diff --git a/CoqOfRust/halo2_proofs/arithmetic.v b/CoqOfRust/halo2_proofs/arithmetic.v new file mode 100644 index 000000000..54a3a91a5 --- /dev/null +++ b/CoqOfRust/halo2_proofs/arithmetic.v @@ -0,0 +1,12313 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module arithmetic. + (* + fn multiexp_serial(coeffs: &[C::Scalar], bases: &[C], acc: &mut C::Curve) { + let coeffs: Vec<_> = coeffs.iter().map(|a| a.to_repr()).collect(); + + let c = if bases.len() < 4 { + 1 + } else if bases.len() < 32 { + 3 + } else { + (f64::from(bases.len() as u32)).ln().ceil() as usize + }; + + fn get_at(segment: usize, c: usize, bytes: &F::Repr) -> usize { + let skip_bits = segment * c; + let skip_bytes = skip_bits / 8; + + if skip_bytes >= 32 { + return 0; + } + + let mut v = [0; 8]; + for (v, o) in v.iter_mut().zip(bytes.as_ref()[skip_bytes..].iter()) { + *v = *o; + } + + let mut tmp = u64::from_le_bytes(v); + tmp >>= skip_bits - (skip_bytes * 8); + tmp = tmp % (1 << c); + + tmp as usize + } + + let segments = (256 / c) + 1; + + for current_segment in (0..segments).rev() { + for _ in 0..c { + *acc = acc.double(); + } + + #[derive(Clone, Copy)] + enum Bucket { + None, + Affine(C), + Projective(C::Curve), + } + + impl Bucket { + fn add_assign(&mut self, other: &C) { + *self = match *self { + Bucket::None => Bucket::Affine( *other), + Bucket::Affine(a) => Bucket::Projective(a + *other), + Bucket::Projective(mut a) => { + a += *other; + Bucket::Projective(a) + } + } + } + + fn add(self, mut other: C::Curve) -> C::Curve { + match self { + Bucket::None => other, + Bucket::Affine(a) => { + other += a; + other + } + Bucket::Projective(a) => other + &a, + } + } + } + + let mut buckets: Vec> = vec![Bucket::None; (1 << c) - 1]; + + for (coeff, base) in coeffs.iter().zip(bases.iter()) { + let coeff = get_at::(current_segment, c, coeff); + if coeff != 0 { + buckets[coeff - 1].add_assign(base); + } + } + + // Summation by parts + // e.g. 3a + 2b + 1c = a + + // (a) + b + + // ((a) + b) + c + let mut running_sum = C::Curve::identity(); + for exp in buckets.into_iter().rev() { + running_sum = exp.add(running_sum); + *acc = *acc + &running_sum; + } + } + } + *) + Definition multiexp_serial (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C ], [ coeffs; bases; acc ] => + ltac:(M.monadic + (let coeffs := M.alloc (| coeffs |) in + let bases := M.alloc (| bases |) in + let acc := M.alloc (| acc |) in + M.read (| + let coeffs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.associated ]; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.associated ] ] ] + Ty.associated + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.associated ], + [], + "map", + [ + Ty.associated; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.associated ] ] ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "iter", + [] + |), + [ M.read (| coeffs |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "ff::PrimeField", + Ty.associated, + [], + "to_repr", + [] + |), + [ M.read (| a |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let c := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ C ], + "len", + [] + |), + [ M.read (| bases |) ] + |)) + (Value.Integer 4) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| Value.Integer 1 |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ C ], + "len", + [] + |), + [ M.read (| bases |) ] + |)) + (Value.Integer 32) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| Value.Integer 3 |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.rust_cast + (M.call_closure (| + M.get_associated_function (| Ty.path "f64", "ceil", [] |), + [ + M.call_closure (| + M.get_associated_function (| Ty.path "f64", "ln", [] |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "f64", + [ Ty.path "u32" ], + "from", + [] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ C ], + "len", + [] + |), + [ M.read (| bases |) ] + |)) + ] + |) + ] + |) + ] + |)) + |))) + ] + |))) + ] + |) + |) in + let segments := + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.div (| Integer.Usize, Value.Integer 256, M.read (| c |) |), + Value.Integer 1 + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ] ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "rev", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| segments |)) ] + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let current_segment := M.copy (| γ0_0 |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", M.read (| c |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let _ := + M.write (| + M.read (| acc |), + M.call_closure (| + M.get_trait_method (| + "group::Group", + Ty.associated, + [], + "double", + [] + |), + [ M.read (| acc |) ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let buckets := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ + Ty.apply + (Ty.path + "halo2_proofs::arithmetic::multiexp_serial::Bucket") + [ C ] + ] + |), + [ + Value.StructTuple + "halo2_proofs::arithmetic::multiexp_serial::Bucket::None" + []; + BinOp.Panic.sub (| + Integer.Usize, + BinOp.Panic.shl (| Value.Integer 1, M.read (| c |) |), + Value.Integer 1 + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.associated ]; + Ty.apply (Ty.path "core::slice::iter::Iter") [ C ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.associated ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ C ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ coeffs ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ C ], + "iter", + [] + |), + [ M.read (| bases |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.associated ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ C ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let coeff := M.copy (| γ1_0 |) in + let base := M.copy (| γ1_1 |) in + let coeff := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::multiexp_serial.get_at", + [] + |), + [ + M.read (| current_segment |); + M.read (| c |); + M.read (| coeff |) + ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.read (| coeff |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::arithmetic::multiexp_serial::Bucket") + [ C ], + "add_assign", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::arithmetic::multiexp_serial::Bucket") + [ C ]; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + buckets; + BinOp.Panic.sub (| + Integer.Usize, + M.read (| + coeff + |), + Value.Integer 1 + |) + ] + |); + M.read (| base |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let running_sum := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::Group", + Ty.associated, + [], + "identity", + [] + |), + [] + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::arithmetic::multiexp_serial::Bucket") + [ C ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::arithmetic::multiexp_serial::Bucket") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "rev", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::arithmetic::multiexp_serial::Bucket") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| buckets |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::arithmetic::multiexp_serial::Bucket") + [ C ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let exp := M.copy (| γ0_0 |) in + let _ := + M.write (| + running_sum, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::arithmetic::multiexp_serial::Bucket") + [ C ], + "add", + [] + |), + [ + M.read (| exp |); + M.read (| running_sum |) + ] + |) + |) in + let _ := + M.write (| + M.read (| acc |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ], + "add", + [] + |), + [ + M.read (| M.read (| acc |) |); + running_sum + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + | _, _ => M.impossible + end. + + Module multiexp_serial. + (* + fn get_at(segment: usize, c: usize, bytes: &F::Repr) -> usize { + let skip_bits = segment * c; + let skip_bytes = skip_bits / 8; + + if skip_bytes >= 32 { + return 0; + } + + let mut v = [0; 8]; + for (v, o) in v.iter_mut().zip(bytes.as_ref()[skip_bytes..].iter()) { + *v = *o; + } + + let mut tmp = u64::from_le_bytes(v); + tmp >>= skip_bits - (skip_bytes * 8); + tmp = tmp % (1 << c); + + tmp as usize + } + *) + Definition get_at (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ segment; c; bytes ] => + ltac:(M.monadic + (let segment := M.alloc (| segment |) in + let c := M.alloc (| c |) in + let bytes := M.alloc (| bytes |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let skip_bits := + M.alloc (| + BinOp.Panic.mul (| Integer.Usize, M.read (| segment |), M.read (| c |) |) + |) in + let skip_bytes := + M.alloc (| + BinOp.Panic.div (| Integer.Usize, M.read (| skip_bits |), Value.Integer 8 |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ge (M.read (| skip_bytes |)) (Value.Integer 32) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| M.read (| M.return_ (| Value.Integer 0 |) |) |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let v := M.alloc (| repeat (Value.Integer 0) 8 |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply (Ty.path "core::slice::iter::IterMut") [ Ty.path "u8" ]; + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.path "u8" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::IterMut") [ Ty.path "u8" ], + [], + "zip", + [ Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.path "u8" ] ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u8" ], + "iter_mut", + [] + |), + [ (* Unsize *) M.pointer_coercion v ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u8" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply (Ty.path "slice") [ Ty.path "u8" ], + [ + Ty.apply + (Ty.path "core::ops::range::RangeFrom") + [ Ty.path "usize" ] + ], + "index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_ref", + [] + |), + [ M.read (| bytes |) ] + |); + Value.StructRecord + "core::ops::range::RangeFrom" + [ ("start", M.read (| skip_bytes |)) ] + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.path "u8" ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "u8" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let v := M.copy (| γ1_0 |) in + let o := M.copy (| γ1_1 |) in + let _ := + M.write (| + M.read (| v |), + M.read (| M.read (| o |) |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let tmp := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u64", "from_le_bytes", [] |), + [ M.read (| v |) ] + |) + |) in + let _ := + let β := tmp in + M.write (| + β, + BinOp.Panic.shr (| + M.read (| β |), + BinOp.Panic.sub (| + Integer.Usize, + M.read (| skip_bits |), + BinOp.Panic.mul (| + Integer.Usize, + M.read (| skip_bytes |), + Value.Integer 8 + |) + |) + |) + |) in + let _ := + M.write (| + tmp, + BinOp.Panic.rem (| + Integer.U64, + M.read (| tmp |), + BinOp.Panic.shl (| Value.Integer 1, M.read (| c |) |) + |) + |) in + M.alloc (| M.rust_cast (M.read (| tmp |)) |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + Enum Bucket + { + ty_params := [ "C" ]; + variants := + [ + { + name := "None"; + item := StructTuple []; + discriminant := None; + }; + { + name := "Affine"; + item := StructTuple [ C ]; + discriminant := None; + }; + { + name := "Projective"; + item := StructTuple [ Ty.associated ]; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_clone_Clone_associated_type_for_halo2_proofs_arithmetic_multiexp_serial_Bucket_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::arithmetic::multiexp_serial::Bucket") [ C ]. + + (* Clone *) + Definition clone (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::arithmetic::multiexp_serial::Bucket::None" + [] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::arithmetic::multiexp_serial::Bucket::Affine", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::arithmetic::multiexp_serial::Bucket::Affine" + [ + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", C, [], "clone", [] |), + [ M.read (| __self_0 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::arithmetic::multiexp_serial::Bucket::Projective", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::arithmetic::multiexp_serial::Bucket::Projective" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.associated, + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone C)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_clone_Clone_associated_type_for_halo2_proofs_arithmetic_multiexp_serial_Bucket_C. + + Module Impl_core_marker_Copy_where_core_marker_Copy_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_marker_Copy_associated_type_for_halo2_proofs_arithmetic_multiexp_serial_Bucket_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::arithmetic::multiexp_serial::Bucket") [ C ]. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_marker_Copy_associated_type_for_halo2_proofs_arithmetic_multiexp_serial_Bucket_C. + + Module Impl_halo2_proofs_arithmetic_multiexp_serial_Bucket_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::arithmetic::multiexp_serial::Bucket") [ C ]. + + (* + fn add_assign(&mut self, other: &C) { + *self = match *self { + Bucket::None => Bucket::Affine( *other), + Bucket::Affine(a) => Bucket::Projective(a + *other), + Bucket::Projective(mut a) => { + a += *other; + Bucket::Projective(a) + } + } + } + *) + Definition add_assign (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + M.write (| + M.read (| self |), + M.read (| + M.match_operator (| + M.read (| self |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "halo2_proofs::arithmetic::multiexp_serial::Bucket::Affine" + [ M.read (| M.read (| other |) |) ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::arithmetic::multiexp_serial::Bucket::Affine", + 0 + |) in + let a := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::arithmetic::multiexp_serial::Bucket::Projective" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + C, + [ C ], + "add", + [] + |), + [ M.read (| a |); M.read (| M.read (| other |) |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::arithmetic::multiexp_serial::Bucket::Projective", + 0 + |) in + let a := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::AddAssign", + Ty.associated, + [ C ], + "add_assign", + [] + |), + [ a; M.read (| M.read (| other |) |) ] + |) + |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::arithmetic::multiexp_serial::Bucket::Projective" + [ M.read (| a |) ] + |))) + ] + |) + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_add_assign : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "add_assign" (add_assign C). + + (* + fn add(self, mut other: C::Curve) -> C::Curve { + match self { + Bucket::None => other, + Bucket::Affine(a) => { + other += a; + other + } + Bucket::Projective(a) => other + &a, + } + } + *) + Definition add (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => ltac:(M.monadic other); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::arithmetic::multiexp_serial::Bucket::Affine", + 0 + |) in + let a := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::AddAssign", + Ty.associated, + [ C ], + "add_assign", + [] + |), + [ other; M.read (| a |) ] + |) + |) in + other)); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::arithmetic::multiexp_serial::Bucket::Projective", + 0 + |) in + let a := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "add", + [] + |), + [ M.read (| other |); a ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_add : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "add" (add C). + End Impl_halo2_proofs_arithmetic_multiexp_serial_Bucket_C. + End multiexp_serial. + + (* + pub fn small_multiexp(coeffs: &[C::Scalar], bases: &[C]) -> C::Curve { + let coeffs: Vec<_> = coeffs.iter().map(|a| a.to_repr()).collect(); + let mut acc = C::Curve::identity(); + + // for byte idx + for byte_idx in (0..32).rev() { + // for bit idx + for bit_idx in (0..8).rev() { + acc = acc.double(); + // for each coeff + for coeff_idx in 0..coeffs.len() { + let byte = coeffs[coeff_idx].as_ref()[byte_idx]; + if ((byte >> bit_idx) & 1) != 0 { + acc += bases[coeff_idx]; + } + } + } + } + + acc + } + *) + Definition small_multiexp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C ], [ coeffs; bases ] => + ltac:(M.monadic + (let coeffs := M.alloc (| coeffs |) in + let bases := M.alloc (| bases |) in + M.read (| + let coeffs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.associated ]; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.associated ] ] ] + Ty.associated + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.associated ], + [], + "map", + [ + Ty.associated; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.associated ] ] ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "iter", + [] + |), + [ M.read (| coeffs |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "ff::PrimeField", + Ty.associated, + [], + "to_repr", + [] + |), + [ M.read (| a |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let acc := + M.alloc (| + M.call_closure (| + M.get_trait_method (| "group::Group", Ty.associated, [], "identity", [] |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ] ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "rev", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", Value.Integer 32) ] + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let byte_idx := M.copy (| γ0_0 |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "i32" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "i32" ], + [], + "rev", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", Value.Integer 8) + ] + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "i32" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let bit_idx := M.copy (| γ0_0 |) in + let _ := + M.write (| + acc, + M.call_closure (| + M.get_trait_method (| + "group::Group", + Ty.associated, + [], + "double", + [] + |), + [ acc ] + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + Value.Integer 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ coeffs ] + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "usize" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let coeff_idx := + M.copy (| + γ0_0 + |) in + let byte := + M.copy (| + M.SubPointer.get_array_field (| + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ + Ty.apply + (Ty.path + "slice") + [ + Ty.path + "u8" + ] + ], + "as_ref", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + coeffs; + M.read (| + coeff_idx + |) + ] + |) + ] + |), + byte_idx + |) + |) in + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (BinOp.Pure.bit_and + (BinOp.Panic.shr (| + M.read (| + byte + |), + M.read (| + bit_idx + |) + |)) + (Value.Integer + 1)) + (Value.Integer + 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::AddAssign", + Ty.associated, + [ + C + ], + "add_assign", + [] + |), + [ + acc; + M.read (| + M.SubPointer.get_array_field (| + M.read (| + bases + |), + coeff_idx + |) + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple + [] + |))) + ] + |))) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + acc + |))) + | _, _ => M.impossible + end. + + (* + pub fn best_multiexp_gpu_cond(coeffs: &[C::Scalar], bases: &[C]) -> C::Curve { + if coeffs.len() == 0 { + C::Curve::identity() + } else { + if coeffs.len() > 1 << 14 { + cfg_if::cfg_if! { + if #[cfg(feature = "cuda")] { + gpu_multiexp(coeffs, bases) + } else { + best_multiexp(coeffs, bases) + } + } + } else { + best_multiexp(coeffs, bases) + } + } + } + *) + Definition best_multiexp_gpu_cond (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C ], [ coeffs; bases ] => + ltac:(M.monadic + (let coeffs := M.alloc (| coeffs |) in + let bases := M.alloc (| bases |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "len", + [] + |), + [ M.read (| coeffs |) ] + |)) + (Value.Integer 0) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "group::Group", Ty.associated, [], "identity", [] |), + [] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "len", + [] + |), + [ M.read (| coeffs |) ] + |)) + (BinOp.Panic.shl (| Value.Integer 1, Value.Integer 14 |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.call_closure (| + M.get_function (| "halo2_proofs::arithmetic::best_multiexp", [ C ] |), + [ M.read (| coeffs |); M.read (| bases |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_function (| "halo2_proofs::arithmetic::best_multiexp", [ C ] |), + [ M.read (| coeffs |); M.read (| bases |) ] + |) + |))) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + pub fn best_multiexp(coeffs: &[C::Scalar], bases: &[C]) -> C::Curve { + assert_eq!(coeffs.len(), bases.len()); + + let num_threads = multicore::current_num_threads(); + if coeffs.len() > num_threads { + let chunk = coeffs.len() / num_threads; + let num_chunks = coeffs.chunks(chunk).len(); + let mut results = vec![C::Curve::identity(); num_chunks]; + multicore::scope(|scope| { + let chunk = coeffs.len() / num_threads; + + for ((coeffs, bases), acc) in coeffs + .chunks(chunk) + .zip(bases.chunks(chunk)) + .zip(results.iter_mut()) + { + scope.spawn(move |_| { + multiexp_serial(coeffs, bases, acc); + }); + } + }); + results.iter().fold(C::Curve::identity(), |a, b| a + b) + } else { + let mut acc = C::Curve::identity(); + multiexp_serial(coeffs, bases, &mut acc); + acc + } + } + *) + Definition best_multiexp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C ], [ coeffs; bases ] => + ltac:(M.monadic + (let coeffs := M.alloc (| coeffs |) in + let bases := M.alloc (| bases |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "len", + [] + |), + [ M.read (| coeffs |) ] + |) + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.apply (Ty.path "slice") [ C ], "len", [] |), + [ M.read (| bases |) ] + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let num_threads := + M.alloc (| + M.call_closure (| M.get_function (| "rayon_core::current_num_threads", [] |), [] |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "len", + [] + |), + [ M.read (| coeffs |) ] + |)) + (M.read (| num_threads |)) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let chunk := + M.alloc (| + BinOp.Panic.div (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "len", + [] + |), + [ M.read (| coeffs |) ] + |), + M.read (| num_threads |) + |) + |) in + let num_chunks := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::exact_size::ExactSizeIterator", + Ty.apply (Ty.path "core::slice::iter::Chunks") [ Ty.associated ], + [], + "len", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "chunks", + [] + |), + [ M.read (| coeffs |); M.read (| chunk |) ] + |) + |) + ] + |) + |) in + let results := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ Ty.associated ] |), + [ + M.call_closure (| + M.get_trait_method (| + "group::Group", + Ty.associated, + [], + "identity", + [] + |), + [] + |); + M.read (| num_chunks |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "rayon_core::scope::scope", + [ + Ty.function + [ + Ty.tuple + [ Ty.apply (Ty.path "&") [ Ty.path "rayon_core::scope::Scope" ] ] + ] + (Ty.tuple []); + Ty.tuple [] + ] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let scope := M.copy (| γ |) in + M.read (| + let chunk := + M.alloc (| + BinOp.Panic.div (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "len", + [] + |), + [ M.read (| coeffs |) ] + |), + M.read (| num_threads |) + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Chunks") + [ Ty.associated ]; + Ty.apply + (Ty.path + "core::slice::iter::Chunks") + [ C ] + ]; + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Chunks") + [ Ty.associated ]; + Ty.apply + (Ty.path + "core::slice::iter::Chunks") + [ C ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Chunks") + [ Ty.associated ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Chunks") + [ C ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "chunks", + [] + |), + [ + M.read (| coeffs |); + M.read (| chunk |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ C ], + "chunks", + [] + |), + [ + M.read (| bases |); + M.read (| chunk |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ results ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Chunks") + [ Ty.associated ]; + Ty.apply + (Ty.path + "core::slice::iter::Chunks") + [ C ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let γ2_0 := + M.SubPointer.get_tuple_field (| + γ1_0, + 0 + |) in + let γ2_1 := + M.SubPointer.get_tuple_field (| + γ1_0, + 1 + |) in + let coeffs := + M.copy (| γ2_0 |) in + let bases := + M.copy (| γ2_1 |) in + let acc := M.copy (| γ1_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "rayon_core::scope::Scope", + "spawn", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "rayon_core::scope::Scope" + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.read (| scope |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let + _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::multiexp_serial", + [ + C + ] + |), + [ + M.read (| + coeffs + |); + M.read (| + bases + |); + M.read (| + acc + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.associated ], + [], + "fold", + [ + Ty.associated; + Ty.function + [ Ty.tuple [ Ty.associated; Ty.apply (Ty.path "&") [ Ty.associated ] ] ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ results ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "group::Group", + Ty.associated, + [], + "identity", + [] + |), + [] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let b := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "add", + [] + |), + [ M.read (| a |); M.read (| b |) ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let acc := + M.alloc (| + M.call_closure (| + M.get_trait_method (| "group::Group", Ty.associated, [], "identity", [] |), + [] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| "halo2_proofs::arithmetic::multiexp_serial", [ C ] |), + [ M.read (| coeffs |); M.read (| bases |); acc ] + |) + |) in + acc)) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + pub fn best_fft(a: &mut [G], omega: G::Scalar, log_n: u32) { + cfg_if::cfg_if! { + if #[cfg(feature = "cuda")]{ + return gpu_fft(a, omega, log_n); + } else { + return best_fft_cpu(a, omega, log_n); + } + } + } + *) + Definition best_fft (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ G ], [ a; omega; log_n ] => + ltac:(M.monadic + (let a := M.alloc (| a |) in + let omega := M.alloc (| omega |) in + let log_n := M.alloc (| log_n |) in + M.catch_return (| + ltac:(M.monadic + (M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_function (| "halo2_proofs::arithmetic::best_fft_cpu", [ G ] |), + [ M.read (| a |); M.read (| omega |); M.read (| log_n |) ] + |) + |) + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + pub fn best_fft_cpu(a: &mut [G], omega: G::Scalar, log_n: u32) { + fn bitreverse(mut n: usize, l: usize) -> usize { + let mut r = 0; + for _ in 0..l { + r = (r << 1) | (n & 1); + n >>= 1; + } + r + } + + let threads = multicore::current_num_threads(); + let log_threads = log2_floor(threads); + let n = a.len() as usize; + assert_eq!(n, 1 << log_n); + + for k in 0..n { + let rk = bitreverse(k, log_n as usize); + if k < rk { + a.swap(rk, k); + } + } + + //let timer1 = start_timer!(|| format!("prepare do fft {}", log_n)); + // precompute twiddle factors + let mut twiddles: Vec<_> = (0..(n / 2) as usize) + .into_iter() + .map(|_| G::Scalar::one()) + .collect(); + + let chunck_size = 1 << 14; + let block_size = 1 << 10; + + if n / 2 < chunck_size { + for i in 1..n / 2 { + twiddles[i] = twiddles[i - 1] * omega; + } + } else { + for i in 1..chunck_size { + twiddles[i] = twiddles[i - 1] * omega; + } + + let base = twiddles[chunck_size - 1] * omega; + let mut chunks = twiddles.chunks_mut(chunck_size); + let mut prev = chunks.next().unwrap(); + + chunks.for_each(|curr| { + curr.par_chunks_mut(block_size) + .enumerate() + .for_each(|(i, v)| { + v.iter_mut().enumerate().for_each(|(j, v)| { + *v = base * prev[i * block_size + j]; + }); + }); + prev = curr; + }); + } + + if log_n <= log_threads { + let mut chunk = 2_usize; + let mut twiddle_chunk = (n / 2) as usize; + for _ in 0..log_n { + a.chunks_mut(chunk).for_each(|coeffs| { + let (left, right) = coeffs.split_at_mut(chunk / 2); + + // case when twiddle factor is one + let (a, left) = left.split_at_mut(1); + let (b, right) = right.split_at_mut(1); + let t = b[0]; + b[0] = a[0]; + a[0].group_add(&t); + b[0].group_sub(&t); + + left.iter_mut() + .zip(right.iter_mut()) + .enumerate() + .for_each(|(i, (a, b))| { + let mut t = *b; + t.group_scale(&twiddles[(i + 1) * twiddle_chunk]); + *b = *a; + a.group_add(&t); + b.group_sub(&t); + }); + }); + chunk *= 2; + twiddle_chunk /= 2; + } + } else { + recursive_butterfly_arithmetic(a, n, 1, &twiddles, 0) + } + } + *) + Definition best_fft_cpu (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ G ], [ a; omega; log_n ] => + ltac:(M.monadic + (let a := M.alloc (| a |) in + let omega := M.alloc (| omega |) in + let log_n := M.alloc (| log_n |) in + M.read (| + let threads := + M.alloc (| + M.call_closure (| M.get_function (| "rayon_core::current_num_threads", [] |), [] |) + |) in + let log_threads := + M.alloc (| + M.call_closure (| + M.get_function (| "halo2_proofs::arithmetic::log2_floor", [] |), + [ M.read (| threads |) ] + |) + |) in + let n := + M.copy (| + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.apply (Ty.path "slice") [ G ], "len", [] |), + [ M.read (| a |) ] + |) + |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ n; M.alloc (| BinOp.Panic.shl (| Value.Integer 1, M.read (| log_n |) |) |) ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| n |)) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let k := M.copy (| γ0_0 |) in + let rk := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::best_fft_cpu.bitreverse", + [] + |), + [ M.read (| k |); M.rust_cast (M.read (| log_n |)) ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt (M.read (| k |)) (M.read (| rk |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ G ], + "swap", + [] + |), + [ M.read (| a |); M.read (| rk |); M.read (| k |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let twiddles := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ]; + Ty.function [ Ty.tuple [ Ty.path "usize" ] ] Ty.associated + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "map", + [ Ty.associated; Ty.function [ Ty.tuple [ Ty.path "usize" ] ] Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.read (| + M.use + (M.alloc (| + BinOp.Panic.div (| + Integer.Usize, + M.read (| n |), + Value.Integer 2 + |) + |)) + |)) + ] + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let chunck_size := + M.alloc (| BinOp.Panic.shl (| Value.Integer 1, Value.Integer 14 |) |) in + let block_size := M.alloc (| BinOp.Panic.shl (| Value.Integer 1, Value.Integer 10 |) |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (BinOp.Panic.div (| Integer.Usize, M.read (| n |), Value.Integer 2 |)) + (M.read (| chunck_size |)) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 1); + ("end_", + BinOp.Panic.div (| + Integer.Usize, + M.read (| n |), + Value.Integer 2 + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ twiddles; M.read (| i |) ] + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.associated ], + "mul", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + twiddles; + BinOp.Panic.sub (| + Integer.Usize, + M.read (| i |), + Value.Integer 1 + |) + ] + |) + |); + M.read (| omega |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))); + fun γ => + ltac:(M.monadic + (let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 1); ("end_", M.read (| chunck_size |)) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ twiddles; M.read (| i |) ] + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.associated ], + "mul", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + twiddles; + BinOp.Panic.sub (| + Integer.Usize, + M.read (| i |), + Value.Integer 1 + |) + ] + |) + |); + M.read (| omega |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let base := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.associated ], + "mul", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + twiddles; + BinOp.Panic.sub (| + Integer.Usize, + M.read (| chunck_size |), + Value.Integer 1 + |) + ] + |) + |); + M.read (| omega |) + ] + |) + |) in + let chunks := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "chunks_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ twiddles ] + |); + M.read (| chunck_size |) + ] + |) + |) in + let prev := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::ChunksMut") [ Ty.associated ], + [], + "next", + [] + |), + [ chunks ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::ChunksMut") [ Ty.associated ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.read (| chunks |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let curr := M.copy (| γ |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::iter::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "rayon::slice::chunks::ChunksMut") + [ Ty.associated ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ] + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IndexedParallelIterator", + Ty.apply + (Ty.path + "rayon::slice::chunks::ChunksMut") + [ Ty.associated ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::slice::ParallelSliceMut", + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + [ Ty.associated ], + "par_chunks_mut", + [] + |), + [ + M.read (| curr |); + M.read (| block_size |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let i := M.copy (| γ0_0 |) in + let v := M.copy (| γ0_1 |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&mut") + [ + Ty.associated + ] + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ], + "iter_mut", + [] + |), + [ + M.read (| + v + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + j := + M.copy (| + γ0_0 + |) in + let + v := + M.copy (| + γ0_1 + |) in + M.read (| + let + _ := + M.write (| + M.read (| + v + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + base + |); + M.read (| + M.SubPointer.get_array_field (| + M.read (| + prev + |), + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.mul (| + Integer.Usize, + M.read (| + i + |), + M.read (| + block_size + |) + |), + M.read (| + j + |) + |) + |) + |) + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := M.write (| prev, M.read (| curr |) |) in + M.alloc (| Value.Tuple [] |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.le (M.read (| log_n |)) (M.read (| log_threads |)) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let chunk := M.alloc (| Value.Integer 2 |) in + let twiddle_chunk := + M.copy (| + M.use + (M.alloc (| + BinOp.Panic.div (| Integer.Usize, M.read (| n |), Value.Integer 2 |) + |)) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| log_n |)) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::ChunksMut") + [ G ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "slice") [ G ] ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ G ], + "chunks_mut", + [] + |), + [ M.read (| a |); M.read (| chunk |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let coeffs := M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ G ], + "split_at_mut", + [] + |), + [ + M.read (| coeffs |); + BinOp.Panic.div (| + Integer.Usize, + M.read (| chunk |), + Value.Integer 2 + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let left := + M.copy (| γ0_0 |) in + let right := + M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ G ], + "split_at_mut", + [] + |), + [ + M.read (| + left + |); + Value.Integer 1 + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let a := + M.copy (| + γ0_0 + |) in + let left := + M.copy (| + γ0_1 + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ G ], + "split_at_mut", + [] + |), + [ + M.read (| + right + |); + Value.Integer + 1 + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let b := + M.copy (| + γ0_0 + |) in + let + right := + M.copy (| + γ0_1 + |) in + let t := + M.copy (| + M.SubPointer.get_array_field (| + M.read (| + b + |), + M.alloc (| + Value.Integer + 0 + |) + |) + |) in + let _ := + M.write (| + M.SubPointer.get_array_field (| + M.read (| + b + |), + M.alloc (| + Value.Integer + 0 + |) + |), + M.read (| + M.SubPointer.get_array_field (| + M.read (| + a + |), + M.alloc (| + Value.Integer + 0 + |) + |) + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_add", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| + a + |), + M.alloc (| + Value.Integer + 0 + |) + |); + t + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_sub", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| + b + |), + M.alloc (| + Value.Integer + 0 + |) + |); + t + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + G + ]; + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + G + ] + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + G + ]; + Ty.apply + (Ty.path + "&mut") + [ + G + ] + ] + ] + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + G + ]; + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + G + ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + G + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + G + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + G + ], + "iter_mut", + [] + |), + [ + M.read (| + left + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + G + ], + "iter_mut", + [] + |), + [ + M.read (| + right + |) + ] + |) + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + i := + M.copy (| + γ0_0 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_1, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_1, + 1 + |) in + let + a := + M.copy (| + γ1_0 + |) in + let + b := + M.copy (| + γ1_1 + |) in + M.read (| + let + t := + M.copy (| + M.read (| + b + |) + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_scale", + [] + |), + [ + t; + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + twiddles; + BinOp.Panic.mul (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.read (| + i + |), + Value.Integer + 1 + |), + M.read (| + twiddle_chunk + |) + |) + ] + |) + ] + |) + |) in + let + _ := + M.write (| + M.read (| + b + |), + M.read (| + M.read (| + a + |) + |) + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_add", + [] + |), + [ + M.read (| + a + |); + t + ] + |) + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_sub", + [] + |), + [ + M.read (| + b + |); + t + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |))) + ] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + let β := chunk in + M.write (| + β, + BinOp.Panic.mul (| + Integer.Usize, + M.read (| β |), + Value.Integer 2 + |) + |) in + let _ := + let β := twiddle_chunk in + M.write (| + β, + BinOp.Panic.div (| + Integer.Usize, + M.read (| β |), + Value.Integer 2 + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::recursive_butterfly_arithmetic", + [ G ] + |), + [ + M.read (| a |); + M.read (| n |); + Value.Integer 1; + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ twiddles ] + |); + Value.Integer 0 + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Module best_fft_cpu. + (* + fn bitreverse(mut n: usize, l: usize) -> usize { + let mut r = 0; + for _ in 0..l { + r = (r << 1) | (n & 1); + n >>= 1; + } + r + } + *) + Definition bitreverse (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ n; l ] => + ltac:(M.monadic + (let n := M.alloc (| n |) in + let l := M.alloc (| l |) in + M.read (| + let r := M.alloc (| Value.Integer 0 |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| l |)) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let _ := + M.write (| + r, + BinOp.Pure.bit_or + (BinOp.Panic.shl (| M.read (| r |), Value.Integer 1 |)) + (BinOp.Pure.bit_and (M.read (| n |)) (Value.Integer 1)) + |) in + let _ := + let β := n in + M.write (| + β, + BinOp.Panic.shr (| M.read (| β |), Value.Integer 1 |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + r + |))) + | _, _ => M.impossible + end. + End best_fft_cpu. + + (* + pub fn recursive_butterfly_arithmetic( + a: &mut [G], + n: usize, + twiddle_chunk: usize, + twiddles: &[G::Scalar], + level: u32, + ) { + if n == 2 { + let t = a[1]; + a[1] = a[0]; + a[0].group_add(&t); + a[1].group_sub(&t); + } else { + let (left, right) = a.split_at_mut(n / 2); + + rayon::join( + || recursive_butterfly_arithmetic(left, n / 2, twiddle_chunk * 2, twiddles, level + 1), + || recursive_butterfly_arithmetic(right, n / 2, twiddle_chunk * 2, twiddles, level + 1), + ); + + // case when twiddle factor is one + let (a, left) = left.split_at_mut(1); + let (b, right) = right.split_at_mut(1); + let t = b[0]; + b[0] = a[0]; + a[0].group_add(&t); + b[0].group_sub(&t); + + let chunk_size = 512; + if n > chunk_size << 2 && level < 4 { + left.par_chunks_mut(chunk_size) + .zip(right.par_chunks_mut(chunk_size)) + .enumerate() + .for_each(|(i, (left, right))| { + left.iter_mut() + .zip(right.iter_mut()) + .enumerate() + .for_each(|(j, (a, b))| { + let mut t = *b; + t.group_scale(&twiddles[(i * chunk_size + j + 1) * twiddle_chunk]); + *b = *a; + a.group_add(&t); + b.group_sub(&t); + }); + }); + } else { + left.iter_mut() + .zip(right.iter_mut()) + .enumerate() + .for_each(|(i, (a, b))| { + let mut t = *b; + t.group_scale(&twiddles[(i + 1) * twiddle_chunk]); + *b = *a; + a.group_add(&t); + b.group_sub(&t); + }); + } + } + } + *) + Definition recursive_butterfly_arithmetic (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ G ], [ a; n; twiddle_chunk; twiddles; level ] => + ltac:(M.monadic + (let a := M.alloc (| a |) in + let n := M.alloc (| n |) in + let twiddle_chunk := M.alloc (| twiddle_chunk |) in + let twiddles := M.alloc (| twiddles |) in + let level := M.alloc (| level |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use (M.alloc (| BinOp.Pure.eq (M.read (| n |)) (Value.Integer 2) |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let t := + M.copy (| + M.SubPointer.get_array_field (| + M.read (| a |), + M.alloc (| Value.Integer 1 |) + |) + |) in + let _ := + M.write (| + M.SubPointer.get_array_field (| + M.read (| a |), + M.alloc (| Value.Integer 1 |) + |), + M.read (| + M.SubPointer.get_array_field (| + M.read (| a |), + M.alloc (| Value.Integer 0 |) + |) + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_add", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| a |), + M.alloc (| Value.Integer 0 |) + |); + t + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_sub", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| a |), + M.alloc (| Value.Integer 1 |) + |); + t + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ G ], + "split_at_mut", + [] + |), + [ + M.read (| a |); + BinOp.Panic.div (| Integer.Usize, M.read (| n |), Value.Integer 2 |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "rayon_core::join::join", + [ + Ty.function [ Ty.tuple [] ] (Ty.tuple []); + Ty.function [ Ty.tuple [] ] (Ty.tuple []); + Ty.tuple []; + Ty.tuple [] + ] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::recursive_butterfly_arithmetic", + [ G ] + |), + [ + M.read (| left |); + BinOp.Panic.div (| + Integer.Usize, + M.read (| n |), + Value.Integer 2 + |); + BinOp.Panic.mul (| + Integer.Usize, + M.read (| twiddle_chunk |), + Value.Integer 2 + |); + M.read (| twiddles |); + BinOp.Panic.add (| + Integer.U32, + M.read (| level |), + Value.Integer 1 + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::recursive_butterfly_arithmetic", + [ G ] + |), + [ + M.read (| right |); + BinOp.Panic.div (| + Integer.Usize, + M.read (| n |), + Value.Integer 2 + |); + BinOp.Panic.mul (| + Integer.Usize, + M.read (| twiddle_chunk |), + Value.Integer 2 + |); + M.read (| twiddles |); + BinOp.Panic.add (| + Integer.U32, + M.read (| level |), + Value.Integer 1 + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ G ], + "split_at_mut", + [] + |), + [ M.read (| left |); Value.Integer 1 ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let a := M.copy (| γ0_0 |) in + let left := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ G ], + "split_at_mut", + [] + |), + [ M.read (| right |); Value.Integer 1 ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let b := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + let t := + M.copy (| + M.SubPointer.get_array_field (| + M.read (| b |), + M.alloc (| Value.Integer 0 |) + |) + |) in + let _ := + M.write (| + M.SubPointer.get_array_field (| + M.read (| b |), + M.alloc (| Value.Integer 0 |) + |), + M.read (| + M.SubPointer.get_array_field (| + M.read (| a |), + M.alloc (| Value.Integer 0 |) + |) + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_add", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| a |), + M.alloc (| Value.Integer 0 |) + |); + t + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_sub", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| b |), + M.alloc (| Value.Integer 0 |) + |); + t + ] + |) + |) in + let chunk_size := M.alloc (| Value.Integer 512 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + BinOp.Pure.gt + (M.read (| n |)) + (BinOp.Panic.shl (| + M.read (| chunk_size |), + Value.Integer 2 + |)), + ltac:(M.monadic + (BinOp.Pure.lt + (M.read (| level |)) + (Value.Integer 4))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::iter::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "rayon::iter::zip::Zip") + [ + Ty.apply + (Ty.path + "rayon::slice::chunks::ChunksMut") + [ G ]; + Ty.apply + (Ty.path + "rayon::slice::chunks::ChunksMut") + [ G ] + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "slice") + [ G ] + ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "slice") + [ G ] + ] + ] + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IndexedParallelIterator", + Ty.apply + (Ty.path "rayon::iter::zip::Zip") + [ + Ty.apply + (Ty.path + "rayon::slice::chunks::ChunksMut") + [ G ]; + Ty.apply + (Ty.path + "rayon::slice::chunks::ChunksMut") + [ G ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IndexedParallelIterator", + Ty.apply + (Ty.path + "rayon::slice::chunks::ChunksMut") + [ G ], + [], + "zip", + [ + Ty.apply + (Ty.path + "rayon::slice::chunks::ChunksMut") + [ G ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::slice::ParallelSliceMut", + Ty.apply + (Ty.path "slice") + [ G ], + [ G ], + "par_chunks_mut", + [] + |), + [ + M.read (| left |); + M.read (| chunk_size |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "rayon::slice::ParallelSliceMut", + Ty.apply + (Ty.path "slice") + [ G ], + [ G ], + "par_chunks_mut", + [] + |), + [ + M.read (| right |); + M.read (| chunk_size |) + ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let i := + M.copy (| γ0_0 |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_1, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_1, + 1 + |) in + let left := + M.copy (| γ1_0 |) in + let right := + M.copy (| γ1_1 |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ G ]; + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ G ] + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + G + ]; + Ty.apply + (Ty.path + "&mut") + [ + G + ] + ] + ] + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ G ]; + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ G ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ G ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ G + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + G + ], + "iter_mut", + [] + |), + [ + M.read (| + left + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + G + ], + "iter_mut", + [] + |), + [ + M.read (| + right + |) + ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + j := + M.copy (| + γ0_0 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_1, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_1, + 1 + |) in + let + a := + M.copy (| + γ1_0 + |) in + let + b := + M.copy (| + γ1_1 + |) in + M.read (| + let + t := + M.copy (| + M.read (| + b + |) + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_scale", + [] + |), + [ + t; + M.SubPointer.get_array_field (| + M.read (| + twiddles + |), + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.mul (| + Integer.Usize, + M.read (| + i + |), + M.read (| + chunk_size + |) + |), + M.read (| + j + |) + |), + Value.Integer + 1 + |), + M.read (| + twiddle_chunk + |) + |) + |) + |) + ] + |) + |) in + let + _ := + M.write (| + M.read (| + b + |), + M.read (| + M.read (| + a + |) + |) + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_add", + [] + |), + [ + M.read (| + a + |); + t + ] + |) + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_sub", + [] + |), + [ + M.read (| + b + |); + t + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ G ]; + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ G ] + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ G ]; + Ty.apply + (Ty.path "&mut") + [ G ] + ] + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ G ]; + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ G ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ G ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ G ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ G ], + "iter_mut", + [] + |), + [ M.read (| left |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ G ], + "iter_mut", + [] + |), + [ M.read (| right |) ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let i := + M.copy (| γ0_0 |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_1, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_1, + 1 + |) in + let a := + M.copy (| γ1_0 |) in + let b := + M.copy (| γ1_1 |) in + M.read (| + let t := + M.copy (| + M.read (| b |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_scale", + [] + |), + [ + t; + M.SubPointer.get_array_field (| + M.read (| + twiddles + |), + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.read (| + i + |), + Value.Integer + 1 + |), + M.read (| + twiddle_chunk + |) + |) + |) + |) + ] + |) + |) in + let _ := + M.write (| + M.read (| b |), + M.read (| + M.read (| a |) + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_add", + [] + |), + [ + M.read (| a |); + t + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_sub", + [] + |), + [ + M.read (| b |); + t + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + pub fn eval_polynomial_st(poly: &[F], point: F) -> F { + poly.iter() + .rev() + .fold(F::zero(), |acc, coeff| acc * point + coeff) + } + *) + Definition eval_polynomial_st (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ poly; point ] => + ltac:(M.monadic + (let poly := M.alloc (| poly |) in + let point := M.alloc (| point |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ Ty.apply (Ty.path "core::slice::iter::Iter") [ F ] ], + [], + "fold", + [ F; Ty.function [ Ty.tuple [ F; Ty.apply (Ty.path "&") [ F ] ] ] F ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ F ], + [], + "rev", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| Ty.apply (Ty.path "slice") [ F ], "iter", [] |), + [ M.read (| poly |) ] + |) + ] + |); + M.call_closure (| M.get_trait_method (| "ff::Field", F, [], "zero", [] |), [] |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let coeff := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + F, + [ Ty.apply (Ty.path "&") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ F ], + "mul", + [] + |), + [ M.read (| acc |); M.read (| point |) ] + |); + M.read (| coeff |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + | _, _ => M.impossible + end. + + (* + pub fn eval_polynomial(poly: &[F], point: F) -> F { + let n = poly.len(); + let num_threads = multicore::current_num_threads(); + if n * 2 < num_threads { + eval_polynomial_st(poly, point) + } else { + let chunk_size = (n + num_threads - 1) / num_threads; + let mut parts = vec![F::zero(); num_threads]; + multicore::scope(|scope| { + for (chunk_idx, (out, poly)) in + parts.chunks_mut(1).zip(poly.chunks(chunk_size)).enumerate() + { + scope.spawn(move |_| { + let start = chunk_idx * chunk_size; + out[0] = eval_polynomial_st(poly, point) + * point.pow_vartime(&[start as u64, 0, 0, 0]); + }); + } + }); + parts.iter().fold(F::zero(), |acc, coeff| acc + coeff) + } + } + *) + Definition eval_polynomial (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ poly; point ] => + ltac:(M.monadic + (let poly := M.alloc (| poly |) in + let point := M.alloc (| point |) in + M.read (| + let n := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.apply (Ty.path "slice") [ F ], "len", [] |), + [ M.read (| poly |) ] + |) + |) in + let num_threads := + M.alloc (| + M.call_closure (| M.get_function (| "rayon_core::current_num_threads", [] |), [] |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (BinOp.Panic.mul (| Integer.Usize, M.read (| n |), Value.Integer 2 |)) + (M.read (| num_threads |)) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.call_closure (| + M.get_function (| "halo2_proofs::arithmetic::eval_polynomial_st", [ F ] |), + [ M.read (| poly |); M.read (| point |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let chunk_size := + M.alloc (| + BinOp.Panic.div (| + Integer.Usize, + BinOp.Panic.sub (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.read (| n |), + M.read (| num_threads |) + |), + Value.Integer 1 + |), + M.read (| num_threads |) + |) + |) in + let parts := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ F ] |), + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "zero", [] |), + [] + |); + M.read (| num_threads |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "rayon_core::scope::scope", + [ + Ty.function + [ + Ty.tuple + [ Ty.apply (Ty.path "&") [ Ty.path "rayon_core::scope::Scope" ] ] + ] + (Ty.tuple []); + Ty.tuple [] + ] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let scope := M.copy (| γ |) in + M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::ChunksMut") + [ F ]; + Ty.apply + (Ty.path + "core::slice::iter::Chunks") + [ F ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::ChunksMut") + [ F ]; + Ty.apply + (Ty.path + "core::slice::iter::Chunks") + [ F ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::ChunksMut") + [ F ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Chunks") + [ F ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "chunks_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ parts ] + |); + Value.Integer 1 + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "chunks", + [] + |), + [ + M.read (| poly |); + M.read (| chunk_size |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::ChunksMut") + [ F ]; + Ty.apply + (Ty.path + "core::slice::iter::Chunks") + [ F ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let chunk_idx := + M.copy (| γ1_0 |) in + let γ2_0 := + M.SubPointer.get_tuple_field (| + γ1_1, + 0 + |) in + let γ2_1 := + M.SubPointer.get_tuple_field (| + γ1_1, + 1 + |) in + let out := M.copy (| γ2_0 |) in + let poly := M.copy (| γ2_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "rayon_core::scope::Scope", + "spawn", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "rayon_core::scope::Scope" + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.read (| scope |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let + start := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + M.read (| + chunk_idx + |), + M.read (| + chunk_size + |) + |) + |) in + let + _ := + M.write (| + M.SubPointer.get_array_field (| + M.read (| + out + |), + M.alloc (| + Value.Integer + 0 + |) + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ + F + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::eval_polynomial_st", + [ + F + ] + |), + [ + M.read (| + poly + |); + M.read (| + point + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "pow_vartime", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.path + "u64" + ] + ] + ] + |), + [ + point; + M.alloc (| + Value.Array + [ + M.rust_cast + (M.read (| + start + |)); + Value.Integer + 0; + Value.Integer + 0; + Value.Integer + 0 + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ F ], + [], + "fold", + [ F; Ty.function [ Ty.tuple [ F; Ty.apply (Ty.path "&") [ F ] ] ] F ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ parts ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "zero", [] |), + [] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let coeff := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + F, + [ Ty.apply (Ty.path "&") [ F ] ], + "add", + [] + |), + [ M.read (| acc |); M.read (| coeff |) ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + pub fn compute_inner_product(a: &[F], b: &[F]) -> F { + // TODO: parallelize? + assert_eq!(a.len(), b.len()); + + let mut acc = F::zero(); + for (a, b) in a.iter().zip(b.iter()) { + acc += ( *a) * ( *b); + } + + acc + } + *) + Definition compute_inner_product (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ a; b ] => + ltac:(M.monadic + (let a := M.alloc (| a |) in + let b := M.alloc (| b |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.apply (Ty.path "slice") [ F ], "len", [] |), + [ M.read (| a |) ] + |) + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.apply (Ty.path "slice") [ F ], "len", [] |), + [ M.read (| b |) ] + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let acc := + M.alloc (| + M.call_closure (| M.get_trait_method (| "ff::Field", F, [], "zero", [] |), [] |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply (Ty.path "core::slice::iter::Iter") [ F ]; + Ty.apply (Ty.path "core::slice::iter::Iter") [ F ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ F ], + [], + "zip", + [ Ty.apply (Ty.path "core::slice::iter::Iter") [ F ] ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "iter", + [] + |), + [ M.read (| a |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "iter", + [] + |), + [ M.read (| b |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply (Ty.path "core::slice::iter::Iter") [ F ]; + Ty.apply (Ty.path "core::slice::iter::Iter") [ F ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let a := M.copy (| γ1_0 |) in + let b := M.copy (| γ1_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::AddAssign", + F, + [ F ], + "add_assign", + [] + |), + [ + acc; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ F ], + "mul", + [] + |), + [ + M.read (| M.read (| a |) |); + M.read (| M.read (| b |) |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + acc + |))) + | _, _ => M.impossible + end. + + (* + pub fn kate_division<'a, F: Field, I: IntoIterator>(a: I, mut b: F) -> Vec + where + I::IntoIter: DoubleEndedIterator + ExactSizeIterator, + { + b = -b; + let a = a.into_iter(); + + let mut q = vec![F::zero(); a.len() - 1]; + + let mut tmp = F::zero(); + for (q, r) in q.iter_mut().rev().zip(a.rev()) { + let mut lead_coeff = *r; + lead_coeff.sub_assign(&tmp); + *q = lead_coeff; + tmp = lead_coeff; + tmp.mul_assign(&b); + } + + q + } + *) + Definition kate_division (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F; _ as I ], [ a; b ] => + ltac:(M.monadic + (let a := M.alloc (| a |) in + let b := M.alloc (| b |) in + M.read (| + let _ := + M.write (| + b, + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Neg", F, [], "neg", [] |), + [ M.read (| b |) ] + |) + |) in + let a := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + I, + [], + "into_iter", + [] + |), + [ M.read (| a |) ] + |) + |) in + let q := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ F ] |), + [ + M.call_closure (| M.get_trait_method (| "ff::Field", F, [], "zero", [] |), [] |); + BinOp.Panic.sub (| + Integer.Usize, + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::exact_size::ExactSizeIterator", + Ty.associated, + [], + "len", + [] + |), + [ a ] + |), + Value.Integer 1 + |) + ] + |) + |) in + let tmp := + M.alloc (| + M.call_closure (| M.get_trait_method (| "ff::Field", F, [], "zero", [] |), [] |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ Ty.apply (Ty.path "core::slice::iter::IterMut") [ F ] ]; + Ty.apply (Ty.path "core::iter::adapters::rev::Rev") [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ Ty.apply (Ty.path "core::slice::iter::IterMut") [ F ] ], + [], + "zip", + [ Ty.apply (Ty.path "core::iter::adapters::rev::Rev") [ Ty.associated ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::IterMut") [ F ], + [], + "rev", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ q ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.associated, + [], + "rev", + [] + |), + [ M.read (| a |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ Ty.apply (Ty.path "core::slice::iter::IterMut") [ F ] ]; + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ Ty.associated ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let q := M.copy (| γ1_0 |) in + let r := M.copy (| γ1_1 |) in + let lead_coeff := M.copy (| M.read (| r |) |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::SubAssign", + F, + [ Ty.apply (Ty.path "&") [ F ] ], + "sub_assign", + [] + |), + [ lead_coeff; tmp ] + |) + |) in + let _ := + M.write (| M.read (| q |), M.read (| lead_coeff |) |) in + let _ := M.write (| tmp, M.read (| lead_coeff |) |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + F, + [ Ty.apply (Ty.path "&") [ F ] ], + "mul_assign", + [] + |), + [ tmp; b ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + q + |))) + | _, _ => M.impossible + end. + + (* + pub fn parallelize(v: &mut [T], f: F) { + let n = v.len(); + let num_threads = multicore::current_num_threads(); + let mut chunk = (n as usize) / num_threads; + if chunk < num_threads { + chunk = n as usize; + } + + multicore::scope(|scope| { + for (chunk_num, v) in v.chunks_mut(chunk).enumerate() { + let f = f.clone(); + scope.spawn(move |_| { + let start = chunk_num * chunk; + f(v, start); + }); + } + }); + } + *) + Definition parallelize (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ T; F ], [ v; f ] => + ltac:(M.monadic + (let v := M.alloc (| v |) in + let f := M.alloc (| f |) in + M.read (| + let n := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.apply (Ty.path "slice") [ T ], "len", [] |), + [ M.read (| v |) ] + |) + |) in + let num_threads := + M.alloc (| + M.call_closure (| M.get_function (| "rayon_core::current_num_threads", [] |), [] |) + |) in + let chunk := + M.alloc (| + BinOp.Panic.div (| Integer.Usize, M.read (| M.use n |), M.read (| num_threads |) |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt (M.read (| chunk |)) (M.read (| num_threads |)) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let _ := M.write (| chunk, M.read (| M.use n |) |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "rayon_core::scope::scope", + [ + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "rayon_core::scope::Scope" ] ] ] + (Ty.tuple []); + Ty.tuple [] + ] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let scope := M.copy (| γ |) in + M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::ChunksMut") + [ T ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::ChunksMut") + [ T ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ T ], + "chunks_mut", + [] + |), + [ M.read (| v |); M.read (| chunk |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::ChunksMut") + [ T ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let chunk_num := M.copy (| γ1_0 |) in + let v := M.copy (| γ1_1 |) in + let f := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + F, + [], + "clone", + [] + |), + [ f ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "rayon_core::scope::Scope", + "spawn", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "rayon_core::scope::Scope" + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.read (| scope |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let start := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + M.read (| + chunk_num + |), + M.read (| + chunk + |) + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + F, + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "slice") + [ + T + ] + ]; + Ty.path + "usize" + ] + ], + "call", + [] + |), + [ + f; + Value.Tuple + [ + M.read (| + v + |); + M.read (| + start + |) + ] + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + (* + fn log2_floor(num: usize) -> u32 { + assert!(num > 0); + + let mut pow = 0; + + while (1 << (pow + 1)) <= num { + pow += 1; + } + + pow + } + *) + Definition log2_floor (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ num ] => + ltac:(M.monadic + (let num := M.alloc (| num |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not (BinOp.Pure.gt (M.read (| num |)) (Value.Integer 0)) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "assertion failed: num > 0" |) ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let pow := M.alloc (| Value.Integer 0 |) in + let _ := + M.loop (| + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.le + (BinOp.Panic.shl (| + Value.Integer 1, + BinOp.Panic.add (| + Integer.U32, + M.read (| pow |), + Value.Integer 1 + |) + |)) + (M.read (| num |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let _ := + let β := pow in + M.write (| + β, + BinOp.Panic.add (| Integer.U32, M.read (| β |), Value.Integer 1 |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + let _ := + M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |) in + M.alloc (| Value.Tuple [] |) + |) + |) + |))) + ] + |))) + |) in + pow + |))) + | _, _ => M.impossible + end. + + (* + pub fn mul_acc(f: &mut [F]) { + let num_threads = multicore::current_num_threads(); + let len = f.len(); + + if len < num_threads * 16 { + for i in 0..f.len() - 1 { + f[i + 1] = f[i] * f[i + 1]; + } + } else { + let chunk_size = len / 4; + let chunk_acc = f + .par_chunks_mut(chunk_size) + .map(|chunk| { + chunk[0] = chunk[0]; + for j in 1..chunk.len() { + chunk[j] = chunk[j - 1] * chunk[j]; + } + chunk.last().unwrap().clone() + }) + .collect::>(); + + let mut acc = chunk_acc[0]; + for (chunk, curr_acc) in f.chunks_mut(chunk_size).zip(chunk_acc.into_iter()).skip(1) { + chunk.par_iter_mut().for_each(|p| { + *p = *p * acc; + }); + + acc *= curr_acc; + } + } + } + *) + Definition mul_acc (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ f ] => + ltac:(M.monadic + (let f := M.alloc (| f |) in + M.read (| + let num_threads := + M.alloc (| + M.call_closure (| M.get_function (| "rayon_core::current_num_threads", [] |), [] |) + |) in + let len := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.apply (Ty.path "slice") [ F ], "len", [] |), + [ M.read (| f |) ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (M.read (| len |)) + (BinOp.Panic.mul (| + Integer.Usize, + M.read (| num_threads |), + Value.Integer 16 + |)) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + BinOp.Panic.sub (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "len", + [] + |), + [ M.read (| f |) ] + |), + Value.Integer 1 + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.write (| + M.SubPointer.get_array_field (| + M.read (| f |), + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.read (| i |), + Value.Integer 1 + |) + |) + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ F ], + "mul", + [] + |), + [ + M.read (| + M.SubPointer.get_array_field (| + M.read (| f |), + i + |) + |); + M.read (| + M.SubPointer.get_array_field (| + M.read (| f |), + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.read (| i |), + Value.Integer 1 + |) + |) + |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))); + fun γ => + ltac:(M.monadic + (let chunk_size := + M.alloc (| + BinOp.Panic.div (| Integer.Usize, M.read (| len |), Value.Integer 4 |) + |) in + let chunk_acc := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::map::Map") + [ + Ty.apply (Ty.path "rayon::slice::chunks::ChunksMut") [ F ]; + Ty.function + [ + Ty.tuple + [ Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ F ] ] + ] + ] + F + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply (Ty.path "rayon::slice::chunks::ChunksMut") [ F ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "slice") [ F ] ] + ] + ] + F; + F + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::slice::ParallelSliceMut", + Ty.apply (Ty.path "slice") [ F ], + [ F ], + "par_chunks_mut", + [] + |), + [ M.read (| f |); M.read (| chunk_size |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let chunk := M.copy (| γ |) in + M.read (| + let _ := + M.write (| + M.SubPointer.get_array_field (| + M.read (| chunk |), + M.alloc (| Value.Integer 0 |) + |), + M.read (| + M.SubPointer.get_array_field (| + M.read (| chunk |), + M.alloc (| Value.Integer 0 |) + |) + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 1); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ F ], + "len", + [] + |), + [ M.read (| chunk |) ] + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let j := + M.copy (| γ0_0 |) in + let _ := + M.write (| + M.SubPointer.get_array_field (| + M.read (| chunk |), + j + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ F ], + "mul", + [] + |), + [ + M.read (| + M.SubPointer.get_array_field (| + M.read (| + chunk + |), + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + M.read (| + j + |), + Value.Integer + 1 + |) + |) + |) + |); + M.read (| + M.SubPointer.get_array_field (| + M.read (| + chunk + |), + j + |) + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + F, + [], + "clone", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ F ] ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "last", + [] + |), + [ M.read (| chunk |) ] + |) + ] + |) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let acc := + M.copy (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + [ Ty.path "usize" ], + "index", + [] + |), + [ chunk_acc; Value.Integer 0 ] + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply (Ty.path "core::slice::iter::ChunksMut") [ F ]; + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ F; Ty.path "alloc::alloc::Global" ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply (Ty.path "core::slice::iter::ChunksMut") [ F ]; + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ F; Ty.path "alloc::alloc::Global" ] + ], + [], + "skip", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::ChunksMut") [ F ], + [], + "zip", + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ F; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "chunks_mut", + [] + |), + [ M.read (| f |); M.read (| chunk_size |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + [], + "into_iter", + [] + |), + [ M.read (| chunk_acc |) ] + |) + ] + |); + Value.Integer 1 + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::ChunksMut") + [ F ]; + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ F; Ty.path "alloc::alloc::Global" ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let chunk := M.copy (| γ1_0 |) in + let curr_acc := M.copy (| γ1_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply (Ty.path "rayon::slice::IterMut") [ F ], + [], + "for_each", + [ + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&mut") [ F ] ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelRefMutIterator", + Ty.apply (Ty.path "slice") [ F ], + [], + "par_iter_mut", + [] + |), + [ M.read (| chunk |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let p := M.copy (| γ |) in + M.read (| + let _ := + M.write (| + M.read (| p |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ F ], + "mul", + [] + |), + [ + M.read (| + M.read (| p |) + |); + M.read (| acc |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + F, + [ F ], + "mul_assign", + [] + |), + [ acc; M.read (| curr_acc |) ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + pub fn batch_invert(f: &mut [F]) { + parallelize(f, |start, _| { + start.batch_invert(); + }); + } + *) + Definition batch_invert (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ f ] => + ltac:(M.monadic + (let f := M.alloc (| f |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + F; + Ty.function + [ + Ty.tuple + [ + Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ F ] ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.read (| f |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let start := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::batch::BatchInvert", + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "slice") [ F ] ], + [ F ], + "batch_invert", + [] + |), + [ M.read (| start |) ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + (* + pub fn lagrange_interpolate(points: &[F], evals: &[F]) -> Vec { + assert_eq!(points.len(), evals.len()); + if points.len() == 1 { + // Constant polynomial + return vec![evals[0]]; + } else { + let mut denoms = Vec::with_capacity(points.len()); + for (j, x_j) in points.iter().enumerate() { + let mut denom = Vec::with_capacity(points.len() - 1); + for x_k in points + .iter() + .enumerate() + .filter(|&(k, _)| k != j) + .map(|a| a.1) + { + denom.push( *x_j - x_k); + } + denoms.push(denom); + } + + // Compute (x_j - x_k)^(-1) for each j != i + denoms.iter_mut().for_each(|v| batch_invert(v)); + + let mut final_poly = vec![F::zero(); points.len()]; + for (j, (denoms, eval)) in denoms.into_iter().zip(evals.iter()).enumerate() { + let mut tmp: Vec = Vec::with_capacity(points.len()); + let mut product = Vec::with_capacity(points.len() - 1); + tmp.push(F::one()); + for (x_k, denom) in points + .iter() + .enumerate() + .filter(|&(k, _)| k != j) + .map(|a| a.1) + .zip(denoms.into_iter()) + { + product.resize(tmp.len() + 1, F::zero()); + for ((a, b), product) in tmp + .iter() + .chain(std::iter::once(&F::zero())) + .zip(std::iter::once(&F::zero()).chain(tmp.iter())) + .zip(product.iter_mut()) + { + *product = *a * (-denom * x_k) + *b * denom; + } + std::mem::swap(&mut tmp, &mut product); + } + assert_eq!(tmp.len(), points.len()); + assert_eq!(product.len(), points.len() - 1); + for (final_coeff, interpolation_coeff) in final_poly.iter_mut().zip(tmp.into_iter()) { + *final_coeff += interpolation_coeff * eval; + } + } + final_poly + } + } + *) + Definition lagrange_interpolate (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ points; evals ] => + ltac:(M.monadic + (let points := M.alloc (| points |) in + let evals := M.alloc (| evals |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "len", + [] + |), + [ M.read (| points |) ] + |) + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "len", + [] + |), + [ M.read (| evals |) ] + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "len", + [] + |), + [ M.read (| points |) ] + |)) + (Value.Integer 1) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "array") [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.read (| + M.SubPointer.get_array_field (| + M.read (| evals |), + M.alloc (| Value.Integer 0 |) + |) + |) + ] + |) + ] + |) + |)) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let denoms := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + "with_capacity", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "len", + [] + |), + [ M.read (| points |) ] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ Ty.apply (Ty.path "core::slice::iter::Iter") [ F ] ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ F ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "iter", + [] + |), + [ M.read (| points |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ F ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let j := M.copy (| γ1_0 |) in + let x_j := M.copy (| γ1_1 |) in + let denom := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + "with_capacity", + [] + |), + [ + BinOp.Panic.sub (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "len", + [] + |), + [ M.read (| points |) ] + |), + Value.Integer 1 + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ F ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "&") [ F ]) + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ F ] + ] + ] + ] + ] + (Ty.path "bool") + ], + [], + "map", + [ + Ty.apply (Ty.path "&") [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "&") [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ] + ], + [], + "filter", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ F ] + ] + ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ F ], + "iter", + [] + |), + [ M.read (| points |) ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.read (| + γ + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let k := + M.copy (| + γ1_0 + |) in + BinOp.Pure.ne + (M.read (| + k + |)) + (M.read (| + j + |)))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := + M.copy (| γ |) in + M.read (| + M.SubPointer.get_tuple_field (| + a, + 1 + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ + F + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "&") + [ F ]) + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let x_k := + M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + denom; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + F, + [ + Ty.apply + (Ty.path + "&") + [ F ] + ], + "sub", + [] + |), + [ + M.read (| + M.read (| + x_j + |) + |); + M.read (| + x_k + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ denoms; M.read (| denom |) ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ] + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ] + ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ denoms ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let v := M.copy (| γ |) in + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::batch_invert", + [ F ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ M.read (| v |) ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let final_poly := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ F ] |), + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "zero", [] |), + [] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "len", + [] + |), + [ M.read (| points |) ] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply (Ty.path "core::slice::iter::Iter") [ F ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply (Ty.path "core::slice::iter::Iter") [ F ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "zip", + [ Ty.apply (Ty.path "core::slice::iter::Iter") [ F ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| denoms |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "iter", + [] + |), + [ M.read (| evals |) ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ F ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let j := M.copy (| γ1_0 |) in + let γ2_0 := + M.SubPointer.get_tuple_field (| γ1_1, 0 |) in + let γ2_1 := + M.SubPointer.get_tuple_field (| γ1_1, 1 |) in + let denoms := M.copy (| γ2_0 |) in + let eval := M.copy (| γ2_1 |) in + let tmp := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + "with_capacity", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "len", + [] + |), + [ M.read (| points |) ] + |) + ] + |) + |) in + let product := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + "with_capacity", + [] + |), + [ + BinOp.Panic.sub (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "len", + [] + |), + [ M.read (| points |) ] + |), + Value.Integer 1 + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + tmp; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ F ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "&") [ F ]) + ]; + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + F; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ F ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "&") [ F ]) + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + F; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ F ] + ] + ] + ] + ] + (Ty.path "bool") + ], + [], + "map", + [ + Ty.apply (Ty.path "&") [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "&") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ] + ], + [], + "filter", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ F ] + ] + ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ F ], + "iter", + [] + |), + [ M.read (| points |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.read (| + γ + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let k := + M.copy (| + γ1_0 + |) in + BinOp.Pure.ne + (M.read (| + k + |)) + (M.read (| + j + |)))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := + M.copy (| + γ + |) in + M.read (| + M.SubPointer.get_tuple_field (| + a, + 1 + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| denoms |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ + F + ] + ] + ] + ] + ] + (Ty.path + "bool") + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ F + ] + ] + ] + ] + (Ty.apply + (Ty.path "&") + [ F ]) + ]; + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + F; + Ty.path + "alloc::alloc::Global" + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let x_k := + M.copy (| γ1_0 |) in + let denom := + M.copy (| γ1_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + "resize", + [] + |), + [ + product; + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ tmp ] + |), + Value.Integer 1 + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + F + ]; + Ty.apply + (Ty.path + "core::iter::sources::once::Once") + [ + Ty.apply + (Ty.path + "&") + [ + F + ] + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::once::Once") + [ + Ty.apply + (Ty.path + "&") + [ + F + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + F + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ F ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + F + ]; + Ty.apply + (Ty.path + "core::iter::sources::once::Once") + [ + Ty.apply + (Ty.path + "&") + [ + F + ] + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::once::Once") + [ + Ty.apply + (Ty.path + "&") + [ + F + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + F + ] + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ F ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + F + ]; + Ty.apply + (Ty.path + "core::iter::sources::once::Once") + [ + Ty.apply + (Ty.path + "&") + [ + F + ] + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::once::Once") + [ + Ty.apply + (Ty.path + "&") + [ + F + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + F + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + F + ], + [], + "chain", + [ + Ty.apply + (Ty.path + "core::iter::sources::once::Once") + [ + Ty.apply + (Ty.path + "&") + [ + F + ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + F + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + tmp + ] + |) + ] + |); + M.call_closure (| + M.get_function (| + "core::iter::sources::once::once", + [ + Ty.apply + (Ty.path + "&") + [ + F + ] + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::sources::once::Once") + [ + Ty.apply + (Ty.path + "&") + [ + F + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + F + ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "core::iter::sources::once::once", + [ + Ty.apply + (Ty.path + "&") + [ + F + ] + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + F + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + tmp + ] + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ F + ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ + product + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + F + ]; + Ty.apply + (Ty.path + "core::iter::sources::once::Once") + [ + Ty.apply + (Ty.path + "&") + [ + F + ] + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::once::Once") + [ + Ty.apply + (Ty.path + "&") + [ + F + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + F + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + F + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + γ2_0 := + M.SubPointer.get_tuple_field (| + γ1_0, + 0 + |) in + let + γ2_1 := + M.SubPointer.get_tuple_field (| + γ1_0, + 1 + |) in + let + a := + M.copy (| + γ2_0 + |) in + let + b := + M.copy (| + γ2_1 + |) in + let + product := + M.copy (| + γ1_1 + |) in + let + _ := + M.write (| + M.read (| + product + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + F, + [ + F + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ + F + ], + "mul", + [] + |), + [ + M.read (| + M.read (| + a + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ + Ty.apply + (Ty.path + "&") + [ + F + ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Neg", + F, + [], + "neg", + [] + |), + [ + M.read (| + denom + |) + ] + |); + M.read (| + x_k + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ + F + ], + "mul", + [] + |), + [ + M.read (| + M.read (| + b + |) + |); + M.read (| + denom + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::mem::swap", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ tmp; product ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + F; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ tmp ] + |) + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "len", + [] + |), + [ M.read (| points |) ] + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| + M.read (| left_val |) + |)) + (M.read (| + M.read (| right_val |) + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ + Ty.path "usize"; + Ty.path "usize" + ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| + right_val + |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + F; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ product ] + |) + |); + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "len", + [] + |), + [ M.read (| points |) ] + |), + Value.Integer 1 + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| + M.read (| left_val |) + |)) + (M.read (| + M.read (| right_val |) + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ + Ty.path "usize"; + Ty.path "usize" + ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| + right_val + |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ F ]; + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ F; Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ F ], + [], + "zip", + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + F; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ final_poly ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + F; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| tmp |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ F ]; + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + F; + Ty.path + "alloc::alloc::Global" + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let final_coeff := + M.copy (| γ1_0 |) in + let interpolation_coeff := + M.copy (| γ1_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::AddAssign", + F, + [ F ], + "add_assign", + [] + |), + [ + M.read (| + final_coeff + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ + Ty.apply + (Ty.path + "&") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| + interpolation_coeff + |); + M.read (| + eval + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + final_poly)) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + pub(crate) fn evaluate_vanishing_polynomial(roots: &[F], z: F) -> F { + fn evaluate(roots: &[F], z: F) -> F { + roots.iter().fold(F::one(), |acc, point| (z - point) * acc) + } + let n = roots.len(); + let num_threads = multicore::current_num_threads(); + if n * 2 < num_threads { + evaluate(roots, z) + } else { + let chunk_size = (n + num_threads - 1) / num_threads; + let mut parts = vec![F::one(); num_threads]; + multicore::scope(|scope| { + for (out, roots) in parts.chunks_mut(1).zip(roots.chunks(chunk_size)) { + scope.spawn(move |_| out[0] = evaluate(roots, z)); + } + }); + parts.iter().fold(F::one(), |acc, part| acc * part) + } + } + *) + Definition evaluate_vanishing_polynomial (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ roots; z ] => + ltac:(M.monadic + (let roots := M.alloc (| roots |) in + let z := M.alloc (| z |) in + M.read (| + let n := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.apply (Ty.path "slice") [ F ], "len", [] |), + [ M.read (| roots |) ] + |) + |) in + let num_threads := + M.alloc (| + M.call_closure (| M.get_function (| "rayon_core::current_num_threads", [] |), [] |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (BinOp.Panic.mul (| Integer.Usize, M.read (| n |), Value.Integer 2 |)) + (M.read (| num_threads |)) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::evaluate_vanishing_polynomial.evaluate", + [] + |), + [ M.read (| roots |); M.read (| z |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let chunk_size := + M.alloc (| + BinOp.Panic.div (| + Integer.Usize, + BinOp.Panic.sub (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.read (| n |), + M.read (| num_threads |) + |), + Value.Integer 1 + |), + M.read (| num_threads |) + |) + |) in + let parts := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ F ] |), + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "one", [] |), + [] + |); + M.read (| num_threads |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "rayon_core::scope::scope", + [ + Ty.function + [ + Ty.tuple + [ Ty.apply (Ty.path "&") [ Ty.path "rayon_core::scope::Scope" ] ] + ] + (Ty.tuple []); + Ty.tuple [] + ] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let scope := M.copy (| γ |) in + M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::ChunksMut") + [ F ]; + Ty.apply + (Ty.path "core::slice::iter::Chunks") + [ F ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::ChunksMut") + [ F ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Chunks") + [ F ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "chunks_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + F; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ parts ] + |); + Value.Integer 1 + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "chunks", + [] + |), + [ + M.read (| roots |); + M.read (| chunk_size |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::ChunksMut") + [ F ]; + Ty.apply + (Ty.path + "core::slice::iter::Chunks") + [ F ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let out := M.copy (| γ1_0 |) in + let roots := + M.copy (| γ1_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "rayon_core::scope::Scope", + "spawn", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "rayon_core::scope::Scope" + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.read (| scope |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + M.write (| + M.SubPointer.get_array_field (| + M.read (| + out + |), + M.alloc (| + Value.Integer + 0 + |) + |), + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::evaluate_vanishing_polynomial.evaluate", + [] + |), + [ + M.read (| + roots + |); + M.read (| + z + |) + ] + |) + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ F ], + [], + "fold", + [ F; Ty.function [ Ty.tuple [ F; Ty.apply (Ty.path "&") [ F ] ] ] F ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ parts ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "one", [] |), + [] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let part := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ Ty.apply (Ty.path "&") [ F ] ], + "mul", + [] + |), + [ M.read (| acc |); M.read (| part |) ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Module evaluate_vanishing_polynomial. + (* + fn evaluate(roots: &[F], z: F) -> F { + roots.iter().fold(F::one(), |acc, point| (z - point) * acc) + } + *) + Definition evaluate (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ roots; z ] => + ltac:(M.monadic + (let roots := M.alloc (| roots |) in + let z := M.alloc (| z |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ F ], + [], + "fold", + [ F; Ty.function [ Ty.tuple [ F; Ty.apply (Ty.path "&") [ F ] ] ] F ] + |), + [ + M.call_closure (| + M.get_associated_function (| Ty.apply (Ty.path "slice") [ F ], "iter", [] |), + [ M.read (| roots |) ] + |); + M.call_closure (| M.get_trait_method (| "ff::Field", F, [], "one", [] |), [] |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let point := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ F ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + F, + [ Ty.apply (Ty.path "&") [ F ] ], + "sub", + [] + |), + [ M.read (| z |); M.read (| point |) ] + |); + M.read (| acc |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + | _, _ => M.impossible + end. + End evaluate_vanishing_polynomial. + + (* + pub fn best_fft_cpu_st(a: &mut [G], omega: G::Scalar, log_n: u32) { + fn bitreverse(mut n: usize, l: usize) -> usize { + let mut r = 0; + for _ in 0..l { + r = (r << 1) | (n & 1); + n >>= 1; + } + r + } + + let n = a.len(); + assert_eq!(n, 1 << log_n); + + for k in 0..n { + let rk = bitreverse(k, log_n as usize); + if k < rk { + a.swap(rk, k); + } + } + + // precompute twiddle factors + let twiddles: Vec<_> = (0..(n / 2)) + .scan(G::Scalar::one(), |w, _| { + let tw = *w; + *w *= ω + Some(tw) + }) + .collect(); + + let mut chunk = 2_usize; + let mut twiddle_chunk = n / 2; + for _ in 0..log_n { + a.chunks_mut(chunk).for_each(|coeffs| { + let (left, right) = coeffs.split_at_mut(chunk / 2); + + // case when twiddle factor is one + let (a, left) = left.split_at_mut(1); + let (b, right) = right.split_at_mut(1); + let t = b[0]; + b[0] = a[0]; + a[0].group_add(&t); + b[0].group_sub(&t); + + left.iter_mut() + .zip(right.iter_mut()) + .enumerate() + .for_each(|(i, (a, b))| { + let mut t = *b; + t.group_scale(&twiddles[(i + 1) * twiddle_chunk]); + *b = *a; + a.group_add(&t); + b.group_sub(&t); + }); + }); + chunk *= 2; + twiddle_chunk /= 2; + } + } + *) + Definition best_fft_cpu_st (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ G ], [ a; omega; log_n ] => + ltac:(M.monadic + (let a := M.alloc (| a |) in + let omega := M.alloc (| omega |) in + let log_n := M.alloc (| log_n |) in + M.read (| + let n := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.apply (Ty.path "slice") [ G ], "len", [] |), + [ M.read (| a |) ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ n; M.alloc (| BinOp.Panic.shl (| Value.Integer 1, M.read (| log_n |) |) |) ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| n |)) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let k := M.copy (| γ0_0 |) in + let rk := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::best_fft_cpu_st.bitreverse", + [] + |), + [ M.read (| k |); M.rust_cast (M.read (| log_n |)) ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt (M.read (| k |)) (M.read (| rk |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ G ], + "swap", + [] + |), + [ M.read (| a |); M.read (| rk |); M.read (| k |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let twiddles := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::scan::Scan") + [ + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ]; + Ty.associated; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&mut") [ Ty.associated ]; Ty.path "usize" ] + ] + (Ty.apply (Ty.path "core::option::Option") [ Ty.associated ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "scan", + [ + Ty.associated; + Ty.associated; + Ty.function + [ + Ty.tuple + [ Ty.apply (Ty.path "&mut") [ Ty.associated ]; Ty.path "usize" ] + ] + (Ty.apply (Ty.path "core::option::Option") [ Ty.associated ]) + ] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + BinOp.Panic.div (| Integer.Usize, M.read (| n |), Value.Integer 2 |)) + ]; + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "one", [] |), + [] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let w := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let tw := M.copy (| M.read (| w |) |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] + ], + "mul_assign", + [] + |), + [ M.read (| w |); omega ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ M.read (| tw |) ] + |) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let chunk := M.alloc (| Value.Integer 2 |) in + let twiddle_chunk := + M.alloc (| BinOp.Panic.div (| Integer.Usize, M.read (| n |), Value.Integer 2 |) |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| log_n |)) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::ChunksMut") [ G ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "slice") [ G ] ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ G ], + "chunks_mut", + [] + |), + [ M.read (| a |); M.read (| chunk |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let coeffs := M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ G ], + "split_at_mut", + [] + |), + [ + M.read (| coeffs |); + BinOp.Panic.div (| + Integer.Usize, + M.read (| chunk |), + Value.Integer 2 + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let left := M.copy (| γ0_0 |) in + let right := + M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ G ], + "split_at_mut", + [] + |), + [ + M.read (| left |); + Value.Integer 1 + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let a := + M.copy (| γ0_0 |) in + let left := + M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ G ], + "split_at_mut", + [] + |), + [ + M.read (| + right + |); + Value.Integer 1 + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let b := + M.copy (| + γ0_0 + |) in + let right := + M.copy (| + γ0_1 + |) in + let t := + M.copy (| + M.SubPointer.get_array_field (| + M.read (| + b + |), + M.alloc (| + Value.Integer + 0 + |) + |) + |) in + let _ := + M.write (| + M.SubPointer.get_array_field (| + M.read (| + b + |), + M.alloc (| + Value.Integer + 0 + |) + |), + M.read (| + M.SubPointer.get_array_field (| + M.read (| + a + |), + M.alloc (| + Value.Integer + 0 + |) + |) + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_add", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| + a + |), + M.alloc (| + Value.Integer + 0 + |) + |); + t + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_sub", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| + b + |), + M.alloc (| + Value.Integer + 0 + |) + |); + t + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + G + ]; + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + G + ] + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + G + ]; + Ty.apply + (Ty.path + "&mut") + [ + G + ] + ] + ] + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + G + ]; + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + G + ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + G + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + G + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + G + ], + "iter_mut", + [] + |), + [ + M.read (| + left + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + G + ], + "iter_mut", + [] + |), + [ + M.read (| + right + |) + ] + |) + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + i := + M.copy (| + γ0_0 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_1, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_1, + 1 + |) in + let + a := + M.copy (| + γ1_0 + |) in + let + b := + M.copy (| + γ1_1 + |) in + M.read (| + let + t := + M.copy (| + M.read (| + b + |) + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_scale", + [] + |), + [ + t; + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + twiddles; + BinOp.Panic.mul (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.read (| + i + |), + Value.Integer + 1 + |), + M.read (| + twiddle_chunk + |) + |) + ] + |) + ] + |) + |) in + let + _ := + M.write (| + M.read (| + b + |), + M.read (| + M.read (| + a + |) + |) + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_add", + [] + |), + [ + M.read (| + a + |); + t + ] + |) + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_sub", + [] + |), + [ + M.read (| + b + |); + t + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |))) + ] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + let β := chunk in + M.write (| + β, + BinOp.Panic.mul (| + Integer.Usize, + M.read (| β |), + Value.Integer 2 + |) + |) in + let _ := + let β := twiddle_chunk in + M.write (| + β, + BinOp.Panic.div (| + Integer.Usize, + M.read (| β |), + Value.Integer 2 + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + | _, _ => M.impossible + end. + + Module best_fft_cpu_st. + (* + fn bitreverse(mut n: usize, l: usize) -> usize { + let mut r = 0; + for _ in 0..l { + r = (r << 1) | (n & 1); + n >>= 1; + } + r + } + *) + Definition bitreverse (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ n; l ] => + ltac:(M.monadic + (let n := M.alloc (| n |) in + let l := M.alloc (| l |) in + M.read (| + let r := M.alloc (| Value.Integer 0 |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| l |)) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let _ := + M.write (| + r, + BinOp.Pure.bit_or + (BinOp.Panic.shl (| M.read (| r |), Value.Integer 1 |)) + (BinOp.Pure.bit_and (M.read (| n |)) (Value.Integer 1)) + |) in + let _ := + let β := n in + M.write (| + β, + BinOp.Panic.shr (| M.read (| β |), Value.Integer 1 |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + r + |))) + | _, _ => M.impossible + end. + End best_fft_cpu_st. +End arithmetic. diff --git a/CoqOfRust/halo2_proofs/circuit.v b/CoqOfRust/halo2_proofs/circuit.v new file mode 100644 index 000000000..a1feaa8b8 --- /dev/null +++ b/CoqOfRust/halo2_proofs/circuit.v @@ -0,0 +1,3465 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuit. + (* Trait *) + (* Empty module 'Chip' *) + + (* StructTuple + { + name := "RegionIndex"; + ty_params := []; + fields := [ Ty.path "usize" ]; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_circuit_RegionIndex. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::RegionIndex". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.read (| self |))) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_circuit_RegionIndex. + + Module Impl_core_marker_Copy_for_halo2_proofs_circuit_RegionIndex. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::RegionIndex". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_circuit_RegionIndex. + + Module Impl_core_fmt_Debug_for_halo2_proofs_circuit_RegionIndex. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::RegionIndex". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "RegionIndex" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::RegionIndex", + 0 + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_circuit_RegionIndex. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_circuit_RegionIndex. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::RegionIndex". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_circuit_RegionIndex. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_circuit_RegionIndex. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::RegionIndex". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::RegionIndex", + 0 + |) + |)) + (M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| other |), + "halo2_proofs::circuit::RegionIndex", + 0 + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_circuit_RegionIndex. + + Module Impl_core_convert_From_usize_for_halo2_proofs_circuit_RegionIndex. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::RegionIndex". + + (* + fn from(idx: usize) -> RegionIndex { + RegionIndex(idx) + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ idx ] => + ltac:(M.monadic + (let idx := M.alloc (| idx |) in + Value.StructTuple "halo2_proofs::circuit::RegionIndex" [ M.read (| idx |) ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) [ (* T *) Ty.path "usize" ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_usize_for_halo2_proofs_circuit_RegionIndex. + + Module Impl_core_ops_deref_Deref_for_halo2_proofs_circuit_RegionIndex. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::RegionIndex". + + (* type Target = usize; *) + Definition _Target : Ty.t := Ty.path "usize". + + (* + fn deref(&self) -> &Self::Target { + &self.0 + } + *) + Definition deref (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::RegionIndex", + 0 + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::ops::deref::Deref" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("Target", InstanceField.Ty _Target); ("deref", InstanceField.Method deref) ]. + End Impl_core_ops_deref_Deref_for_halo2_proofs_circuit_RegionIndex. + + (* StructTuple + { + name := "RegionStart"; + ty_params := []; + fields := [ Ty.path "usize" ]; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_circuit_RegionStart. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::RegionStart". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.read (| self |))) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_circuit_RegionStart. + + Module Impl_core_marker_Copy_for_halo2_proofs_circuit_RegionStart. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::RegionStart". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_circuit_RegionStart. + + Module Impl_core_fmt_Debug_for_halo2_proofs_circuit_RegionStart. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::RegionStart". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "RegionStart" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::RegionStart", + 0 + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_circuit_RegionStart. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_circuit_RegionStart. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::RegionStart". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_circuit_RegionStart. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_circuit_RegionStart. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::RegionStart". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::RegionStart", + 0 + |) + |)) + (M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| other |), + "halo2_proofs::circuit::RegionStart", + 0 + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_circuit_RegionStart. + + Module Impl_core_marker_StructuralEq_for_halo2_proofs_circuit_RegionStart. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::RegionStart". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralEq_for_halo2_proofs_circuit_RegionStart. + + Module Impl_core_cmp_Eq_for_halo2_proofs_circuit_RegionStart. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::RegionStart". + + (* Eq *) + Definition assert_receiver_is_total_eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Eq" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("assert_receiver_is_total_eq", InstanceField.Method assert_receiver_is_total_eq) ]. + End Impl_core_cmp_Eq_for_halo2_proofs_circuit_RegionStart. + + Module Impl_core_convert_From_usize_for_halo2_proofs_circuit_RegionStart. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::RegionStart". + + (* + fn from(idx: usize) -> RegionStart { + RegionStart(idx) + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ idx ] => + ltac:(M.monadic + (let idx := M.alloc (| idx |) in + Value.StructTuple "halo2_proofs::circuit::RegionStart" [ M.read (| idx |) ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) [ (* T *) Ty.path "usize" ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_usize_for_halo2_proofs_circuit_RegionStart. + + Module Impl_core_ops_deref_Deref_for_halo2_proofs_circuit_RegionStart. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::RegionStart". + + (* type Target = usize; *) + Definition _Target : Ty.t := Ty.path "usize". + + (* + fn deref(&self) -> &Self::Target { + &self.0 + } + *) + Definition deref (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::RegionStart", + 0 + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::ops::deref::Deref" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("Target", InstanceField.Ty _Target); ("deref", InstanceField.Method deref) ]. + End Impl_core_ops_deref_Deref_for_halo2_proofs_circuit_RegionStart. + + (* StructRecord + { + name := "Cell"; + ty_params := []; + fields := + [ + ("region_index", Ty.path "halo2_proofs::circuit::RegionIndex"); + ("row_offset", Ty.path "usize"); + ("column", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]) + ]; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_circuit_Cell. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::Cell". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + Value.DeclaredButUndefined, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.read (| self |))) ] + |))) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_circuit_Cell. + + Module Impl_core_marker_Copy_for_halo2_proofs_circuit_Cell. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::Cell". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_circuit_Cell. + + Module Impl_core_fmt_Debug_for_halo2_proofs_circuit_Cell. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::Cell". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Cell" |); + M.read (| Value.String "region_index" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::Cell", + "region_index" + |)); + M.read (| Value.String "row_offset" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::Cell", + "row_offset" + |)); + M.read (| Value.String "column" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::Cell", + "column" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_circuit_Cell. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_circuit_Cell. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::Cell". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_circuit_Cell. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_circuit_Cell. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::Cell". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + LogicalOp.and (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::circuit::RegionIndex", + [ Ty.path "halo2_proofs::circuit::RegionIndex" ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::Cell", + "region_index" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::circuit::Cell", + "region_index" + |) + ] + |), + ltac:(M.monadic + (BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::Cell", + "row_offset" + |) + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::circuit::Cell", + "row_offset" + |) + |)))) + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::Cell", + "column" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::circuit::Cell", + "column" + |) + ] + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_circuit_Cell. + + (* StructRecord + { + name := "AssignedCell"; + ty_params := [ "V"; "F" ]; + fields := + [ + ("value", Ty.apply (Ty.path "core::option::Option") [ V ]); + ("cell", Ty.path "halo2_proofs::circuit::Cell"); + ("_marker", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_V_where_core_clone_Clone_F_where_ff_Field_F_for_halo2_proofs_circuit_AssignedCell_V_F. + Definition Self (V F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ V; F ]. + + (* Clone *) + Definition clone (V F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self V F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::circuit::AssignedCell" + [ + ("value", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::option::Option") [ V ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::AssignedCell", + "value" + |) + ] + |)); + ("cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::circuit::Cell", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::AssignedCell", + "cell" + |) + ] + |)); + ("_marker", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::AssignedCell", + "_marker" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (V F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self V F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone V F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_V_where_core_clone_Clone_F_where_ff_Field_F_for_halo2_proofs_circuit_AssignedCell_V_F. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_V_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_circuit_AssignedCell_V_F. + Definition Self (V F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ V; F ]. + + (* Debug *) + Definition fmt (V F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self V F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AssignedCell" |); + M.read (| Value.String "value" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::AssignedCell", + "value" + |)); + M.read (| Value.String "cell" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::AssignedCell", + "cell" + |)); + M.read (| Value.String "_marker" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::AssignedCell", + "_marker" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (V F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self V F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt V F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_V_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_circuit_AssignedCell_V_F. + + Module Impl_halo2_proofs_circuit_AssignedCell_V_F. + Definition Self (V F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ V; F ]. + + (* + pub fn value(&self) -> Option<&V> { + self.value.as_ref() + } + *) + Definition value (V F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self V F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ V ], + "as_ref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::AssignedCell", + "value" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_value : + forall (V F : Ty.t), + M.IsAssociatedFunction (Self V F) "value" (value V F). + + (* + pub fn cell(&self) -> Cell { + self.cell + } + *) + Definition cell (V F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self V F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::AssignedCell", + "cell" + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_cell : + forall (V F : Ty.t), + M.IsAssociatedFunction (Self V F) "cell" (cell V F). + (* + pub fn value_field(&self) -> Option> { + self.value().map(|v| v.into()) + } + *) + Definition value_field (V F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self V F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.apply (Ty.path "&") [ V ] ], + "map", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ V ] ] ] + (Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ V; F ], + "value", + [] + |), + [ M.read (| self |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let v := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply (Ty.path "&") [ V ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ], + "into", + [] + |), + [ M.read (| v |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_value_field : + forall (V F : Ty.t), + M.IsAssociatedFunction (Self V F) "value_field" (value_field V F). + (* + pub fn copy_advice( + &self, + annotation: A, + region: &mut Region<'_, F>, + column: Column, + offset: usize, + ) -> Result + where + A: Fn() -> AR, + AR: Into, + { + let assigned_cell = region.assign_advice(annotation, column, offset, || { + self.value.clone().ok_or(Error::Synthesis) + })?; + region.constrain_equal(assigned_cell.cell(), self.cell())?; + + Ok(assigned_cell) + } + *) + Definition copy_advice (V F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self V F in + match τ, α with + | [ A; AR ], [ self; annotation; region; column; offset ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let annotation := M.alloc (| annotation |) in + let region := M.alloc (| region |) in + let column := M.alloc (| column |) in + let offset := M.alloc (| offset |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let assigned_cell := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ V; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ V; Ty.path "halo2_proofs::plonk::error::Error" ]); + V; + A; + AR + ] + |), + [ + M.read (| region |); + M.read (| annotation |); + M.read (| column |); + M.read (| offset |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ V ], + "ok_or", + [ Ty.path "halo2_proofs::plonk::error::Error" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "core::option::Option") + [ V ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::AssignedCell", + "value" + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::error::Error::Synthesis" + [] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ V; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "constrain_equal", + [] + |), + [ + M.read (| region |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ V; F ], + "cell", + [] + |), + [ assigned_cell ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ V; F ], + "cell", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ V; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ M.read (| assigned_cell |) ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_copy_advice : + forall (V F : Ty.t), + M.IsAssociatedFunction (Self V F) "copy_advice" (copy_advice V F). + End Impl_halo2_proofs_circuit_AssignedCell_V_F. + + + + (* StructRecord + { + name := "Region"; + ty_params := [ "F" ]; + fields := + [ + ("region", + Ty.apply + (Ty.path "&") + [ Ty.dyn [ ("halo2_proofs::circuit::layouter::RegionLayouter::Trait", []) ] ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_for_halo2_proofs_circuit_Region_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::circuit::Region" + [ + ("region", + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "&") + [ Ty.dyn [ ("halo2_proofs::circuit::layouter::RegionLayouter::Trait", []) ] + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::Region", + "region" + |) + ] + |))) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_for_halo2_proofs_circuit_Region_F. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_circuit_Region_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Region" |); + M.read (| Value.String "region" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::Region", + "region" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_circuit_Region_F. + + Module Impl_core_marker_Sync_where_ff_Field_F_for_halo2_proofs_circuit_Region_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Sync" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Sync_where_ff_Field_F_for_halo2_proofs_circuit_Region_F. + + Module Impl_core_marker_Send_where_ff_Field_F_for_halo2_proofs_circuit_Region_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Send" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Send_where_ff_Field_F_for_halo2_proofs_circuit_Region_F. + + Module Impl_core_convert_From_where_ff_Field_F_ref__Dyn_halo2_proofs_circuit_layouter_RegionLayouter_Trait_for_halo2_proofs_circuit_Region_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ]. + + (* + fn from(region: &'r dyn layouter::RegionLayouter) -> Self { + Region { region } + } + *) + Definition from (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ region ] => + ltac:(M.monadic + (let region := M.alloc (| region |) in + Value.StructRecord + "halo2_proofs::circuit::Region" + [ ("region", (* Unsize *) M.pointer_coercion (M.read (| region |))) ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::convert::From" + (Self F) + (* Trait polymorphic types *) + [ + (* T *) + Ty.apply + (Ty.path "&") + [ Ty.dyn [ ("halo2_proofs::circuit::layouter::RegionLayouter::Trait", []) ] ] + ] + (* Instance *) [ ("from", InstanceField.Method (from F)) ]. + End Impl_core_convert_From_where_ff_Field_F_ref__Dyn_halo2_proofs_circuit_layouter_RegionLayouter_Trait_for_halo2_proofs_circuit_Region_F. + + Module Impl_halo2_proofs_circuit_Region_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ]. + + (* + pub(crate) fn enable_selector( + &self, + annotation: A, + selector: &Selector, + offset: usize, + ) -> Result<(), Error> + where + A: Fn() -> AR, + AR: Into, + { + self.region + .enable_selector(&|| annotation().into(), selector, offset) + } + *) + Definition enable_selector (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ A; AR ], [ self; annotation; selector; offset ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let annotation := M.alloc (| annotation |) in + let selector := M.alloc (| selector |) in + let offset := M.alloc (| offset |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::layouter::RegionLayouter", + Ty.dyn [ ("halo2_proofs::circuit::layouter::RegionLayouter::Trait", []) ], + [ F ], + "enable_selector", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::Region", + "region" + |) + |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + AR, + [ Ty.path "alloc::string::String" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + A, + [ Ty.tuple [] ], + "call", + [] + |), + [ annotation; Value.Tuple [] ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)); + M.read (| selector |); + M.read (| offset |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_enable_selector : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "enable_selector" (enable_selector F). + + (* + pub fn assign_advice<'v, V, VR, A, AR>( + &'v self, + annotation: A, + column: Column, + offset: usize, + mut to: V, + ) -> Result, Error> + where + V: FnMut() -> Result + 'v, + for<'vr> Assigned: From<&'vr VR>, + A: Fn() -> AR, + AR: Into, + { + let mut value = None; + let cell = + self.region + .assign_advice(&|| annotation().into(), column, offset, &mut || { + let v = to()?; + let value_f = (&v).into(); + value = Some(v); + Ok(value_f) + })?; + + Ok(AssignedCell { + value, + cell, + _marker: PhantomData, + }) + } + *) + Definition assign_advice (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ V; VR; A; AR ], [ self; annotation; column; offset; to ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let annotation := M.alloc (| annotation |) in + let column := M.alloc (| column |) in + let offset := M.alloc (| offset |) in + let to := M.alloc (| to |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let value := M.alloc (| Value.StructTuple "core::option::Option::None" [] |) in + let cell := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::layouter::RegionLayouter", + Ty.dyn + [ ("halo2_proofs::circuit::layouter::RegionLayouter::Trait", []) + ], + [ F ], + "assign_advice", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::Region", + "region" + |) + |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + AR, + [ Ty.path "alloc::string::String" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + A, + [ Ty.tuple [] ], + "call", + [] + |), + [ annotation; Value.Tuple [] ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)); + M.read (| column |); + M.read (| offset |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let v := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + VR; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnMut", + V, + [ Ty.tuple [] ], + "call_mut", + [] + |), + [ to; Value.Tuple [] ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let value_f := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply (Ty.path "&") [ VR ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ], + "into", + [] + |), + [ v ] + |) + |) in + let _ := + M.write (| + value, + Value.StructTuple + "core::option::Option::Some" + [ M.read (| v |) ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ M.read (| value_f |) ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ VR; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::circuit::AssignedCell" + [ + ("value", M.read (| value |)); + ("cell", M.read (| cell |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_advice : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign_advice" (assign_advice F). + + (* + pub fn assign_advice_from_constant( + &self, + annotation: A, + column: Column, + offset: usize, + constant: VR, + ) -> Result, Error> + where + for<'vr> Assigned: From<&'vr VR>, + A: Fn() -> AR, + AR: Into, + { + let cell = self.region.assign_advice_from_constant( + &|| annotation().into(), + column, + offset, + (&constant).into(), + )?; + + Ok(AssignedCell { + value: Some(constant), + cell, + _marker: PhantomData, + }) + } + *) + Definition assign_advice_from_constant (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ VR; A; AR ], [ self; annotation; column; offset; constant ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let annotation := M.alloc (| annotation |) in + let column := M.alloc (| column |) in + let offset := M.alloc (| offset |) in + let constant := M.alloc (| constant |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let cell := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::layouter::RegionLayouter", + Ty.dyn + [ ("halo2_proofs::circuit::layouter::RegionLayouter::Trait", []) + ], + [ F ], + "assign_advice_from_constant", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::Region", + "region" + |) + |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + AR, + [ Ty.path "alloc::string::String" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + A, + [ Ty.tuple [] ], + "call", + [] + |), + [ annotation; Value.Tuple [] ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)); + M.read (| column |); + M.read (| offset |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply (Ty.path "&") [ VR ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ], + "into", + [] + |), + [ constant ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ VR; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::circuit::AssignedCell" + [ + ("value", + Value.StructTuple + "core::option::Option::Some" + [ M.read (| constant |) ]); + ("cell", M.read (| cell |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_advice_from_constant : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign_advice_from_constant" (assign_advice_from_constant F). + + (* + pub fn assign_advice_from_instance( + &mut self, + annotation: A, + instance: Column, + row: usize, + advice: Column, + offset: usize, + ) -> Result, Error> + where + A: Fn() -> AR, + AR: Into, + { + let (cell, value) = self.region.assign_advice_from_instance( + &|| annotation().into(), + instance, + row, + advice, + offset, + )?; + + Ok(AssignedCell { + value, + cell, + _marker: PhantomData, + }) + } + *) + Definition assign_advice_from_instance (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ A; AR ], [ self; annotation; instance; row; advice; offset ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let annotation := M.alloc (| annotation |) in + let instance := M.alloc (| instance |) in + let row := M.alloc (| row |) in + let advice := M.alloc (| advice |) in + let offset := M.alloc (| offset |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.apply (Ty.path "core::option::Option") [ F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::layouter::RegionLayouter", + Ty.dyn + [ ("halo2_proofs::circuit::layouter::RegionLayouter::Trait", []) ], + [ F ], + "assign_advice_from_instance", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::Region", + "region" + |) + |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + AR, + [ Ty.path "alloc::string::String" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + A, + [ Ty.tuple [] ], + "call", + [] + |), + [ annotation; Value.Tuple [] ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)); + M.read (| instance |); + M.read (| row |); + M.read (| advice |); + M.read (| offset |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let cell := M.copy (| γ0_0 |) in + let value := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::circuit::AssignedCell" + [ + ("value", M.read (| value |)); + ("cell", M.read (| cell |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ] + ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_advice_from_instance : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign_advice_from_instance" (assign_advice_from_instance F). + + (* + pub fn assign_fixed<'v, V, VR, A, AR>( + &'v self, + annotation: A, + column: Column, + offset: usize, + mut to: V, + ) -> Result, Error> + where + V: FnMut() -> Result + 'v, + for<'vr> Assigned: From<&'vr VR>, + A: Fn() -> AR, + AR: Into, + { + let mut value = None; + let cell = + self.region + .assign_fixed(&|| annotation().into(), column, offset, &mut || { + let v = to()?; + let value_f = (&v).into(); + value = Some(v); + Ok(value_f) + })?; + + Ok(AssignedCell { + value, + cell, + _marker: PhantomData, + }) + } + *) + Definition assign_fixed (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ V; VR; A; AR ], [ self; annotation; column; offset; to ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let annotation := M.alloc (| annotation |) in + let column := M.alloc (| column |) in + let offset := M.alloc (| offset |) in + let to := M.alloc (| to |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let value := M.alloc (| Value.StructTuple "core::option::Option::None" [] |) in + let cell := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::layouter::RegionLayouter", + Ty.dyn + [ ("halo2_proofs::circuit::layouter::RegionLayouter::Trait", []) + ], + [ F ], + "assign_fixed", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::Region", + "region" + |) + |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + AR, + [ Ty.path "alloc::string::String" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + A, + [ Ty.tuple [] ], + "call", + [] + |), + [ annotation; Value.Tuple [] ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)); + M.read (| column |); + M.read (| offset |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let v := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + VR; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnMut", + V, + [ Ty.tuple [] ], + "call_mut", + [] + |), + [ to; Value.Tuple [] ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let value_f := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply (Ty.path "&") [ VR ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ], + "into", + [] + |), + [ v ] + |) + |) in + let _ := + M.write (| + value, + Value.StructTuple + "core::option::Option::Some" + [ M.read (| v |) ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ M.read (| value_f |) ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ VR; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::circuit::AssignedCell" + [ + ("value", M.read (| value |)); + ("cell", M.read (| cell |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_fixed : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign_fixed" (assign_fixed F). + + (* + pub fn constrain_constant(&mut self, cell: Cell, constant: VR) -> Result<(), Error> + where + VR: Into>, + { + self.region.constrain_constant(cell, constant.into()) + } + *) + Definition constrain_constant (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ VR ], [ self; cell; constant ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let cell := M.alloc (| cell |) in + let constant := M.alloc (| constant |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::layouter::RegionLayouter", + Ty.dyn [ ("halo2_proofs::circuit::layouter::RegionLayouter::Trait", []) ], + [ F ], + "constrain_constant", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::Region", + "region" + |) + |); + M.read (| cell |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + VR, + [ Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ] ], + "into", + [] + |), + [ M.read (| constant |) ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_constrain_constant : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "constrain_constant" (constrain_constant F). + + (* + pub fn constrain_equal(&self, left: Cell, right: Cell) -> Result<(), Error> { + self.region.constrain_equal(left, right) + } + *) + Definition constrain_equal (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _ as left; _ as right ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let left := M.alloc (| left |) in + let right := M.alloc (| right |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::layouter::RegionLayouter", + Ty.dyn [ ("halo2_proofs::circuit::layouter::RegionLayouter::Trait", []) ], + [ F ], + "constrain_equal", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::Region", + "region" + |) + |); + M.read (| left |); + M.read (| right |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_constrain_equal : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "constrain_equal" (constrain_equal F). + End Impl_halo2_proofs_circuit_Region_F. + + (* StructRecord + { + name := "Table"; + ty_params := [ "F" ]; + fields := + [ + ("table", + Ty.apply + (Ty.path "&") + [ Ty.dyn [ ("halo2_proofs::circuit::layouter::TableLayouter::Trait", []) ] ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_circuit_Table_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::circuit::Table") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Table" |); + M.read (| Value.String "table" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::Table", + "table" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_circuit_Table_F. + + Module Impl_core_convert_From_where_ff_Field_F_ref__Dyn_halo2_proofs_circuit_layouter_TableLayouter_Trait_for_halo2_proofs_circuit_Table_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::circuit::Table") [ F ]. + + (* + fn from(table: &'r dyn layouter::TableLayouter) -> Self { + Table { table } + } + *) + Definition from (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ table ] => + ltac:(M.monadic + (let table := M.alloc (| table |) in + Value.StructRecord + "halo2_proofs::circuit::Table" + [ ("table", (* Unsize *) M.pointer_coercion (M.read (| table |))) ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::convert::From" + (Self F) + (* Trait polymorphic types *) + [ + (* T *) + Ty.apply + (Ty.path "&") + [ Ty.dyn [ ("halo2_proofs::circuit::layouter::TableLayouter::Trait", []) ] ] + ] + (* Instance *) [ ("from", InstanceField.Method (from F)) ]. + End Impl_core_convert_From_where_ff_Field_F_ref__Dyn_halo2_proofs_circuit_layouter_TableLayouter_Trait_for_halo2_proofs_circuit_Table_F. + + Module Impl_halo2_proofs_circuit_Table_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::circuit::Table") [ F ]. + + (* + pub fn assign_cell<'v, V, VR, A, AR>( + &'v self, + annotation: A, + column: TableColumn, + offset: usize, + mut to: V, + ) -> Result<(), Error> + where + V: FnMut() -> Result + 'v, + VR: Into>, + A: Fn() -> AR, + AR: Into, + { + self.table + .assign_cell(&|| annotation().into(), column, offset, &mut || { + to().map(|v| v.into()) + }) + } + *) + Definition assign_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ V; VR; A; AR ], [ self; annotation; column; offset; to ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let annotation := M.alloc (| annotation |) in + let column := M.alloc (| column |) in + let offset := M.alloc (| offset |) in + let to := M.alloc (| to |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::layouter::TableLayouter", + Ty.dyn [ ("halo2_proofs::circuit::layouter::TableLayouter::Trait", []) ], + [ F ], + "assign_cell", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::Table", + "table" + |) + |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + AR, + [ Ty.path "alloc::string::String" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + A, + [ Ty.tuple [] ], + "call", + [] + |), + [ annotation; Value.Tuple [] ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)); + M.read (| column |); + M.read (| offset |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ VR; Ty.path "halo2_proofs::plonk::error::Error" ], + "map", + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.function + [ Ty.tuple [ VR ] ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnMut", + V, + [ Ty.tuple [] ], + "call_mut", + [] + |), + [ to; Value.Tuple [] ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let v := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + VR, + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ], + "into", + [] + |), + [ M.read (| v |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_cell : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign_cell" (assign_cell F). + End Impl_halo2_proofs_circuit_Table_F. + + (* Trait *) + Module Layouter. + Definition namespace (F Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ NR; N ], [ self; name_fn ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name_fn := M.alloc (| name_fn |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::Layouter", + Ty.associated, + [ F ], + "push_namespace", + [ NR; N ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::Layouter", + Self, + [ F ], + "get_root", + [] + |), + [ M.read (| self |) ] + |); + M.read (| name_fn |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::circuit::NamespacedLayouter" + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::Layouter", + Self, + [ F ], + "get_root", + [] + |), + [ M.read (| self |) ] + |); + Value.StructTuple "core::marker::PhantomData" [] + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_namespace : + forall (F : Ty.t), + M.IsProvidedMethod "halo2_proofs::circuit::Layouter" "namespace" (namespace F). + End Layouter. + + (* StructTuple + { + name := "NamespacedLayouter"; + ty_params := [ "F"; "L" ]; + fields := + [ Ty.apply (Ty.path "&") [ L ]; Ty.apply (Ty.path "core::marker::PhantomData") [ F ] ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_where_core_clone_Clone_L_where_halo2_proofs_circuit_Layouter_L_F_for_halo2_proofs_circuit_NamespacedLayouter_F_L. + Definition Self (F L : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::NamespacedLayouter") [ F; L ]. + + (* Clone *) + Definition clone (F L : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F L in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructTuple + "halo2_proofs::circuit::NamespacedLayouter" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "&") [ L ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::NamespacedLayouter", + 0 + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::NamespacedLayouter", + 1 + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F L : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F L) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F L)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_where_core_clone_Clone_L_where_halo2_proofs_circuit_Layouter_L_F_for_halo2_proofs_circuit_NamespacedLayouter_F_L. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_where_core_fmt_Debug_L_where_halo2_proofs_circuit_Layouter_L_F_for_halo2_proofs_circuit_NamespacedLayouter_F_L. + Definition Self (F L : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::NamespacedLayouter") [ F; L ]. + + (* Debug *) + Definition fmt (F L : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F L in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "NamespacedLayouter" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::NamespacedLayouter", + 0 + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::NamespacedLayouter", + 1 + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F L : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F L) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F L)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_where_core_fmt_Debug_L_where_halo2_proofs_circuit_Layouter_L_F_for_halo2_proofs_circuit_NamespacedLayouter_F_L. + + Module Impl_core_marker_Send_where_ff_Field_F_where_halo2_proofs_circuit_Layouter_L_F_for_halo2_proofs_circuit_NamespacedLayouter_F_L. + Definition Self (F L : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::NamespacedLayouter") [ F; L ]. + + Axiom Implements : + forall (F L : Ty.t), + M.IsTraitInstance + "core::marker::Send" + (Self F L) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Send_where_ff_Field_F_where_halo2_proofs_circuit_Layouter_L_F_for_halo2_proofs_circuit_NamespacedLayouter_F_L. + + Module Impl_halo2_proofs_circuit_Layouter_where_ff_Field_F_where_halo2_proofs_circuit_Layouter_L_F_F_for_halo2_proofs_circuit_NamespacedLayouter_F_L. + Definition Self (F L : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::NamespacedLayouter") [ F; L ]. + + (* type Root = L::Root; *) + Definition _Root (F L : Ty.t) : Ty.t := Ty.associated. + + (* + fn assign_region(&self, name: N, assignment: A) -> Result + where + A: Fn(&Region<'_, F>) -> Result, + N: Fn() -> NR, + NR: Into, + { + self.0.assign_region(name, assignment) + } + *) + Definition assign_region (F L : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F L in + match τ, α with + | [ A; AR; N; NR ], [ self; name; assignment ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + let assignment := M.alloc (| assignment |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::Layouter", + L, + [ F ], + "assign_region", + [ A; AR; N; NR ] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::NamespacedLayouter", + 0 + |) + |); + M.read (| name |); + M.read (| assignment |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign_table(&self, name: N, assignment: A) -> Result<(), Error> + where + A: Fn(Table<'_, F>) -> Result<(), Error>, + N: Fn() -> NR, + NR: Into, + { + self.0.assign_table(name, assignment) + } + *) + Definition assign_table (F L : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F L in + match τ, α with + | [ A; N; NR ], [ self; name; assignment ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + let assignment := M.alloc (| assignment |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::Layouter", + L, + [ F ], + "assign_table", + [ A; N; NR ] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::NamespacedLayouter", + 0 + |) + |); + M.read (| name |); + M.read (| assignment |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn constrain_instance( + &self, + cell: Cell, + column: Column, + row: usize, + ) -> Result<(), Error> { + self.0.constrain_instance(cell, column, row) + } + *) + Definition constrain_instance (F L : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F L in + match τ, α with + | [], [ self; cell; column; row ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let cell := M.alloc (| cell |) in + let column := M.alloc (| column |) in + let row := M.alloc (| row |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::Layouter", + L, + [ F ], + "constrain_instance", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::NamespacedLayouter", + 0 + |) + |); + M.read (| cell |); + M.read (| column |); + M.read (| row |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn get_root(&self) -> &Self::Root { + self.0.get_root() + } + *) + Definition get_root (F L : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F L in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| "halo2_proofs::circuit::Layouter", L, [ F ], "get_root", [] |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::NamespacedLayouter", + 0 + |) + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn push_namespace(&self, _name_fn: N) + where + NR: Into, + N: FnOnce() -> NR, + { + panic!("Only the root's push_namespace should be called"); + } + *) + Definition push_namespace (F L : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F L in + match τ, α with + | [ NR; N ], [ self; _name_fn ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _name_fn := M.alloc (| _name_fn |) in + M.never_to_any (| + M.call_closure (| + M.get_function (| + "std::panicking::begin_panic", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ M.read (| Value.String "Only the root's push_namespace should be called" |) ] + |) + |))) + | _, _ => M.impossible + end. + + (* + fn pop_namespace(&self, _gadget_name: Option) { + panic!("Only the root's pop_namespace should be called"); + } + *) + Definition pop_namespace (F L : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F L in + match τ, α with + | [], [ self; _gadget_name ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _gadget_name := M.alloc (| _gadget_name |) in + M.never_to_any (| + M.call_closure (| + M.get_function (| + "std::panicking::begin_panic", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ M.read (| Value.String "Only the root's pop_namespace should be called" |) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F L : Ty.t), + M.IsTraitInstance + "halo2_proofs::circuit::Layouter" + (Self F L) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("Root", InstanceField.Ty (_Root F L)); + ("assign_region", InstanceField.Method (assign_region F L)); + ("assign_table", InstanceField.Method (assign_table F L)); + ("constrain_instance", InstanceField.Method (constrain_instance F L)); + ("get_root", InstanceField.Method (get_root F L)); + ("push_namespace", InstanceField.Method (push_namespace F L)); + ("pop_namespace", InstanceField.Method (pop_namespace F L)) + ]. + End Impl_halo2_proofs_circuit_Layouter_where_ff_Field_F_where_halo2_proofs_circuit_Layouter_L_F_F_for_halo2_proofs_circuit_NamespacedLayouter_F_L. + + Module Impl_core_ops_drop_Drop_where_ff_Field_F_where_halo2_proofs_circuit_Layouter_L_F_for_halo2_proofs_circuit_NamespacedLayouter_F_L. + Definition Self (F L : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::NamespacedLayouter") [ F; L ]. + + (* + fn drop(&mut self) { + let gadget_name = { + #[cfg(feature = "gadget-traces")] + { + let mut gadget_name = None; + let mut is_second_frame = false; + backtrace::trace(|frame| { + if is_second_frame { + // Resolve this instruction pointer to a symbol name. + backtrace::resolve_frame(frame, |symbol| { + gadget_name = symbol.name().map(|name| format!("{:#}", name)); + }); + + // We are done! + false + } else { + // We want the next frame. + is_second_frame = true; + true + } + }); + gadget_name + } + + #[cfg(not(feature = "gadget-traces"))] + None + }; + + self.get_root().pop_namespace(gadget_name); + } + *) + Definition drop (F L : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F L in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let gadget_name := M.alloc (| Value.StructTuple "core::option::Option::None" [] |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::Layouter", + Ty.associated, + [ F ], + "pop_namespace", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::Layouter", + Ty.apply (Ty.path "halo2_proofs::circuit::NamespacedLayouter") [ F; L ], + [ F ], + "get_root", + [] + |), + [ M.read (| self |) ] + |); + M.read (| gadget_name |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F L : Ty.t), + M.IsTraitInstance + "core::ops::drop::Drop" + (Self F L) + (* Trait polymorphic types *) [] + (* Instance *) [ ("drop", InstanceField.Method (drop F L)) ]. + End Impl_core_ops_drop_Drop_where_ff_Field_F_where_halo2_proofs_circuit_Layouter_L_F_for_halo2_proofs_circuit_NamespacedLayouter_F_L. +End circuit. diff --git a/CoqOfRust/halo2_proofs/circuit/floor_planner/flat.v b/CoqOfRust/halo2_proofs/circuit/floor_planner/flat.v new file mode 100644 index 000000000..e376a6bbf --- /dev/null +++ b/CoqOfRust/halo2_proofs/circuit/floor_planner/flat.v @@ -0,0 +1,6410 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuit. + Module floor_planner. + Module flat. + (* StructTuple + { + name := "FlatFloorPlanner"; + ty_params := []; + fields := []; + } *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_circuit_floor_planner_flat_FlatFloorPlanner. + Definition Self : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::flat::FlatFloorPlanner". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ M.read (| f |); M.read (| Value.String "FlatFloorPlanner" |) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_circuit_floor_planner_flat_FlatFloorPlanner. + + Module Impl_halo2_proofs_plonk_circuit_FloorPlanner_for_halo2_proofs_circuit_floor_planner_flat_FlatFloorPlanner. + Definition Self : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::flat::FlatFloorPlanner". + + (* + fn synthesize, C: Circuit>( + cs: &CS, + circuit: &C, + config: C::Config, + constants: Vec>, + ) -> Result<(), Error> { + if !cs.is_in_prove_mode() { + let layouter = FlatShapeLayouter::new(cs)?; + circuit + .without_witnesses() + .synthesize(config.clone(), layouter.clone())?; + + let mut constants_to_assign = Arc::try_unwrap(layouter.dynamic) + .unwrap() + .into_inner() + .unwrap() + .constants_to_assign; + + constants_to_assign.sort_by(|(_, cell_a), (_, cell_b)| { + if cell_a.column != cell_b.column { + cell_a.column.cmp(&cell_b.column) + } else { + cell_a.row_offset.cmp(&cell_b.row_offset) + } + }); + + // Assign constants. For the simple floor planner, we assign constants in order in + // the first `constants` column. + // we assume the first constants starts at zero if constants_to_assign is not empty + if constants.is_empty() { + if !constants_to_assign.is_empty() { + return Err(Error::NotEnoughColumnsForConstants); + } else { + Ok::<(), Error>(()) + } + } else { + let constants_column = constants[0]; + let mut next_constant_row = 0; + for (constant, advice) in constants_to_assign { + cs.assign_fixed( + || format!("Constant({:?})", constant.evaluate()), + constants_column.clone(), + next_constant_row, + || Ok(constant), + )?; + cs.copy( + constants_column.into(), + next_constant_row, + advice.column, + advice.row_offset, + )?; + next_constant_row += 1; + } + Ok(()) + }?; + } + + let layouter = FlatChipLayouter::new(cs)?; + circuit.synthesize(config, layouter)?; + Ok(()) + } + *) + Definition synthesize (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F; CS; C ], [ cs; circuit; config; constants ] => + ltac:(M.monadic + (let cs := M.alloc (| cs |) in + let circuit := M.alloc (| circuit |) in + let config := M.alloc (| config |) in + let constants := M.alloc (| constants |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "is_in_prove_mode", + [] + |), + [ M.read (| cs |) ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let layouter := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter") + [ F; CS ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter") + [ F; CS ], + "new", + [] + |), + [ M.read (| cs |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Circuit", + C, + [ F ], + "synthesize", + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter") + [ F; CS ] + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Circuit", + C, + [ F ], + "without_witnesses", + [] + |), + [ M.read (| circuit |) ] + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.associated, + [], + "clone", + [] + |), + [ config ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter") + [ F; CS ], + [], + "clone", + [] + |), + [ layouter ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let constants_to_assign := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ], + "into_inner", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ]; + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "try_unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + layouter, + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter", + "dynamic" + |) + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic", + "constants_to_assign" + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ] + ], + "sort_by", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ] + ] + ] + ] + (Ty.path "core::cmp::Ordering") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ constants_to_assign ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let cell_a := M.alloc (| γ1_1 |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let cell_b := M.alloc (| γ1_1 |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "ne", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + cell_a + |), + "halo2_proofs::circuit::Cell", + "column" + |); + M.SubPointer.get_struct_record_field (| + M.read (| + cell_b + |), + "halo2_proofs::circuit::Cell", + "column" + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + [], + "cmp", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| cell_a |), + "halo2_proofs::circuit::Cell", + "column" + |); + M.SubPointer.get_struct_record_field (| + M.read (| cell_b |), + "halo2_proofs::circuit::Cell", + "column" + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path "usize", + [], + "cmp", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| cell_a |), + "halo2_proofs::circuit::Cell", + "row_offset" + |); + M.SubPointer.get_struct_record_field (| + M.read (| cell_b |), + "halo2_proofs::circuit::Cell", + "row_offset" + |) + ] + |) + |))) + ] + |) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "alloc::alloc::Global" + ], + "is_empty", + [] + |), + [ constants ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path + "halo2_proofs::circuit::Cell" + ]; + Ty.path + "alloc::alloc::Global" + ], + "is_empty", + [] + |), + [ constants_to_assign ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "halo2_proofs::plonk::error::Error::NotEnoughColumnsForConstants" + [] + ] + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ] + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let constants_column := + M.copy (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ constants; Value.Integer 0 ] + |) + |) in + let next_constant_row := + M.alloc (| Value.Integer 0 |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path + "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| constants_to_assign |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path + "halo2_proofs::circuit::Cell" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let constant := + M.copy (| γ1_0 |) in + let advice := + M.copy (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "assign_fixed", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ + F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.path + "alloc::string::String"); + Ty.path + "alloc::string::String" + ] + |), + [ + M.read (| + cs + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "Constant(" + |); + M.read (| + Value.String + ")" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_debug", + [ + F + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ + F + ], + "evaluate", + [] + |), + [ + M.read (| + constant + |) + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ], + [], + "clone", + [] + |), + [ + constants_column + ] + |); + M.read (| + next_constant_row + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.read (| + constant + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "copy", + [] + |), + [ + M.read (| + cs + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "into", + [] + |), + [ + M.read (| + constants_column + |) + ] + |); + M.read (| + next_constant_row + |); + M.read (| + M.SubPointer.get_struct_record_field (| + advice, + "halo2_proofs::circuit::Cell", + "column" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + advice, + "halo2_proofs::circuit::Cell", + "row_offset" + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let _ := + let β := + next_constant_row in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ] + |))) + ] + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let layouter := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouter") + [ F; CS ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouter") + [ F; CS ], + "new", + [] + |), + [ M.read (| cs |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Circuit", + C, + [ F ], + "synthesize", + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouter") + [ F; CS ] + ] + |), + [ M.read (| circuit |); M.read (| config |); M.read (| layouter |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "halo2_proofs::plonk::circuit::FloorPlanner" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("synthesize", InstanceField.Method synthesize) ]. + End Impl_halo2_proofs_plonk_circuit_FloorPlanner_for_halo2_proofs_circuit_floor_planner_flat_FlatFloorPlanner. + + (* StructRecord + { + name := "FlatShapeDynamic"; + ty_params := [ "F" ]; + fields := + [ + ("constants_to_assign", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ]); + ("nb_regions", Ty.path "usize"); + ("table_columns", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.path "alloc::alloc::Global" + ]); + ("_marker", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_circuit_floor_planner_flat_FlatShapeDynamic_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field4_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "FlatShapeDynamic" |); + M.read (| Value.String "constants_to_assign" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic", + "constants_to_assign" + |)); + M.read (| Value.String "nb_regions" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic", + "nb_regions" + |)); + M.read (| Value.String "table_columns" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic", + "table_columns" + |)); + M.read (| Value.String "_marker" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic", + "_marker" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_circuit_floor_planner_flat_FlatShapeDynamic_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_for_halo2_proofs_circuit_floor_planner_flat_FlatShapeDynamic_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic" + [ + ("constants_to_assign", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic", + "constants_to_assign" + |) + ] + |)); + ("nb_regions", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "usize", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic", + "nb_regions" + |) + ] + |)); + ("table_columns", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic", + "table_columns" + |) + ] + |)); + ("_marker", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic", + "_marker" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_for_halo2_proofs_circuit_floor_planner_flat_FlatShapeDynamic_F. + + (* StructRecord + { + name := "FlatShapeLayouter"; + ty_params := [ "F"; "CS" ]; + fields := + [ + ("cs", Ty.apply (Ty.path "&") [ CS ]); + ("dynamic", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_where_core_clone_Clone_CS_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_flat_FlatShapeLayouter_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter") + [ F; CS ]. + + (* Clone *) + Definition clone (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter" + [ + ("cs", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "&") [ CS ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter", + "cs" + |) + ] + |)); + ("dynamic", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter", + "dynamic" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F CS) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F CS)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_where_core_clone_Clone_CS_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_flat_FlatShapeLayouter_F_CS. + + Module Impl_core_marker_Send_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_flat_FlatShapeLayouter_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter") + [ F; CS ]. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "core::marker::Send" + (Self F CS) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Send_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_flat_FlatShapeLayouter_F_CS. + + Module Impl_core_fmt_Debug_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_flat_FlatShapeLayouter_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter") + [ F; CS ]. + + (* + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let dynamic = self.dynamic.lock().unwrap(); + f.debug_struct("FlatChipLayouter") + .field("nb_regions", &dynamic.nb_regions) + .finish() + } + *) + Definition fmt (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let dynamic := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter", + "dynamic" + |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::builders::DebugStruct", + "finish", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::builders::DebugStruct", + "field", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct", + [] + |), + [ M.read (| f |); M.read (| Value.String "FlatChipLayouter" |) ] + |) + |); + M.read (| Value.String "nb_regions" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ], + [], + "deref", + [] + |), + [ dynamic ] + |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic", + "nb_regions" + |)) + ] + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F CS) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F CS)) ]. + End Impl_core_fmt_Debug_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_flat_FlatShapeLayouter_F_CS. + + Module Impl_halo2_proofs_circuit_floor_planner_flat_FlatShapeLayouter_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter") + [ F; CS ]. + + (* + pub fn new(cs: &'a CS) -> Result { + let ret = FlatShapeLayouter { + cs, + dynamic: Arc::new(Mutex::new(FlatShapeDynamic { + nb_regions: 0, + table_columns: vec![], + constants_to_assign: vec![], + _marker: PhantomData, + })), + }; + Ok(ret) + } + *) + Definition new (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ cs ] => + ltac:(M.monadic + (let cs := M.alloc (| cs |) in + M.read (| + let ret := + M.alloc (| + Value.StructRecord + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter" + [ + ("cs", M.read (| cs |)); + ("dynamic", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ], + "new", + [] + |), + [ + Value.StructRecord + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic" + [ + ("nb_regions", Value.Integer 0); + ("table_columns", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("constants_to_assign", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ] + ] + |) + ] + |)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| ret |) ] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F CS : Ty.t), + M.IsAssociatedFunction (Self F CS) "new" (new F CS). + End Impl_halo2_proofs_circuit_floor_planner_flat_FlatShapeLayouter_F_CS. + + Module Impl_halo2_proofs_circuit_Layouter_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_F_for_halo2_proofs_circuit_floor_planner_flat_FlatShapeLayouter_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter") + [ F; CS ]. + + (* type Root = Self; *) + Definition _Root (F CS : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter") + [ F; CS ]. + + (* + fn assign_region(&self, name: N, assignment: A) -> Result + where + A: Fn(&Region) -> Result, + N: Fn() -> NR, + NR: Into, + { + let mut dynamic = self.dynamic.lock().unwrap(); + let region_index = dynamic.nb_regions; + dynamic.nb_regions += 1; + drop(dynamic); + + let name = name().into(); + + self.cs.enter_region(|| name.clone()); + + // Get shape of the region. + let shape = region::RegionSetup::new(region_index.into()); + let shared_region = Parallel::new(shape); + + let region: &dyn RegionLayouter = &shared_region; + let result = assignment(®ion.into())?; + self.cs.exit_region(); + + let mut shape = shared_region.into_inner(); + + let mut dynamic = self.dynamic.lock().unwrap(); + dynamic.constants_to_assign.append(&mut shape.constants); + + Ok(result) + } + *) + Definition assign_region (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [ A; AR; N; NR ], [ self; name; assignment ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + let assignment := M.alloc (| assignment |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let dynamic := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter", + "dynamic" + |) + ] + |) + ] + |) + ] + |) + |) in + let region_index := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ], + [], + "deref", + [] + |), + [ dynamic ] + |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic", + "nb_regions" + |) + |) in + let _ := + let β := + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ dynamic ] + |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic", + "nb_regions" + |) in + M.write (| + β, + BinOp.Panic.add (| Integer.Usize, M.read (| β |), Value.Integer 1 |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::mem::drop", + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ] + ] + |), + [ M.read (| dynamic |) ] + |) + |) in + let name := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + NR, + [ Ty.path "alloc::string::String" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + N, + [ Ty.tuple [] ], + "call", + [] + |), + [ name; Value.Tuple [] ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "enter_region", + [ + Ty.path "alloc::string::String"; + Ty.function [ Ty.tuple [] ] (Ty.path "alloc::string::String") + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter", + "cs" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "alloc::string::String", + [], + "clone", + [] + |), + [ name ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let shape := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ], + "new", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "usize", + [ Ty.path "halo2_proofs::circuit::RegionIndex" ], + "into", + [] + |), + [ M.read (| region_index |) ] + |) + ] + |) + |) in + let shared_region := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + "new", + [] + |), + [ M.read (| shape |) ] + |) + |) in + let region := M.alloc (| (* Unsize *) M.pointer_coercion shared_region |) in + let result := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ AR; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + A, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::Region") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + assignment; + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("halo2_proofs::circuit::layouter::RegionLayouter::Trait", + []) + ] + ], + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::Region") + [ F ] + ], + "into", + [] + |), + [ M.read (| region |) ] + |) + |) + ] + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ AR; Ty.path "halo2_proofs::plonk::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "exit_region", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter", + "cs" + |) + |) + ] + |) + |) in + let shape := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + "into_inner", + [] + |), + [ M.read (| shared_region |) ] + |) + |) in + let dynamic := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter", + "dynamic" + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ], + "append", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ dynamic ] + |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic", + "constants_to_assign" + |); + M.SubPointer.get_struct_record_field (| + shape, + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "constants" + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ M.read (| result |) ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn assign_table(&self, name: N, assignment: A) -> Result<(), Error> + where + A: Fn(Table) -> Result<(), Error>, + N: Fn() -> NR, + NR: Into, + { + // Maintenance hazard: there is near-duplicate code in `v1::AssignmentPass::assign_table`. + // Assign table cells. + let name = name().into(); + + let mut dynamic = self.dynamic.lock().unwrap(); + self.cs.enter_region(|| name.clone()); + let table = SimpleTableLayouter::new(self.cs, &dynamic.table_columns); + { + let table: &dyn TableLayouter = &table; + assignment(table.into()) + }?; + + let default_and_assigned = table.default_and_assigned.lock().unwrap().clone(); + self.cs.exit_region(); + + // Check that all table columns have the same length `first_unused`, + // and all cells up to that length are assigned. + let first_unused = { + match default_and_assigned + .values() + .map(|(_, assigned)| { + if assigned.iter().all(|b| *b) { + Some(assigned.len()) + } else { + None + } + }) + .reduce(|acc, item| match (acc, item) { + (Some(a), Some(b)) if a == b => Some(a), + _ => None, + }) { + Some(Some(len)) => len, + _ => return Err(Error::Synthesis), // TODO better error + } + }; + + // Record these columns so that we can prevent them from being used again. + for column in default_and_assigned.keys() { + dynamic.table_columns.push( *column); + } + + for (col, (default_val, _)) in default_and_assigned.iter() { + // default_val must be Some because we must have assigned + // at least one cell in each column, and in that case we checked + // that all cells up to first_unused were assigned. + self.cs + .fill_from_row(col.inner(), first_unused, default_val.unwrap())?; + } + + Ok(()) + } + *) + Definition assign_table (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [ A; N; NR ], [ self; name; assignment ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + let assignment := M.alloc (| assignment |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let name := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + NR, + [ Ty.path "alloc::string::String" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + N, + [ Ty.tuple [] ], + "call", + [] + |), + [ name; Value.Tuple [] ] + |) + ] + |) + |) in + let dynamic := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter", + "dynamic" + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "enter_region", + [ + Ty.path "alloc::string::String"; + Ty.function [ Ty.tuple [] ] (Ty.path "alloc::string::String") + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter", + "cs" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "alloc::string::String", + [], + "clone", + [] + |), + [ name ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let table := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::single_pass::SimpleTableLayouter") + [ F; CS ], + "new", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter", + "cs" + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ], + [], + "deref", + [] + |), + [ dynamic ] + |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic", + "table_columns" + |) + ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.read (| + let table := M.alloc (| (* Unsize *) M.pointer_coercion table |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + A, + [ + Ty.tuple + [ Ty.apply (Ty.path "halo2_proofs::circuit::Table") [ F ] + ] + ], + "call", + [] + |), + [ + assignment; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("halo2_proofs::circuit::layouter::TableLayouter::Trait", + []) + ] + ], + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::Table") + [ F ] + ], + "into", + [] + |), + [ M.read (| table |) ] + |) + ] + ] + |) + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let default_and_assigned := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "std::hash::random::RandomState" + ], + [], + "clone", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "std::hash::random::RandomState" + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path + "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "std::hash::random::RandomState" + ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path + "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "std::hash::random::RandomState" + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path + "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "std::hash::random::RandomState" + ] + ], + "lock", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + table, + "halo2_proofs::circuit::floor_planner::single_pass::SimpleTableLayouter", + "default_and_assigned" + |) + ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "exit_region", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter", + "cs" + |) + |) + ] + |) + |) in + let first_unused := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "std::collections::hash::map::Values") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "usize" ]) + ], + [], + "reduce", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "usize" ] + ] + ] + (Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "std::collections::hash::map::Values") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ] + ], + [], + "map", + [ + Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "usize" ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "std::hash::random::RandomState" + ], + "values", + [] + |), + [ default_and_assigned ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let assigned := M.alloc (| γ1_1 |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.path "bool" ], + [], + "all", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "bool" + ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "bool" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "bool"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + assigned + |) + ] + |) + ] + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let b := + M.copy (| + γ + |) in + M.read (| + M.read (| + b + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| assigned |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let item := M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.read (| acc |); + M.read (| item |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "core::option::Option::Some", + 0 + |) in + let a := M.copy (| γ1_0 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "core::option::Option::Some", + 0 + |) in + let b := M.copy (| γ1_0 |) in + let γ := + M.alloc (| + BinOp.Pure.eq + (M.read (| a |)) + (M.read (| b |)) + |) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ M.read (| a |) ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))) + ] + |) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "core::option::Option::Some", + 0 + |) in + let len := M.copy (| γ1_0 |) in + len)); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "halo2_proofs::plonk::error::Error::Synthesis" + [] + ] + |) + |) + |) + |))) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "std::collections::hash::map::Keys") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "std::hash::random::RandomState" + ], + "keys", + [] + |), + [ default_and_assigned ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "std::collections::hash::map::Keys") + [ + Ty.path + "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let column := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::circuit::TableColumn"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ dynamic ] + |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeDynamic", + "table_columns" + |); + M.read (| M.read (| column |) |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "std::hash::random::RandomState" + ], + "iter", + [] + |), + [ default_and_assigned ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let col := M.copy (| γ1_0 |) in + let γ1_1 := M.read (| γ1_1 |) in + let γ3_0 := + M.SubPointer.get_tuple_field (| γ1_1, 0 |) in + let γ3_1 := + M.SubPointer.get_tuple_field (| γ1_1, 1 |) in + let default_val := M.alloc (| γ3_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "fill_from_row", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter", + "cs" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::plonk::circuit::TableColumn", + "inner", + [] + |), + [ M.read (| col |) ] + |); + M.read (| first_unused |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ], + "unwrap", + [] + |), + [ + M.read (| + M.read (| default_val |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn constrain_instance( + &self, + cell: Cell, + instance: Column, + row: usize, + ) -> Result<(), Error> { + self.cs + .copy(cell.column, cell.row_offset, instance.into(), row) + } + *) + Definition constrain_instance (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; cell; instance; row ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let cell := M.alloc (| cell |) in + let instance := M.alloc (| instance |) in + let row := M.alloc (| row |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "copy", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter", + "cs" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + cell, + "halo2_proofs::circuit::Cell", + "column" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + cell, + "halo2_proofs::circuit::Cell", + "row_offset" + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "into", + [] + |), + [ M.read (| instance |) ] + |); + M.read (| row |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn get_root(&self) -> &Self::Root { + self + } + *) + Definition get_root (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| self |))) + | _, _ => M.impossible + end. + + (* + fn push_namespace(&self, name_fn: N) + where + NR: Into, + N: FnOnce() -> NR, + { + self.cs.push_namespace(name_fn) + } + *) + Definition push_namespace (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [ NR; N ], [ self; name_fn ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name_fn := M.alloc (| name_fn |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "push_namespace", + [ NR; N ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter", + "cs" + |) + |); + M.read (| name_fn |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn pop_namespace(&self, gadget_name: Option) { + self.cs.pop_namespace(gadget_name) + } + *) + Definition pop_namespace (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; gadget_name ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let gadget_name := M.alloc (| gadget_name |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "pop_namespace", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatShapeLayouter", + "cs" + |) + |); + M.read (| gadget_name |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "halo2_proofs::circuit::Layouter" + (Self F CS) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("Root", InstanceField.Ty (_Root F CS)); + ("assign_region", InstanceField.Method (assign_region F CS)); + ("assign_table", InstanceField.Method (assign_table F CS)); + ("constrain_instance", InstanceField.Method (constrain_instance F CS)); + ("get_root", InstanceField.Method (get_root F CS)); + ("push_namespace", InstanceField.Method (push_namespace F CS)); + ("pop_namespace", InstanceField.Method (pop_namespace F CS)) + ]. + End Impl_halo2_proofs_circuit_Layouter_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_F_for_halo2_proofs_circuit_floor_planner_flat_FlatShapeLayouter_F_CS. + + (* StructRecord + { + name := "FlatChipLayouter"; + ty_params := [ "F"; "CS" ]; + fields := + [ + ("cs", Ty.apply (Ty.path "&") [ CS ]); + ("_mark", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_where_core_clone_Clone_CS_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_flat_FlatChipLayouter_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouter") + [ F; CS ]. + + (* Clone *) + Definition clone (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouter" + [ + ("cs", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "&") [ CS ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouter", + "cs" + |) + ] + |)); + ("_mark", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouter", + "_mark" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F CS) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F CS)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_where_core_clone_Clone_CS_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_flat_FlatChipLayouter_F_CS. + + Module Impl_core_marker_Send_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_flat_FlatChipLayouter_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouter") + [ F; CS ]. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "core::marker::Send" + (Self F CS) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Send_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_flat_FlatChipLayouter_F_CS. + + Module Impl_halo2_proofs_circuit_floor_planner_flat_FlatChipLayouter_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouter") + [ F; CS ]. + + (* + pub fn new(cs: &'a CS) -> Result { + let ret = FlatChipLayouter { + cs, + _mark: PhantomData, + }; + Ok(ret) + } + *) + Definition new (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ cs ] => + ltac:(M.monadic + (let cs := M.alloc (| cs |) in + M.read (| + let ret := + M.alloc (| + Value.StructRecord + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouter" + [ + ("cs", M.read (| cs |)); + ("_mark", Value.StructTuple "core::marker::PhantomData" []) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| ret |) ] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F CS : Ty.t), + M.IsAssociatedFunction (Self F CS) "new" (new F CS). + End Impl_halo2_proofs_circuit_floor_planner_flat_FlatChipLayouter_F_CS. + + Module Impl_halo2_proofs_circuit_Layouter_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_F_for_halo2_proofs_circuit_floor_planner_flat_FlatChipLayouter_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouter") + [ F; CS ]. + + (* type Root = Self; *) + Definition _Root (F CS : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouter") + [ F; CS ]. + + (* + fn assign_region(&self, _name: N, assignment: A) -> Result + where + A: Fn(&Region<'_, F>) -> Result, + N: Fn() -> NR, + NR: Into, + { + let region = FlatChipLayouterRegion::new(self.cs); + let result = { + let region: &dyn RegionLayouter = ®ion; + assignment(®ion.into()) + }?; + Ok(result) + } + *) + Definition assign_region (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [ A; AR; N; NR ], [ self; _name; assignment ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _name := M.alloc (| _name |) in + let assignment := M.alloc (| assignment |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let region := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouterRegion") + [ F; CS ], + "new", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouter", + "cs" + |) + |) + ] + |) + |) in + let result := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ AR; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.read (| + let region := + M.alloc (| (* Unsize *) M.pointer_coercion region |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + A, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::Region") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + assignment; + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("halo2_proofs::circuit::layouter::RegionLayouter::Trait", + []) + ] + ], + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::Region") + [ F ] + ], + "into", + [] + |), + [ M.read (| region |) ] + |) + |) + ] + ] + |) + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ AR; Ty.path "halo2_proofs::plonk::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ M.read (| result |) ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn assign_table(&self, _name: N, mut _assignment: A) -> Result<(), Error> + where + A: FnMut(Table<'_, F>) -> Result<(), Error>, + N: Fn() -> NR, + NR: Into, + { + Ok(()) + } + *) + Definition assign_table (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [ A; N; NR ], [ self; _name; _assignment ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _name := M.alloc (| _name |) in + let _assignment := M.alloc (| _assignment |) in + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ])) + | _, _ => M.impossible + end. + + (* + fn constrain_instance( + &self, + _cell: Cell, + _instance: Column, + _row: usize, + ) -> Result<(), Error> { + Ok(()) + } + *) + Definition constrain_instance (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; _cell; _instance; _row ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _cell := M.alloc (| _cell |) in + let _instance := M.alloc (| _instance |) in + let _row := M.alloc (| _row |) in + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ])) + | _, _ => M.impossible + end. + + (* + fn get_root(&self) -> &Self::Root { + self + } + *) + Definition get_root (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| self |))) + | _, _ => M.impossible + end. + + (* + fn push_namespace(&self, name_fn: N) + where + NR: Into, + N: FnOnce() -> NR, + { + self.cs.push_namespace(name_fn) + } + *) + Definition push_namespace (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [ NR; N ], [ self; name_fn ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name_fn := M.alloc (| name_fn |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "push_namespace", + [ NR; N ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouter", + "cs" + |) + |); + M.read (| name_fn |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn pop_namespace(&self, gadget_name: Option) { + self.cs.pop_namespace(gadget_name) + } + *) + Definition pop_namespace (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; gadget_name ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let gadget_name := M.alloc (| gadget_name |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "pop_namespace", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouter", + "cs" + |) + |); + M.read (| gadget_name |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "halo2_proofs::circuit::Layouter" + (Self F CS) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("Root", InstanceField.Ty (_Root F CS)); + ("assign_region", InstanceField.Method (assign_region F CS)); + ("assign_table", InstanceField.Method (assign_table F CS)); + ("constrain_instance", InstanceField.Method (constrain_instance F CS)); + ("get_root", InstanceField.Method (get_root F CS)); + ("push_namespace", InstanceField.Method (push_namespace F CS)); + ("pop_namespace", InstanceField.Method (pop_namespace F CS)) + ]. + End Impl_halo2_proofs_circuit_Layouter_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_F_for_halo2_proofs_circuit_floor_planner_flat_FlatChipLayouter_F_CS. + + (* StructRecord + { + name := "FlatChipLayouterRegion"; + ty_params := [ "F"; "CS" ]; + fields := + [ + ("cs", Ty.apply (Ty.path "&") [ CS ]); + ("_mark", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_flat_FlatChipLayouterRegion_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouterRegion") + [ F; CS ]. + + (* + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("FlatChipLayouterRegion").finish() + } + *) + Definition fmt (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::builders::DebugStruct", + "finish", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct", + [] + |), + [ M.read (| f |); M.read (| Value.String "FlatChipLayouterRegion" |) ] + |) + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F CS) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F CS)) ]. + End Impl_core_fmt_Debug_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_flat_FlatChipLayouterRegion_F_CS. + + Module Impl_halo2_proofs_circuit_floor_planner_flat_FlatChipLayouterRegion_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouterRegion") + [ F; CS ]. + + (* + fn new(cs: &'a CS) -> Self { + FlatChipLayouterRegion { + cs, + _mark: PhantomData, + } + } + *) + Definition new (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ cs ] => + ltac:(M.monadic + (let cs := M.alloc (| cs |) in + Value.StructRecord + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouterRegion" + [ + ("cs", M.read (| cs |)); + ("_mark", Value.StructTuple "core::marker::PhantomData" []) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F CS : Ty.t), + M.IsAssociatedFunction (Self F CS) "new" (new F CS). + End Impl_halo2_proofs_circuit_floor_planner_flat_FlatChipLayouterRegion_F_CS. + + Module Impl_halo2_proofs_circuit_layouter_RegionLayouter_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_F_for_halo2_proofs_circuit_floor_planner_flat_FlatChipLayouterRegion_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouterRegion") + [ F; CS ]. + + (* + fn enable_selector<'v>( + &'v self, + annotation: &'v (dyn Fn() -> String + 'v), + selector: &Selector, + offset: usize, + ) -> Result<(), Error> { + self.cs.enable_selector(annotation, selector, offset) + } + *) + Definition enable_selector (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; annotation; selector; offset ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let annotation := M.alloc (| annotation |) in + let selector := M.alloc (| selector |) in + let offset := M.alloc (| offset |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "enable_selector", + [ + Ty.apply (Ty.path "&") [ Ty.dyn [ ("core::ops::function::Fn::Trait", []) ] ]; + Ty.path "alloc::string::String" + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouterRegion", + "cs" + |) + |); + M.read (| annotation |); + M.read (| selector |); + M.read (| offset |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign_advice<'v>( + &'v self, + annotation: &'v (dyn Fn() -> String + 'v), + column: Column, + offset: usize, + to: &'v mut (dyn FnMut() -> Result, Error> + 'v), + ) -> Result { + self.cs.assign_advice(annotation, column, offset, to)?; + + Ok(Cell { + //region_index: self.region_index, + region_index: RegionIndex(0), // no longer track the region index as in phase 2 + row_offset: offset, + column: column.into(), + }) + } + *) + Definition assign_advice (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; annotation; column; offset; to ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let annotation := M.alloc (| annotation |) in + let column := M.alloc (| column |) in + let offset := M.alloc (| offset |) in + let to := M.alloc (| to |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "assign_advice", + [ + Ty.apply + (Ty.path "&mut") + [ Ty.dyn [ ("core::ops::function::FnMut::Trait", []) ] ]; + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.apply + (Ty.path "&") + [ Ty.dyn [ ("core::ops::function::Fn::Trait", []) ] ]; + Ty.path "alloc::string::String" + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouterRegion", + "cs" + |) + |); + M.read (| annotation |); + M.read (| column |); + M.read (| offset |); + M.read (| to |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::circuit::Cell" + [ + ("region_index", + Value.StructTuple + "halo2_proofs::circuit::RegionIndex" + [ Value.Integer 0 ]); + ("row_offset", M.read (| offset |)); + ("column", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "into", + [] + |), + [ M.read (| column |) ] + |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn assign_advice_from_constant<'v>( + &'v self, + annotation: &'v (dyn Fn() -> String + 'v), + column: Column, + offset: usize, + constant: Assigned, + ) -> Result { + let advice = self.assign_advice(annotation, column, offset, &mut || Ok(constant))?; + self.constrain_constant(advice, constant)?; + + Ok(advice) + } + *) + Definition assign_advice_from_constant + (F CS : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; annotation; column; offset; constant ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let annotation := M.alloc (| annotation |) in + let column := M.alloc (| column |) in + let offset := M.alloc (| offset |) in + let constant := M.alloc (| constant |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let advice := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::layouter::RegionLayouter", + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouterRegion") + [ F; CS ], + [ F ], + "assign_advice", + [] + |), + [ + M.read (| self |); + (* Unsize *) M.pointer_coercion (M.read (| annotation |)); + M.read (| column |); + M.read (| offset |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ M.read (| constant |) ])) + ] + |) + | _ => M.impossible (||) + end)) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::layouter::RegionLayouter", + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouterRegion") + [ F; CS ], + [ F ], + "constrain_constant", + [] + |), + [ M.read (| self |); M.read (| advice |); M.read (| constant |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ M.read (| advice |) ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn assign_advice_from_instance<'v>( + &self, + annotation: &'v (dyn Fn() -> String + 'v), + instance: Column, + row: usize, + advice: Column, + offset: usize, + ) -> Result<(Cell, Option), Error> { + let value = self.cs.query_instance(instance, row)?; + + let cell = self.assign_advice(annotation, advice, offset, &mut || { + value.ok_or(Error::Synthesis).map(|v| v.into()) + })?; + + self.cs + .copy(cell.column, cell.row_offset, instance.into(), row)?; + + Ok((cell, value)) + } + *) + Definition assign_advice_from_instance + (F CS : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; annotation; instance; row; advice; offset ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let annotation := M.alloc (| annotation |) in + let instance := M.alloc (| instance |) in + let row := M.alloc (| row |) in + let advice := M.alloc (| advice |) in + let offset := M.alloc (| offset |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let value := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "core::option::Option") [ F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "query_instance", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouterRegion", + "cs" + |) + |); + M.read (| instance |); + M.read (| row |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.apply (Ty.path "core::option::Option") [ F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let cell := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::layouter::RegionLayouter", + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouterRegion") + [ F; CS ], + [ F ], + "assign_advice", + [] + |), + [ + M.read (| self |); + (* Unsize *) M.pointer_coercion (M.read (| annotation |)); + M.read (| advice |); + M.read (| offset |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.function + [ Ty.tuple [ F ] ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ F ], + "ok_or", + [ + Ty.path + "halo2_proofs::plonk::error::Error" + ] + |), + [ + M.read (| value |); + Value.StructTuple + "halo2_proofs::plonk::error::Error::Synthesis" + [] + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let v := + M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + F, + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ], + "into", + [] + |), + [ M.read (| v |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.apply (Ty.path "core::option::Option") [ F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "copy", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouterRegion", + "cs" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + cell, + "halo2_proofs::circuit::Cell", + "column" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + cell, + "halo2_proofs::circuit::Cell", + "row_offset" + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "into", + [] + |), + [ M.read (| instance |) ] + |); + M.read (| row |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.apply (Ty.path "core::option::Option") [ F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [ M.read (| cell |); M.read (| value |) ] ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn assign_fixed<'v>( + &'v self, + annotation: &'v (dyn Fn() -> String + 'v), + column: Column, + offset: usize, + to: &'v mut (dyn FnMut() -> Result, Error> + 'v), + ) -> Result { + self.cs.assign_fixed(annotation, column, offset, to)?; + Ok(Cell { + //region_index: self.region_index, + region_index: RegionIndex(0), // no longer track the region index as in phase 2 + row_offset: offset, + column: column.into(), + }) + } + *) + Definition assign_fixed (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; annotation; column; offset; to ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let annotation := M.alloc (| annotation |) in + let column := M.alloc (| column |) in + let offset := M.alloc (| offset |) in + let to := M.alloc (| to |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "assign_fixed", + [ + Ty.apply + (Ty.path "&mut") + [ Ty.dyn [ ("core::ops::function::FnMut::Trait", []) ] ]; + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.apply + (Ty.path "&") + [ Ty.dyn [ ("core::ops::function::Fn::Trait", []) ] ]; + Ty.path "alloc::string::String" + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouterRegion", + "cs" + |) + |); + M.read (| annotation |); + M.read (| column |); + M.read (| offset |); + M.read (| to |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::circuit::Cell" + [ + ("region_index", + Value.StructTuple + "halo2_proofs::circuit::RegionIndex" + [ Value.Integer 0 ]); + ("row_offset", M.read (| offset |)); + ("column", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "into", + [] + |), + [ M.read (| column |) ] + |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn constrain_constant(&self, _cell: Cell, _constant: Assigned) -> Result<(), Error> { + Ok(()) + } + *) + Definition constrain_constant (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; _cell; _constant ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _cell := M.alloc (| _cell |) in + let _constant := M.alloc (| _constant |) in + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ])) + | _, _ => M.impossible + end. + + (* + fn constrain_equal(&self, left: Cell, right: Cell) -> Result<(), Error> { + self.cs + .copy(left.column, left.row_offset, right.column, right.row_offset)?; + + Ok(()) + } + *) + Definition constrain_equal (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; _ as left; _ as right ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let left := M.alloc (| left |) in + let right := M.alloc (| right |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "copy", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::FlatChipLayouterRegion", + "cs" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + left, + "halo2_proofs::circuit::Cell", + "column" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + left, + "halo2_proofs::circuit::Cell", + "row_offset" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + right, + "halo2_proofs::circuit::Cell", + "column" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + right, + "halo2_proofs::circuit::Cell", + "row_offset" + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "halo2_proofs::circuit::layouter::RegionLayouter" + (Self F CS) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("enable_selector", InstanceField.Method (enable_selector F CS)); + ("assign_advice", InstanceField.Method (assign_advice F CS)); + ("assign_advice_from_constant", + InstanceField.Method (assign_advice_from_constant F CS)); + ("assign_advice_from_instance", + InstanceField.Method (assign_advice_from_instance F CS)); + ("assign_fixed", InstanceField.Method (assign_fixed F CS)); + ("constrain_constant", InstanceField.Method (constrain_constant F CS)); + ("constrain_equal", InstanceField.Method (constrain_equal F CS)) + ]. + End Impl_halo2_proofs_circuit_layouter_RegionLayouter_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_F_for_halo2_proofs_circuit_floor_planner_flat_FlatChipLayouterRegion_F_CS. + End flat. + End floor_planner. +End circuit. diff --git a/CoqOfRust/halo2_proofs/circuit/floor_planner/flat/region.v b/CoqOfRust/halo2_proofs/circuit/floor_planner/flat/region.v new file mode 100644 index 000000000..2c356ad15 --- /dev/null +++ b/CoqOfRust/halo2_proofs/circuit/floor_planner/flat/region.v @@ -0,0 +1,1753 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuit. + Module floor_planner. + Module flat. + Module region. + (* StructRecord + { + name := "RegionSetup"; + ty_params := [ "F" ]; + fields := + [ + ("region_index", Ty.path "halo2_proofs::circuit::RegionIndex"); + ("columns", + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path "std::hash::random::RandomState" + ]); + ("row_count", Ty.path "usize"); + ("constants", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_for_halo2_proofs_circuit_floor_planner_flat_region_RegionSetup_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup" + [ + ("region_index", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::circuit::RegionIndex", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "region_index" + |) + ] + |)); + ("columns", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path "std::hash::random::RandomState" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "columns" + |) + ] + |)); + ("row_count", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "usize", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "row_count" + |) + ] + |)); + ("constants", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "constants" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_for_halo2_proofs_circuit_floor_planner_flat_region_RegionSetup_F. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_circuit_floor_planner_flat_region_RegionSetup_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field4_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "RegionSetup" |); + M.read (| Value.String "region_index" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "region_index" + |)); + M.read (| Value.String "columns" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "columns" + |)); + M.read (| Value.String "row_count" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "row_count" + |)); + M.read (| Value.String "constants" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "constants" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_circuit_floor_planner_flat_region_RegionSetup_F. + + Module Impl_halo2_proofs_circuit_floor_planner_flat_region_RegionSetup_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ]. + + (* + pub(crate) fn new(region_index: RegionIndex) -> Self { + RegionSetup { + region_index, + columns: HashSet::default(), + row_count: 0, + constants: vec![], + } + } + *) + Definition new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ region_index ] => + ltac:(M.monadic + (let region_index := M.alloc (| region_index |) in + Value.StructRecord + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup" + [ + ("region_index", M.read (| region_index |)); + ("columns", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path "std::hash::random::RandomState" + ], + [], + "default", + [] + |), + [] + |)); + ("row_count", Value.Integer 0); + ("constants", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "new" (new F). + End Impl_halo2_proofs_circuit_floor_planner_flat_region_RegionSetup_F. + + Module Impl_halo2_proofs_circuit_layouter_RegionLayouter_where_ff_Field_F_F_for_halo2_proofs_parallel_Parallel_halo2_proofs_circuit_floor_planner_flat_region_RegionSetup_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ]. + + (* + fn enable_selector<'v>( + &'v self, + _: &'v (dyn Fn() -> String + 'v), + selector: &Selector, + offset: usize, + ) -> Result<(), Error> { + // Track the selector's fixed column as part of the region's shape. + let mut region = self.lock().unwrap(); + region.columns.insert(( *selector).into()); + region.row_count = cmp::max(region.row_count, offset + 1); + Ok(()) + } + *) + Definition enable_selector (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1; selector; offset ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let selector := M.alloc (| selector |) in + let offset := M.alloc (| offset |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.read (| + let region := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + "lock", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ region ] + |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "columns" + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "halo2_proofs::plonk::circuit::Selector", + [ Ty.path "halo2_proofs::circuit::layouter::RegionColumn" ], + "into", + [] + |), + [ M.read (| M.read (| selector |) |) ] + |) + ] + |) + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ region ] + |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "row_count" + |), + M.call_closure (| + M.get_function (| "core::cmp::max", [ Ty.path "usize" ] |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + [], + "deref", + [] + |), + [ region ] + |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "row_count" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| offset |), + Value.Integer 1 + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |) + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign_advice<'v>( + &'v self, + _: &'v (dyn Fn() -> String + 'v), + column: Column, + offset: usize, + _to: &'v mut (dyn FnMut() -> Result, Error> + 'v), + ) -> Result { + let mut region = self.lock().unwrap(); + region.columns.insert(Column::::from(column).into()); + region.row_count = cmp::max(region.row_count, offset + 1); + + Ok(Cell { + region_index: region.region_index, + row_offset: offset, + column: column.into(), + }) + } + *) + Definition assign_advice (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1; column; offset; _to ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let column := M.alloc (| column |) in + let offset := M.alloc (| offset |) in + let _to := M.alloc (| _to |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.read (| + let region := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + "lock", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ region ] + |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "columns" + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + [ Ty.path "halo2_proofs::circuit::layouter::RegionColumn" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + "from", + [] + |), + [ M.read (| column |) ] + |) + ] + |) + ] + |) + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ region ] + |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "row_count" + |), + M.call_closure (| + M.get_function (| "core::cmp::max", [ Ty.path "usize" ] |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + [], + "deref", + [] + |), + [ region ] + |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "row_count" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| offset |), + Value.Integer 1 + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::circuit::Cell" + [ + ("region_index", + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + [], + "deref", + [] + |), + [ region ] + |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "region_index" + |) + |)); + ("row_offset", M.read (| offset |)); + ("column", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "into", + [] + |), + [ M.read (| column |) ] + |)) + ] + ] + |) + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign_advice_from_constant<'v>( + &'v self, + annotation: &'v (dyn Fn() -> String + 'v), + column: Column, + offset: usize, + constant: Assigned, + ) -> Result { + // The rest is identical to witnessing an advice cell. + let advice = self.assign_advice(annotation, column, offset, &mut || Ok(constant))?; + self.constrain_constant(advice, constant)?; + Ok(advice) + } + *) + Definition assign_advice_from_constant + (F : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; annotation; column; offset; constant ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let annotation := M.alloc (| annotation |) in + let column := M.alloc (| column |) in + let offset := M.alloc (| offset |) in + let constant := M.alloc (| constant |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let advice := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::layouter::RegionLayouter", + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + [ F ], + "assign_advice", + [] + |), + [ + M.read (| self |); + (* Unsize *) M.pointer_coercion (M.read (| annotation |)); + M.read (| column |); + M.read (| offset |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ M.read (| constant |) ])) + ] + |) + | _ => M.impossible (||) + end)) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::layouter::RegionLayouter", + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + [ F ], + "constrain_constant", + [] + |), + [ M.read (| self |); M.read (| advice |); M.read (| constant |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ M.read (| advice |) ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn assign_advice_from_instance<'v>( + &self, + _: &'v (dyn Fn() -> String + 'v), + _: Column, + _: usize, + advice: Column, + offset: usize, + ) -> Result<(Cell, Option), Error> { + let mut region = self.lock().unwrap(); + region.columns.insert(Column::::from(advice).into()); + region.row_count = cmp::max(region.row_count, offset + 1); + + Ok(( + Cell { + region_index: region.region_index, + row_offset: offset, + column: advice.into(), + }, + None, + )) + } + *) + Definition assign_advice_from_instance + (F : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1; β2; β3; advice; offset ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let β2 := M.alloc (| β2 |) in + let β3 := M.alloc (| β3 |) in + let advice := M.alloc (| advice |) in + let offset := M.alloc (| offset |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β2, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β3, + [ + fun γ => + ltac:(M.monadic + (M.read (| + let region := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + "lock", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ region ] + |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "columns" + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn" + ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ], + "from", + [] + |), + [ M.read (| advice |) ] + |) + ] + |) + ] + |) + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ region ] + |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "row_count" + |), + M.call_closure (| + M.get_function (| + "core::cmp::max", + [ Ty.path "usize" ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + [], + "deref", + [] + |), + [ region ] + |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "row_count" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| offset |), + Value.Integer 1 + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.Tuple + [ + Value.StructRecord + "halo2_proofs::circuit::Cell" + [ + ("region_index", + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + [], + "deref", + [] + |), + [ region ] + |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "region_index" + |) + |)); + ("row_offset", M.read (| offset |)); + ("column", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "into", + [] + |), + [ M.read (| advice |) ] + |)) + ]; + Value.StructTuple + "core::option::Option::None" + [] + ] + ] + |) + |))) + ] + |))) + ] + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign_fixed<'v>( + &'v self, + _: &'v (dyn Fn() -> String + 'v), + column: Column, + offset: usize, + _to: &'v mut (dyn FnMut() -> Result, Error> + 'v), + ) -> Result { + let mut region = self.lock().unwrap(); + region.columns.insert(Column::::from(column).into()); + region.row_count = cmp::max(region.row_count, offset + 1); + + Ok(Cell { + region_index: region.region_index, + row_offset: offset, + column: column.into(), + }) + } + *) + Definition assign_fixed (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1; column; offset; _to ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let column := M.alloc (| column |) in + let offset := M.alloc (| offset |) in + let _to := M.alloc (| _to |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.read (| + let region := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + "lock", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ region ] + |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "columns" + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + [ Ty.path "halo2_proofs::circuit::layouter::RegionColumn" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ], + "from", + [] + |), + [ M.read (| column |) ] + |) + ] + |) + ] + |) + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ region ] + |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "row_count" + |), + M.call_closure (| + M.get_function (| "core::cmp::max", [ Ty.path "usize" ] |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + [], + "deref", + [] + |), + [ region ] + |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "row_count" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| offset |), + Value.Integer 1 + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::circuit::Cell" + [ + ("region_index", + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + [], + "deref", + [] + |), + [ region ] + |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "region_index" + |) + |)); + ("row_offset", M.read (| offset |)); + ("column", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "into", + [] + |), + [ M.read (| column |) ] + |)) + ] + ] + |) + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn constrain_constant(&self, cell: Cell, constant: Assigned) -> Result<(), Error> { + // Global constants don't affect the region shape. + let mut region = self.lock().unwrap(); + region.constants.push((constant, cell)); + Ok(()) + } + *) + Definition constrain_constant (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; cell; constant ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let cell := M.alloc (| cell |) in + let constant := M.alloc (| constant |) in + M.read (| + let region := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + "lock", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ region ] + |), + "halo2_proofs::circuit::floor_planner::flat::region::RegionSetup", + "constants" + |); + Value.Tuple [ M.read (| constant |); M.read (| cell |) ] + ] + |) + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + | _, _ => M.impossible + end. + + (* + fn constrain_equal(&self, _left: Cell, _right: Cell) -> Result<(), Error> { + // Equality constraints don't affect the region shape. + Ok(()) + } + *) + Definition constrain_equal (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _left; _right ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _left := M.alloc (| _left |) in + let _right := M.alloc (| _right |) in + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "halo2_proofs::circuit::layouter::RegionLayouter" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("enable_selector", InstanceField.Method (enable_selector F)); + ("assign_advice", InstanceField.Method (assign_advice F)); + ("assign_advice_from_constant", + InstanceField.Method (assign_advice_from_constant F)); + ("assign_advice_from_instance", + InstanceField.Method (assign_advice_from_instance F)); + ("assign_fixed", InstanceField.Method (assign_fixed F)); + ("constrain_constant", InstanceField.Method (constrain_constant F)); + ("constrain_equal", InstanceField.Method (constrain_equal F)) + ]. + End Impl_halo2_proofs_circuit_layouter_RegionLayouter_where_ff_Field_F_F_for_halo2_proofs_parallel_Parallel_halo2_proofs_circuit_floor_planner_flat_region_RegionSetup_F. + End region. + End flat. + End floor_planner. +End circuit. diff --git a/CoqOfRust/halo2_proofs/circuit/floor_planner/single_pass.v b/CoqOfRust/halo2_proofs/circuit/floor_planner/single_pass.v new file mode 100644 index 000000000..680acc22c --- /dev/null +++ b/CoqOfRust/halo2_proofs/circuit/floor_planner/single_pass.v @@ -0,0 +1,973 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuit. + Module floor_planner. + Module single_pass. + Axiom DefaultTableValue : + forall (F : Ty.t), + (Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::single_pass::DefaultTableValue") + [ F ]) = + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ] ] + ]). + + (* StructRecord + { + name := "SimpleTableLayouter"; + ty_params := [ "F"; "CS" ]; + fields := + [ + ("cs", Ty.apply (Ty.path "&") [ CS ]); + ("used_columns", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.path "halo2_proofs::plonk::circuit::TableColumn" ] + ]); + ("default_and_assigned", + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "std::hash::random::RandomState" + ] + ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_single_pass_SimpleTableLayouter_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::single_pass::SimpleTableLayouter") + [ F; CS ]. + + (* + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("SimpleTableLayouter") + .field("used_columns", &self.used_columns) + .field("default_and_assigned", &self.default_and_assigned) + .finish() + } + *) + Definition fmt (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::builders::DebugStruct", + "finish", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::builders::DebugStruct", + "field", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::builders::DebugStruct", + "field", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct", + [] + |), + [ M.read (| f |); M.read (| Value.String "SimpleTableLayouter" |) ] + |) + |); + M.read (| Value.String "used_columns" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::single_pass::SimpleTableLayouter", + "used_columns" + |)) + ] + |); + M.read (| Value.String "default_and_assigned" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::single_pass::SimpleTableLayouter", + "default_and_assigned" + |)) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F CS) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F CS)) ]. + End Impl_core_fmt_Debug_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_single_pass_SimpleTableLayouter_F_CS. + + Module Impl_halo2_proofs_circuit_floor_planner_single_pass_SimpleTableLayouter_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::single_pass::SimpleTableLayouter") + [ F; CS ]. + + (* + pub(crate) fn new(cs: &'a CS, used_columns: &'r [TableColumn]) -> Self { + SimpleTableLayouter { + cs, + used_columns, + default_and_assigned: Parallel::new(HashMap::default()), + } + } + *) + Definition new (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ cs; used_columns ] => + ltac:(M.monadic + (let cs := M.alloc (| cs |) in + let used_columns := M.alloc (| used_columns |) in + Value.StructRecord + "halo2_proofs::circuit::floor_planner::single_pass::SimpleTableLayouter" + [ + ("cs", M.read (| cs |)); + ("used_columns", M.read (| used_columns |)); + ("default_and_assigned", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "std::hash::random::RandomState" + ] + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "std::hash::random::RandomState" + ], + [], + "default", + [] + |), + [] + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F CS : Ty.t), + M.IsAssociatedFunction (Self F CS) "new" (new F CS). + End Impl_halo2_proofs_circuit_floor_planner_single_pass_SimpleTableLayouter_F_CS. + + Module Impl_halo2_proofs_circuit_layouter_TableLayouter_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_F_for_halo2_proofs_circuit_floor_planner_single_pass_SimpleTableLayouter_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::single_pass::SimpleTableLayouter") + [ F; CS ]. + + (* + fn assign_cell<'v>( + &'v self, + annotation: &'v (dyn Fn() -> String + 'v), + column: TableColumn, + offset: usize, + to: &'v mut (dyn FnMut() -> Result, Error> + 'v), + ) -> Result<(), Error> { + if self.used_columns.contains(&column) { + return Err(Error::Synthesis); // TODO better error + } + + let mut default_and_assigned = self.default_and_assigned.lock().unwrap(); + let entry = default_and_assigned.entry(column).or_default(); + + let mut value = None; + self.cs.assign_fixed( + annotation, + column.inner(), + offset, // tables are always assigned starting at row 0 + || { + let res = to(); + value = res.as_ref().ok().cloned(); + res + }, + )?; + + match (entry.0.is_none(), offset) { + // Use the value at offset 0 as the default value for this table column. + (true, 0) => entry.0 = Some(value), + // Since there is already an existing default value for this table column, + // the caller should not be attempting to assign another value at offset 0. + (false, 0) => return Err(Error::Synthesis), // TODO better error + _ => (), + } + if entry.1.len() <= offset { + entry.1.resize(offset + 1, false); + } + entry.1[offset] = true; + + Ok(()) + } + *) + Definition assign_cell (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; annotation; column; offset; to ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let annotation := M.alloc (| annotation |) in + let column := M.alloc (| column |) in + let offset := M.alloc (| offset |) in + let to := M.alloc (| to |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "halo2_proofs::plonk::circuit::TableColumn" ], + "contains", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::single_pass::SimpleTableLayouter", + "used_columns" + |) + |); + column + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "halo2_proofs::plonk::error::Error::Synthesis" + [] + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let default_and_assigned := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "std::hash::random::RandomState" + ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "std::hash::random::RandomState" + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "std::hash::random::RandomState" + ] + ], + "lock", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::single_pass::SimpleTableLayouter", + "default_and_assigned" + |) + ] + |) + ] + |) + |) in + let entry := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::Entry") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ] + ], + "or_default", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "std::hash::random::RandomState" + ], + "entry", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "std::hash::random::RandomState" + ] + ], + [], + "deref_mut", + [] + |), + [ default_and_assigned ] + |); + M.read (| column |) + ] + |) + ] + |) + |) in + let value := M.alloc (| Value.StructTuple "core::option::Option::None" [] |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "assign_fixed", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]); + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.apply + (Ty.path "&") + [ Ty.dyn [ ("core::ops::function::Fn::Trait", []) ] ]; + Ty.path "alloc::string::String" + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::single_pass::SimpleTableLayouter", + "cs" + |) + |); + M.read (| annotation |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::circuit::TableColumn", + "inner", + [] + |), + [ column ] + |); + M.read (| offset |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let res := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnMut", + Ty.dyn + [ + ("core::ops::function::FnMut::Trait", + []) + ], + [ Ty.tuple [] ], + "call_mut", + [] + |), + [ M.read (| to |); Value.Tuple [] ] + |) + |) in + let _ := + M.write (| + value, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ], + "cloned", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "ok", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "as_ref", + [] + |), + [ res ] + |) + ] + |) + ] + |) + |) in + res + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ], + "is_none", + [] + |), + [ M.SubPointer.get_tuple_field (| M.read (| entry |), 0 |) ] + |); + M.read (| offset |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ0_0 |), + Value.Bool true + |) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ0_1 |), + Value.Integer 0 + |) in + M.write (| + M.SubPointer.get_tuple_field (| M.read (| entry |), 0 |), + Value.StructTuple + "core::option::Option::Some" + [ M.read (| value |) ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ0_0 |), + Value.Bool false + |) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ0_1 |), + Value.Integer 0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "halo2_proofs::plonk::error::Error::Synthesis" + [] + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.le + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ M.SubPointer.get_tuple_field (| M.read (| entry |), 1 |) ] + |)) + (M.read (| offset |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ], + "resize", + [] + |), + [ + M.SubPointer.get_tuple_field (| M.read (| entry |), 1 |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| offset |), + Value.Integer 1 + |); + Value.Bool false + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + M.SubPointer.get_tuple_field (| M.read (| entry |), 1 |); + M.read (| offset |) + ] + |), + Value.Bool true + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "halo2_proofs::circuit::layouter::TableLayouter" + (Self F CS) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("assign_cell", InstanceField.Method (assign_cell F CS)) ]. + End Impl_halo2_proofs_circuit_layouter_TableLayouter_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_F_for_halo2_proofs_circuit_floor_planner_single_pass_SimpleTableLayouter_F_CS. + End single_pass. + End floor_planner. +End circuit. diff --git a/CoqOfRust/halo2_proofs/circuit/floor_planner/v1.v b/CoqOfRust/halo2_proofs/circuit/floor_planner/v1.v new file mode 100644 index 000000000..e8756776b --- /dev/null +++ b/CoqOfRust/halo2_proofs/circuit/floor_planner/v1.v @@ -0,0 +1,10154 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuit. + Module floor_planner. + Module v1. + (* StructTuple + { + name := "V1"; + ty_params := []; + fields := []; + } *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_circuit_floor_planner_v1_V1. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::floor_planner::v1::V1". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ M.read (| f |); M.read (| Value.String "V1" |) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_circuit_floor_planner_v1_V1. + + (* StructRecord + { + name := "V1Plan"; + ty_params := [ "F"; "CS" ]; + fields := + [ + ("cs", Ty.apply (Ty.path "&") [ CS ]); + ("regions", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "halo2_proofs::circuit::RegionStart"; Ty.path "alloc::alloc::Global" ]); + ("constants", + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ] + ]); + ("table_columns", + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.path "alloc::alloc::Global" + ] + ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_v1_V1Plan_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::v1::V1Plan") [ F; CS ]. + + (* + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("floor_planner::V1Plan").finish() + } + *) + Definition fmt (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::builders::DebugStruct", + "finish", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct", + [] + |), + [ M.read (| f |); M.read (| Value.String "floor_planner::V1Plan" |) ] + |) + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F CS) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F CS)) ]. + End Impl_core_fmt_Debug_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_v1_V1Plan_F_CS. + + Module Impl_halo2_proofs_circuit_floor_planner_v1_V1Plan_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::v1::V1Plan") [ F; CS ]. + + (* + pub fn new(cs: &'a CS) -> Result { + let ret = V1Plan { + cs, + regions: vec![], + constants: Parallel::new(vec![]), + table_columns: Parallel::new(vec![]), + }; + Ok(ret) + } + *) + Definition new (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ cs ] => + ltac:(M.monadic + (let cs := M.alloc (| cs |) in + M.read (| + let ret := + M.alloc (| + Value.StructRecord + "halo2_proofs::circuit::floor_planner::v1::V1Plan" + [ + ("cs", M.read (| cs |)); + ("regions", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("constants", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + ] + |)); + ("table_columns", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.path "alloc::alloc::Global" + ] + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + ] + |)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| ret |) ] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F CS : Ty.t), + M.IsAssociatedFunction (Self F CS) "new" (new F CS). + End Impl_halo2_proofs_circuit_floor_planner_v1_V1Plan_F_CS. + + Module Impl_halo2_proofs_plonk_circuit_FloorPlanner_for_halo2_proofs_circuit_floor_planner_v1_V1. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::floor_planner::v1::V1". + + (* + fn synthesize, C: Circuit>( + cs: &CS, + circuit: &C, + config: C::Config, + constants: Vec>, + ) -> Result<(), Error> { + let mut plan = V1Plan::new(cs)?; + + // First pass: measure the regions within the circuit. + let mut measure = MeasurementPassAssignment::new(); + { + let pass = &mut measure; + circuit + .without_witnesses() + .synthesize(config.clone(), V1Pass::<_, CS>::measure(pass))?; + } + + let measure: MeasurementPass = measure.into(); + + // Planning: + // - Position the regions. + let (regions, column_allocations) = + { strategy::slot_in_biggest_advice_first(measure.regions) }; + plan.regions = regions; + + // - Determine how many rows our planned circuit will require. + let first_unassigned_row = column_allocations + .iter() + .map(|(_, a)| a.unbounded_interval_start()) + .max() + .unwrap_or(0); + + // - Position the constants within those rows. + let fixed_allocations: Vec<_> = constants + .into_iter() + .map(|c| { + ( + c, + column_allocations + .get(&Column::::from(c).into()) + .cloned() + .unwrap_or_default(), + ) + }) + .collect(); + let constant_positions = || { + fixed_allocations.iter().flat_map(|(c, a)| { + let c = *c; + a.free_intervals(0, Some(first_unassigned_row)) + .flat_map(move |e| e.range().unwrap().map(move |i| (c, i))) + }) + }; + + // Second pass: + // - Assign the regions. + let mut assign = AssignmentPass::new(&mut plan, measure.regions_name); + { + let pass = &mut assign; + circuit.synthesize(config, V1Pass::assign(pass))?; + } + + let mut constants = plan.constants.lock().unwrap(); + + // - Assign the constants. + if constant_positions().count() < constants.len() { + return Err(Error::NotEnoughColumnsForConstants); + } + + constants.sort_by(|(_, cell_a), (_, cell_b)| { + if cell_a.column != cell_b.column { + cell_a.column.cmp(&cell_b.column) + } else { + cell_a.row_offset.cmp(&cell_b.row_offset) + } + }); + + for ((fixed_column, fixed_row), (value, advice)) in + constant_positions().zip(constants.iter()) + { + plan.cs.assign_fixed( + || format!("Constant({:?})", ( *value).evaluate()), + fixed_column, + fixed_row, + || Ok( *value), + )?; + plan.cs.copy( + fixed_column.into(), + fixed_row, + advice.column, + *plan.regions[*advice.region_index] + advice.row_offset, + )?; + } + + Ok(()) + } + *) + Definition synthesize (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F; CS; C ], [ cs; circuit; config; constants ] => + ltac:(M.monadic + (let cs := M.alloc (| cs |) in + let circuit := M.alloc (| circuit |) in + let config := M.alloc (| config |) in + let constants := M.alloc (| constants |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let plan := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::v1::V1Plan") + [ F; CS ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::v1::V1Plan") + [ F; CS ], + "new", + [] + |), + [ M.read (| cs |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let measure := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::circuit::floor_planner::v1::MeasurementPassAssignment", + "new", + [] + |), + [] + |) + |) in + let _ := + let pass := M.alloc (| measure |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Circuit", + C, + [ F ], + "synthesize", + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::v1::V1Pass") + [ F; CS ] + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Circuit", + C, + [ F ], + "without_witnesses", + [] + |), + [ M.read (| circuit |) ] + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.associated, + [], + "clone", + [] + |), + [ config ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::v1::V1Pass") + [ F; CS ], + "measure", + [] + |), + [ M.read (| pass |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |) in + let measure := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "halo2_proofs::circuit::floor_planner::v1::MeasurementPassAssignment", + [ Ty.path "halo2_proofs::circuit::floor_planner::v1::MeasurementPass" ], + "into", + [] + |), + [ M.read (| measure |) ] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::circuit::floor_planner::v1::strategy::slot_in_biggest_advice_first", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + measure, + "halo2_proofs::circuit::floor_planner::v1::MeasurementPass", + "regions" + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let regions := M.copy (| γ0_0 |) in + let column_allocations := M.copy (| γ0_1 |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + plan, + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "regions" + |), + M.read (| regions |) + |) in + let first_unassigned_row := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn" + ]; + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ] + ] + ] + ] + (Ty.path "usize") + ], + [], + "max", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ], + [], + "map", + [ + Ty.path "usize"; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn" + ]; + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ] + ] + ] + ] + (Ty.path "usize") + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations"; + Ty.path "std::hash::random::RandomState" + ], + "iter", + [] + |), + [ column_allocations ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let a := M.copy (| γ0_1 |) in + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations", + "unbounded_interval_start", + [] + |), + [ M.read (| a |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |); + Value.Integer 0 + ] + |) + |) in + let fixed_allocations := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| constants |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let c := M.copy (| γ |) in + Value.Tuple + [ + M.read (| c |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ], + "unwrap_or_default", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ] + ], + "cloned", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations"; + Ty.path + "std::hash::random::RandomState" + ], + "get", + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn" + ] + |), + [ + column_allocations; + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn" + ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ] + ], + "from", + [] + |), + [ M.read (| c |) ] + |) + ] + |) + |) + ] + |) + ] + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let constant_positions := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ] + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.associated; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace" + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.associated; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace" + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]) + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ fixed_allocations ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let c := M.alloc (| γ1_0 |) in + let a := M.alloc (| γ1_1 |) in + M.read (| + let c := + M.copy (| + M.read (| c |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.associated, + [], + "flat_map", + [ + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "usize" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize" + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "usize" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace" + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "usize" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize" + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "usize" + ]) + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations", + "free_intervals", + [] + |), + [ + M.read (| a |); + Value.Integer 0; + Value.StructTuple + "core::option::Option::Some" + [ + M.read (| + first_unassigned_row + |) + ] + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + e := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "usize" + ], + [], + "map", + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "usize" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize" + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "usize" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "usize" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace", + "range", + [] + |), + [ + e + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + i := + M.copy (| + γ + |) in + Value.Tuple + [ + M.read (| + c + |); + M.read (| + i + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let assign := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::v1::AssignmentPass") + [ F; CS ], + "new", + [] + |), + [ + plan; + M.read (| + M.SubPointer.get_struct_record_field (| + measure, + "halo2_proofs::circuit::floor_planner::v1::MeasurementPass", + "regions_name" + |) + |) + ] + |) + |) in + let _ := + let pass := M.alloc (| assign |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Circuit", + C, + [ F ], + "synthesize", + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::v1::V1Pass") + [ F; CS ] + ] + |), + [ + M.read (| circuit |); + M.read (| config |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::v1::V1Pass") + [ F; CS ], + "assign", + [] + |), + [ M.read (| pass |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |) in + let constants := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "lock", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + plan, + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "constants" + |) + ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.associated; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace" + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.associated; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace" + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]) + ]) + ], + [], + "count", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.associated; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace" + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ + Ty.tuple + [ Ty.path "usize" ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.associated; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ + Ty.tuple + [ Ty.path "usize" ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace" + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ + Ty.tuple + [ Ty.path "usize" ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]) + ]) + ]), + [ Ty.tuple [] ], + "call", + [] + |), + [ constant_positions; Value.Tuple [] ] + |) + ] + |)) + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path + "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref", + [] + |), + [ constants ] + |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "halo2_proofs::plonk::error::Error::NotEnoughColumnsForConstants" + [] + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ] + ], + "sort_by", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ] + ] + ] + ] + (Ty.path "core::cmp::Ordering") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref_mut", + [] + |), + [ constants ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let cell_a := M.alloc (| γ1_1 |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let cell_b := M.alloc (| γ1_1 |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "ne", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + cell_a + |), + "halo2_proofs::circuit::Cell", + "column" + |); + M.SubPointer.get_struct_record_field (| + M.read (| + cell_b + |), + "halo2_proofs::circuit::Cell", + "column" + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + [], + "cmp", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| cell_a |), + "halo2_proofs::circuit::Cell", + "column" + |); + M.SubPointer.get_struct_record_field (| + M.read (| cell_b |), + "halo2_proofs::circuit::Cell", + "column" + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path "usize", + [], + "cmp", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| cell_a |), + "halo2_proofs::circuit::Cell", + "row_offset" + |); + M.SubPointer.get_struct_record_field (| + M.read (| cell_b |), + "halo2_proofs::circuit::Cell", + "row_offset" + |) + ] + |) + |))) + ] + |) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.associated; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace" + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.associated; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace" + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]) + ]) + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.associated; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace" + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.associated; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace" + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]) + ]) + ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.associated; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace" + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.associated; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace" + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]) + ]) + ]), + [ Ty.tuple [] ], + "call", + [] + |), + [ constant_positions; Value.Tuple [] ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path + "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref", + [] + |), + [ constants ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.associated; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ + Ty.tuple + [ Ty.path "usize" ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace" + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ + Ty.tuple + [ Ty.path "usize" ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.associated; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ + Ty.tuple + [ Ty.path "usize" ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace" + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ + Ty.tuple + [ Ty.path "usize" ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "usize" + ]) + ]) + ]) + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path + "halo2_proofs::circuit::Cell" + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let γ2_0 := + M.SubPointer.get_tuple_field (| + γ1_0, + 0 + |) in + let γ2_1 := + M.SubPointer.get_tuple_field (| + γ1_0, + 1 + |) in + let fixed_column := M.copy (| γ2_0 |) in + let fixed_row := M.copy (| γ2_1 |) in + let γ1_1 := M.read (| γ1_1 |) in + let γ3_0 := + M.SubPointer.get_tuple_field (| + γ1_1, + 0 + |) in + let γ3_1 := + M.SubPointer.get_tuple_field (| + γ1_1, + 1 + |) in + let value := M.alloc (| γ3_0 |) in + let advice := M.alloc (| γ3_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "assign_fixed", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.function + [ Ty.tuple [] ] + (Ty.path + "alloc::string::String"); + Ty.path + "alloc::string::String" + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + plan, + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "cs" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "Constant(" + |); + M.read (| + Value.String + ")" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_debug", + [ + F + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ + F + ], + "evaluate", + [] + |), + [ + M.read (| + M.read (| + value + |) + |) + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| fixed_column |); + M.read (| fixed_row |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.read (| + M.read (| + value + |) + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "copy", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + plan, + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "cs" + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "into", + [] + |), + [ M.read (| fixed_column |) ] + |); + M.read (| fixed_row |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| advice |), + "halo2_proofs::circuit::Cell", + "column" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "halo2_proofs::circuit::RegionStart", + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::circuit::RegionStart"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + plan, + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "regions" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "halo2_proofs::circuit::RegionIndex", + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + advice + |), + "halo2_proofs::circuit::Cell", + "region_index" + |) + ] + |) + |) + ] + |) + ] + |) + |), + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| advice |), + "halo2_proofs::circuit::Cell", + "row_offset" + |) + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "halo2_proofs::plonk::circuit::FloorPlanner" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("synthesize", InstanceField.Method synthesize) ]. + End Impl_halo2_proofs_plonk_circuit_FloorPlanner_for_halo2_proofs_circuit_floor_planner_v1_V1. + + (* + Enum Pass + { + ty_params := [ "F"; "CS" ]; + variants := + [ + { + name := "Measurement"; + item := + StructTuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::MeasurementPassAssignment" + ] + ]; + discriminant := None; + }; + { + name := "Assignment"; + item := + StructTuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::v1::AssignmentPass") + [ F; CS ] + ] + ]; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_where_core_clone_Clone_CS_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_v1_Pass_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::v1::Pass") [ F; CS ]. + + (* Clone *) + Definition clone (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::circuit::floor_planner::v1::Pass::Measurement", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::circuit::floor_planner::v1::Pass::Measurement" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::MeasurementPassAssignment" + ], + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::circuit::floor_planner::v1::Pass::Assignment", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::circuit::floor_planner::v1::Pass::Assignment" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::v1::AssignmentPass") + [ F; CS ] + ], + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F CS) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F CS)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_where_core_clone_Clone_CS_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_v1_Pass_F_CS. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_where_core_fmt_Debug_CS_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_v1_Pass_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::v1::Pass") [ F; CS ]. + + (* Debug *) + Definition fmt (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::circuit::floor_planner::v1::Pass::Measurement", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Measurement" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::circuit::floor_planner::v1::Pass::Assignment", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Assignment" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F CS) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F CS)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_where_core_fmt_Debug_CS_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_v1_Pass_F_CS. + + (* StructTuple + { + name := "V1Pass"; + ty_params := [ "F"; "CS" ]; + fields := + [ Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::v1::Pass") [ F; CS ] ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_where_core_clone_Clone_CS_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_v1_V1Pass_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::v1::V1Pass") [ F; CS ]. + + (* Clone *) + Definition clone (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructTuple + "halo2_proofs::circuit::floor_planner::v1::V1Pass" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::v1::Pass") [ F; CS ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Pass", + 0 + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F CS) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F CS)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_where_core_clone_Clone_CS_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_v1_V1Pass_F_CS. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_where_core_fmt_Debug_CS_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_v1_V1Pass_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::v1::V1Pass") [ F; CS ]. + + (* Debug *) + Definition fmt (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "V1Pass" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Pass", + 0 + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F CS) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F CS)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_where_core_fmt_Debug_CS_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_v1_V1Pass_F_CS. + + Module Impl_core_marker_Send_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_v1_V1Pass_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::v1::V1Pass") [ F; CS ]. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "core::marker::Send" + (Self F CS) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Send_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_v1_V1Pass_F_CS. + + Module Impl_halo2_proofs_circuit_floor_planner_v1_V1Pass_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::v1::V1Pass") [ F; CS ]. + + (* + fn measure(pass: &'p mut MeasurementPassAssignment) -> Self { + V1Pass(Pass::Measurement(pass)) + } + *) + Definition measure (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ pass ] => + ltac:(M.monadic + (let pass := M.alloc (| pass |) in + Value.StructTuple + "halo2_proofs::circuit::floor_planner::v1::V1Pass" + [ + Value.StructTuple + "halo2_proofs::circuit::floor_planner::v1::Pass::Measurement" + [ M.read (| pass |) ] + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_measure : + forall (F CS : Ty.t), + M.IsAssociatedFunction (Self F CS) "measure" (measure F CS). + + (* + fn assign(pass: &'p mut AssignmentPass<'p, 'a, F, CS>) -> Self { + V1Pass(Pass::Assignment(pass)) + } + *) + Definition assign (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ pass ] => + ltac:(M.monadic + (let pass := M.alloc (| pass |) in + Value.StructTuple + "halo2_proofs::circuit::floor_planner::v1::V1Pass" + [ + Value.StructTuple + "halo2_proofs::circuit::floor_planner::v1::Pass::Assignment" + [ M.read (| pass |) ] + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F CS : Ty.t), + M.IsAssociatedFunction (Self F CS) "assign" (assign F CS). + End Impl_halo2_proofs_circuit_floor_planner_v1_V1Pass_F_CS. + + Module Impl_halo2_proofs_circuit_Layouter_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_F_for_halo2_proofs_circuit_floor_planner_v1_V1Pass_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::v1::V1Pass") [ F; CS ]. + + (* type Root = Self; *) + Definition _Root (F CS : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::v1::V1Pass") [ F; CS ]. + + (* + fn assign_region(&self, name: N, assignment: A) -> Result + where + A: Fn(&Region<'_, F>) -> Result, + N: Fn() -> NR, + NR: Into, + { + match &self.0 { + Pass::Measurement(pass) => pass.assign_region(name, assignment), + Pass::Assignment(pass) => pass.assign_region(name, assignment), + } + } + *) + Definition assign_region (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [ A; AR; N; NR ], [ self; name; assignment ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + let assignment := M.alloc (| assignment |) in + M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Pass", + 0 + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::circuit::floor_planner::v1::Pass::Measurement", + 0 + |) in + let pass := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::circuit::floor_planner::v1::MeasurementPassAssignment", + "assign_region", + [ F; A; AR; N; NR ] + |), + [ + M.read (| M.read (| pass |) |); + M.read (| name |); + M.read (| assignment |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::circuit::floor_planner::v1::Pass::Assignment", + 0 + |) in + let pass := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::v1::AssignmentPass") + [ F; CS ], + "assign_region", + [ A; AR; N; NR ] + |), + [ + M.read (| M.read (| pass |) |); + M.read (| name |); + M.read (| assignment |) + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + fn assign_table(&self, name: N, assignment: A) -> Result<(), Error> + where + A: Fn(Table<'_, F>) -> Result<(), Error>, + N: Fn() -> NR, + NR: Into, + { + match &self.0 { + Pass::Measurement(_) => Ok(()), + Pass::Assignment(pass) => pass.assign_table(name, assignment), + } + } + *) + Definition assign_table (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [ A; N; NR ], [ self; name; assignment ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + let assignment := M.alloc (| assignment |) in + M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Pass", + 0 + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::circuit::floor_planner::v1::Pass::Measurement", + 0 + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::circuit::floor_planner::v1::Pass::Assignment", + 0 + |) in + let pass := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::v1::AssignmentPass") + [ F; CS ], + "assign_table", + [ A; Ty.tuple []; N; NR ] + |), + [ + M.read (| M.read (| pass |) |); + M.read (| name |); + M.read (| assignment |) + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + fn constrain_instance( + &self, + cell: Cell, + instance: Column, + row: usize, + ) -> Result<(), Error> { + match &self.0 { + Pass::Measurement(_) => Ok(()), + Pass::Assignment(pass) => pass.constrain_instance(cell, instance, row), + } + } + *) + Definition constrain_instance (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; cell; instance; row ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let cell := M.alloc (| cell |) in + let instance := M.alloc (| instance |) in + let row := M.alloc (| row |) in + M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Pass", + 0 + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::circuit::floor_planner::v1::Pass::Measurement", + 0 + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::circuit::floor_planner::v1::Pass::Assignment", + 0 + |) in + let pass := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::v1::AssignmentPass") + [ F; CS ], + "constrain_instance", + [] + |), + [ + M.read (| M.read (| pass |) |); + M.read (| cell |); + M.read (| instance |); + M.read (| row |) + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + fn get_root(&self) -> &Self::Root { + self + } + *) + Definition get_root (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| self |))) + | _, _ => M.impossible + end. + + (* + fn push_namespace(&self, name_fn: N) + where + NR: Into, + N: FnOnce() -> NR, + { + if let Pass::Assignment(pass) = &self.0 { + pass.plan.cs.push_namespace(name_fn); + } + } + *) + Definition push_namespace (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [ NR; N ], [ self; name_fn ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name_fn := M.alloc (| name_fn |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Pass", + 0 + |) + |) in + let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::circuit::floor_planner::v1::Pass::Assignment", + 0 + |) in + let pass := M.alloc (| γ1_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "push_namespace", + [ NR; N ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| M.read (| pass |) |), + "halo2_proofs::circuit::floor_planner::v1::AssignmentPass", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "cs" + |) + |); + M.read (| name_fn |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + fn pop_namespace(&self, gadget_name: Option) { + if let Pass::Assignment(pass) = &self.0 { + pass.plan.cs.pop_namespace(gadget_name); + } + } + *) + Definition pop_namespace (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; gadget_name ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let gadget_name := M.alloc (| gadget_name |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Pass", + 0 + |) + |) in + let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::circuit::floor_planner::v1::Pass::Assignment", + 0 + |) in + let pass := M.alloc (| γ1_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "pop_namespace", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| M.read (| pass |) |), + "halo2_proofs::circuit::floor_planner::v1::AssignmentPass", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "cs" + |) + |); + M.read (| gadget_name |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "halo2_proofs::circuit::Layouter" + (Self F CS) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("Root", InstanceField.Ty (_Root F CS)); + ("assign_region", InstanceField.Method (assign_region F CS)); + ("assign_table", InstanceField.Method (assign_table F CS)); + ("constrain_instance", InstanceField.Method (constrain_instance F CS)); + ("get_root", InstanceField.Method (get_root F CS)); + ("push_namespace", InstanceField.Method (push_namespace F CS)); + ("pop_namespace", InstanceField.Method (pop_namespace F CS)) + ]. + End Impl_halo2_proofs_circuit_Layouter_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_F_for_halo2_proofs_circuit_floor_planner_v1_V1Pass_F_CS. + + (* StructRecord + { + name := "MeasurementPass"; + ty_params := []; + fields := + [ + ("regions", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionShape"; + Ty.path "alloc::alloc::Global" + ]); + ("regions_name", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ]) + ]; + } *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_circuit_floor_planner_v1_MeasurementPass. + Definition Self : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::v1::MeasurementPass". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "MeasurementPass" |); + M.read (| Value.String "regions" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::MeasurementPass", + "regions" + |)); + M.read (| Value.String "regions_name" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::MeasurementPass", + "regions_name" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_circuit_floor_planner_v1_MeasurementPass. + + (* StructRecord + { + name := "MeasurementPassAssignment"; + ty_params := []; + fields := + [ + ("regions", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_circuit_floor_planner_v1_MeasurementPassAssignment. + Definition Self : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::v1::MeasurementPassAssignment". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "MeasurementPassAssignment" |); + M.read (| Value.String "regions" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::MeasurementPassAssignment", + "regions" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_circuit_floor_planner_v1_MeasurementPassAssignment. + + Module Impl_core_convert_Into_halo2_proofs_circuit_floor_planner_v1_MeasurementPass_for_halo2_proofs_circuit_floor_planner_v1_MeasurementPassAssignment. + Definition Self : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::v1::MeasurementPassAssignment". + + (* + fn into(self) -> MeasurementPass { + let (regions, regions_name) = Arc::try_unwrap(self.regions).unwrap().into_inner().unwrap(); + + assert!(regions.iter().all(|region| region.is_some())); + + MeasurementPass { + regions: regions.into_iter().map(Option::unwrap).collect(), + regions_name, + } + } + *) + Definition into (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ], + "into_inner", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ]; + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "try_unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::circuit::floor_planner::v1::MeasurementPassAssignment", + "regions" + |) + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let regions := M.copy (| γ0_0 |) in + let regions_name := M.copy (| γ0_1 |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ] + ], + [], + "all", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ] + ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ regions ] + |) + ] + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let region := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ], + "is_some", + [] + |), + [ M.read (| region |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "assertion failed: regions.iter().all(|region| region.is_some())" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::circuit::floor_planner::v1::MeasurementPass" + [ + ("regions", + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ] + ] + (Ty.path "halo2_proofs::circuit::layouter::RegionShape") + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionShape"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.path "halo2_proofs::circuit::layouter::RegionShape"; + Ty.function + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ] + ] + (Ty.path "halo2_proofs::circuit::layouter::RegionShape") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| regions |) ] + |); + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" + ], + "unwrap", + [] + |) + ] + |) + ] + |)); + ("regions_name", M.read (| regions_name |)) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::Into" + Self + (* Trait polymorphic types *) + [ (* T *) Ty.path "halo2_proofs::circuit::floor_planner::v1::MeasurementPass" ] + (* Instance *) [ ("into", InstanceField.Method into) ]. + End Impl_core_convert_Into_halo2_proofs_circuit_floor_planner_v1_MeasurementPass_for_halo2_proofs_circuit_floor_planner_v1_MeasurementPassAssignment. + + Module Impl_halo2_proofs_circuit_floor_planner_v1_MeasurementPassAssignment. + Definition Self : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::v1::MeasurementPassAssignment". + + (* + fn new() -> Self { + MeasurementPassAssignment { + regions: Arc::new(Mutex::new((vec![], HashMap::default()))), + } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [] => + ltac:(M.monadic + (Value.StructRecord + "halo2_proofs::circuit::floor_planner::v1::MeasurementPassAssignment" + [ + ("regions", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ], + "new", + [] + |), + [ + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |); + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ], + [], + "default", + [] + |), + [] + |) + ] + ] + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + + (* + fn assign_region(&self, name: N, assignment: A) -> Result + where + A: Fn(&Region<'_, F>) -> Result, + N: Fn() -> NR, + NR: Into, + { + let name: String = name().into(); + + let mut regions = self.regions.lock().unwrap(); + let region_index = regions.0.len(); + regions.0.resize(region_index + 1, None); + assert!( + regions + .1 + .insert(name.clone(), region_index.into()) + .is_none(), + "The region name {} is already exist.", + name + ); + drop(regions); + + // Get shape of the region. + let shape = Parallel::new(RegionShape::new(region_index.into())); + let result = { + let region: &dyn RegionLayouter = &shape; + assignment(®ion.into()) + }?; + + let shape = shape.into_inner(); + + let mut regions = self.regions.lock().unwrap(); + regions.0[region_index] = Some(shape); + drop(regions); + + Ok(result) + } + *) + Definition assign_region (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F; A; AR; N; NR ], [ self; name; assignment ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + let assignment := M.alloc (| assignment |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let name := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + NR, + [ Ty.path "alloc::string::String" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + N, + [ Ty.tuple [] ], + "call", + [] + |), + [ name; Value.Tuple [] ] + |) + ] + |) + |) in + let regions := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::MeasurementPassAssignment", + "regions" + |) + ] + |) + ] + |) + ] + |) + |) in + let region_index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_tuple_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ], + [], + "deref", + [] + |), + [ regions ] + |), + 0 + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ]; + Ty.path "alloc::alloc::Global" + ], + "resize", + [] + |), + [ + M.SubPointer.get_tuple_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ], + [], + "deref_mut", + [] + |), + [ regions ] + |), + 0 + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| region_index |), + Value.Integer 1 + |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::circuit::RegionIndex" ], + "is_none", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + M.SubPointer.get_tuple_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path + "halo2_proofs::circuit::RegionIndex"; + Ty.path + "std::hash::random::RandomState" + ] + ] + ], + [], + "deref_mut", + [] + |), + [ regions ] + |), + 1 + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "alloc::string::String", + [], + "clone", + [] + |), + [ name ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "usize", + [ Ty.path "halo2_proofs::circuit::RegionIndex" + ], + "into", + [] + |), + [ M.read (| region_index |) ] + |) + ] + |) + |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic_fmt", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "The region name " |); + M.read (| Value.String " is already exist." |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "alloc::string::String" ] + |), + [ name ] + |) + ] + |)) + ] + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::mem::drop", + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ] + ] + |), + [ M.read (| regions |) ] + |) + |) in + let shape := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::circuit::layouter::RegionShape", + "new", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "usize", + [ Ty.path "halo2_proofs::circuit::RegionIndex" ], + "into", + [] + |), + [ M.read (| region_index |) ] + |) + ] + |) + ] + |) + |) in + let result := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ AR; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.read (| + let region := + M.alloc (| (* Unsize *) M.pointer_coercion shape |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + A, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::Region") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + assignment; + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("halo2_proofs::circuit::layouter::RegionLayouter::Trait", + []) + ] + ], + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::Region") + [ F ] + ], + "into", + [] + |), + [ M.read (| region |) ] + |) + |) + ] + ] + |) + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ AR; Ty.path "halo2_proofs::plonk::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let shape := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ], + "into_inner", + [] + |), + [ M.read (| shape |) ] + |) + |) in + let regions := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::MeasurementPassAssignment", + "regions" + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + M.SubPointer.get_tuple_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ], + [], + "deref_mut", + [] + |), + [ regions ] + |), + 0 + |); + M.read (| region_index |) + ] + |), + Value.StructTuple "core::option::Option::Some" [ M.read (| shape |) ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::mem::drop", + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ] + ] + ] + ] + |), + [ M.read (| regions |) ] + |) + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ M.read (| result |) ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_region : + M.IsAssociatedFunction Self "assign_region" assign_region. + End Impl_halo2_proofs_circuit_floor_planner_v1_MeasurementPassAssignment. + + (* StructRecord + { + name := "AssignmentPass"; + ty_params := [ "F"; "CS" ]; + fields := + [ + ("plan", + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::v1::V1Plan") [ F; CS ] + ]); + ("regions_name", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_where_core_fmt_Debug_CS_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_v1_AssignmentPass_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::v1::AssignmentPass") [ F; CS ]. + + (* Debug *) + Definition fmt (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AssignmentPass" |); + M.read (| Value.String "plan" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::AssignmentPass", + "plan" + |)); + M.read (| Value.String "regions_name" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::AssignmentPass", + "regions_name" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F CS) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F CS)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_where_core_fmt_Debug_CS_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_v1_AssignmentPass_F_CS. + + Module Impl_halo2_proofs_circuit_floor_planner_v1_AssignmentPass_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::v1::AssignmentPass") [ F; CS ]. + + (* + fn new(plan: &'p mut V1Plan<'a, F, CS>, regions_name: HashMap) -> Self { + AssignmentPass { plan, regions_name } + } + *) + Definition new (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ plan; regions_name ] => + ltac:(M.monadic + (let plan := M.alloc (| plan |) in + let regions_name := M.alloc (| regions_name |) in + Value.StructRecord + "halo2_proofs::circuit::floor_planner::v1::AssignmentPass" + [ ("plan", M.read (| plan |)); ("regions_name", M.read (| regions_name |)) ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F CS : Ty.t), + M.IsAssociatedFunction (Self F CS) "new" (new F CS). + + (* + fn region_from_name(&self, name: &str) -> usize { + *self.regions_name.get(name).unwrap().clone() + } + *) + Definition region_from_name (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; name ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "halo2_proofs::circuit::RegionIndex", + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::circuit::RegionIndex", + [], + "clone", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ Ty.path "halo2_proofs::circuit::RegionIndex" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "halo2_proofs::circuit::RegionIndex"; + Ty.path "std::hash::random::RandomState" + ], + "get", + [ Ty.path "str" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::AssignmentPass", + "regions_name" + |); + M.read (| name |) + ] + |) + ] + |) + ] + |) + |) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_region_from_name : + forall (F CS : Ty.t), + M.IsAssociatedFunction (Self F CS) "region_from_name" (region_from_name F CS). + + (* + fn assign_region(&self, name: N, assignment: A) -> Result + where + A: Fn(&Region<'_, F>) -> Result, + N: Fn() -> NR, + NR: Into, + { + // Get the next region we are assigning. + let region_index = self.region_from_name(&name().into()); + + self.plan.cs.enter_region(name); + let region = V1Region::new(self.plan, region_index.into()); + let result = { + let region: &dyn RegionLayouter = ®ion; + assignment(®ion.into()) + }?; + self.plan.cs.exit_region(); + + Ok(result) + } + *) + Definition assign_region (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [ A; AR; N; NR ], [ self; name; assignment ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + let assignment := M.alloc (| assignment |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let region_index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::v1::AssignmentPass") + [ F; CS ], + "region_from_name", + [] + |), + [ + M.read (| self |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "alloc::string::String", + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + NR, + [ Ty.path "alloc::string::String" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + N, + [ Ty.tuple [] ], + "call", + [] + |), + [ name; Value.Tuple [] ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "enter_region", + [ NR; N ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::AssignmentPass", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "cs" + |) + |); + M.read (| name |) + ] + |) + |) in + let region := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::v1::V1Region") + [ F; CS ], + "new", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::AssignmentPass", + "plan" + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "usize", + [ Ty.path "halo2_proofs::circuit::RegionIndex" ], + "into", + [] + |), + [ M.read (| region_index |) ] + |) + ] + |) + |) in + let result := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ AR; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.read (| + let region := + M.alloc (| (* Unsize *) M.pointer_coercion region |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + A, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::Region") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + assignment; + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("halo2_proofs::circuit::layouter::RegionLayouter::Trait", + []) + ] + ], + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::Region") + [ F ] + ], + "into", + [] + |), + [ M.read (| region |) ] + |) + |) + ] + ] + |) + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ AR; Ty.path "halo2_proofs::plonk::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "exit_region", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::AssignmentPass", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "cs" + |) + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ M.read (| result |) ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_region : + forall (F CS : Ty.t), + M.IsAssociatedFunction (Self F CS) "assign_region" (assign_region F CS). + + (* + fn assign_table(&self, name: N, assignment: A) -> Result + where + A: Fn(Table<'_, F>) -> Result, + N: Fn() -> NR, + NR: Into, + { + let mut table_columns = self.plan.table_columns.lock().unwrap(); + + // Maintenance hazard: there is near-duplicate code in `SingleChipLayouter::assign_table`. + + // Assign table cells. + self.plan.cs.enter_region(name); + let table = SimpleTableLayouter::new(self.plan.cs, &table_columns); + let result = { + let table: &dyn TableLayouter = &table; + assignment(table.into()) + }?; + let default_and_assigned = table.default_and_assigned.into_inner(); + self.plan.cs.exit_region(); + + // Check that all table columns have the same length `first_unused`, + // and all cells up to that length are assigned. + let first_unused = { + match default_and_assigned + .values() + .map(|(_, assigned)| { + if assigned.iter().all(|b| *b) { + Some(assigned.len()) + } else { + None + } + }) + .reduce(|acc, item| match (acc, item) { + (Some(a), Some(b)) if a == b => Some(a), + _ => None, + }) { + Some(Some(len)) => len, + _ => return Err(Error::Synthesis), // TODO better error + } + }; + + // Record these columns so that we can prevent them from being used again. + for column in default_and_assigned.keys() { + table_columns.push( *column); + } + + for (col, (default_val, _)) in default_and_assigned { + // default_val must be Some because we must have assigned + // at least one cell in each column, and in that case we checked + // that all cells up to first_unused were assigned. + self.plan + .cs + .fill_from_row(col.inner(), first_unused, default_val.unwrap())?; + } + + Ok(result) + } + *) + Definition assign_table (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [ A; AR; N; NR ], [ self; name; assignment ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + let assignment := M.alloc (| assignment |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let table_columns := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.path "alloc::alloc::Global" + ] + ], + "lock", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::AssignmentPass", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "table_columns" + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "enter_region", + [ NR; N ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::AssignmentPass", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "cs" + |) + |); + M.read (| name |) + ] + |) + |) in + let table := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::floor_planner::single_pass::SimpleTableLayouter") + [ F; CS ], + "new", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::AssignmentPass", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "cs" + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref", + [] + |), + [ table_columns ] + |) + ] + |) + ] + |) + |) in + let result := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ AR; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.read (| + let table := + M.alloc (| (* Unsize *) M.pointer_coercion table |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + A, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::Table") + [ F ] + ] + ], + "call", + [] + |), + [ + assignment; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("halo2_proofs::circuit::layouter::TableLayouter::Trait", + []) + ] + ], + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::Table") + [ F ] + ], + "into", + [] + |), + [ M.read (| table |) ] + |) + ] + ] + |) + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ AR; Ty.path "halo2_proofs::plonk::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let default_and_assigned := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "std::hash::random::RandomState" + ] + ], + "into_inner", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + table, + "halo2_proofs::circuit::floor_planner::single_pass::SimpleTableLayouter", + "default_and_assigned" + |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "exit_region", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::AssignmentPass", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "cs" + |) + |) + ] + |) + |) in + let first_unused := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "std::collections::hash::map::Values") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "usize" ]) + ], + [], + "reduce", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "usize" ] + ] + ] + (Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "std::collections::hash::map::Values") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ] + ], + [], + "map", + [ + Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "usize" ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "std::hash::random::RandomState" + ], + "values", + [] + |), + [ default_and_assigned ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let assigned := M.alloc (| γ1_1 |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.path "bool" ], + [], + "all", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "bool" + ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "bool" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "bool"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + assigned + |) + ] + |) + ] + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let b := + M.copy (| + γ + |) in + M.read (| + M.read (| + b + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| assigned |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let item := M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.read (| acc |); + M.read (| item |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "core::option::Option::Some", + 0 + |) in + let a := M.copy (| γ1_0 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "core::option::Option::Some", + 0 + |) in + let b := M.copy (| γ1_0 |) in + let γ := + M.alloc (| + BinOp.Pure.eq + (M.read (| a |)) + (M.read (| b |)) + |) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ M.read (| a |) ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))) + ] + |) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "core::option::Option::Some", + 0 + |) in + let len := M.copy (| γ1_0 |) in + len)); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "halo2_proofs::plonk::error::Error::Synthesis" + [] + ] + |) + |) + |) + |))) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "std::collections::hash::map::Keys") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "std::hash::random::RandomState" + ], + "keys", + [] + |), + [ default_and_assigned ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "std::collections::hash::map::Keys") + [ + Ty.path + "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let column := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::circuit::TableColumn"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::circuit::TableColumn"; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref_mut", + [] + |), + [ table_columns ] + |); + M.read (| M.read (| column |) |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "std::hash::random::RandomState" + ], + [], + "into_iter", + [] + |), + [ M.read (| default_and_assigned |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "std::collections::hash::map::IntoIter") + [ + Ty.path + "halo2_proofs::plonk::circuit::TableColumn"; + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let col := M.copy (| γ1_0 |) in + let γ2_0 := + M.SubPointer.get_tuple_field (| γ1_1, 0 |) in + let γ2_1 := + M.SubPointer.get_tuple_field (| γ1_1, 1 |) in + let default_val := M.copy (| γ2_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "fill_from_row", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::AssignmentPass", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "cs" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::plonk::circuit::TableColumn", + "inner", + [] + |), + [ col ] + |); + M.read (| first_unused |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ], + "unwrap", + [] + |), + [ M.read (| default_val |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + AR; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ M.read (| result |) ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_table : + forall (F CS : Ty.t), + M.IsAssociatedFunction (Self F CS) "assign_table" (assign_table F CS). + + (* + fn constrain_instance( + &self, + cell: Cell, + instance: Column, + row: usize, + ) -> Result<(), Error> { + self.plan.cs.copy( + cell.column, + *self.plan.regions[*cell.region_index] + cell.row_offset, + instance.into(), + row, + ) + } + *) + Definition constrain_instance (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; cell; instance; row ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let cell := M.alloc (| cell |) in + let instance := M.alloc (| instance |) in + let row := M.alloc (| row |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "copy", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::AssignmentPass", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "cs" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + cell, + "halo2_proofs::circuit::Cell", + "column" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "halo2_proofs::circuit::RegionStart", + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::AssignmentPass", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "regions" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "halo2_proofs::circuit::RegionIndex", + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cell, + "halo2_proofs::circuit::Cell", + "region_index" + |) + ] + |) + |) + ] + |) + ] + |) + |), + M.read (| + M.SubPointer.get_struct_record_field (| + cell, + "halo2_proofs::circuit::Cell", + "row_offset" + |) + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "into", + [] + |), + [ M.read (| instance |) ] + |); + M.read (| row |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_constrain_instance : + forall (F CS : Ty.t), + M.IsAssociatedFunction (Self F CS) "constrain_instance" (constrain_instance F CS). + End Impl_halo2_proofs_circuit_floor_planner_v1_AssignmentPass_F_CS. + + (* StructRecord + { + name := "V1Region"; + ty_params := [ "F"; "CS" ]; + fields := + [ + ("plan", + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::v1::V1Plan") [ F; CS ] + ]); + ("region_index", Ty.path "halo2_proofs::circuit::RegionIndex") + ]; + } *) + + Module Impl_core_fmt_Debug_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_v1_V1Region_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::v1::V1Region") [ F; CS ]. + + (* + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("V1Region") + .field("plan", &self.plan) + .field("region_index", &self.region_index) + .finish() + } + *) + Definition fmt (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::builders::DebugStruct", + "finish", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::builders::DebugStruct", + "field", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::builders::DebugStruct", + "field", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct", + [] + |), + [ M.read (| f |); M.read (| Value.String "V1Region" |) ] + |) + |); + M.read (| Value.String "plan" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Region", + "plan" + |)) + ] + |); + M.read (| Value.String "region_index" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Region", + "region_index" + |)) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F CS) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F CS)) ]. + End Impl_core_fmt_Debug_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_for_halo2_proofs_circuit_floor_planner_v1_V1Region_F_CS. + + Module Impl_halo2_proofs_circuit_floor_planner_v1_V1Region_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::v1::V1Region") [ F; CS ]. + + (* + fn new(plan: &'r V1Plan<'a, F, CS>, region_index: RegionIndex) -> Self { + V1Region { plan, region_index } + } + *) + Definition new (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ plan; region_index ] => + ltac:(M.monadic + (let plan := M.alloc (| plan |) in + let region_index := M.alloc (| region_index |) in + Value.StructRecord + "halo2_proofs::circuit::floor_planner::v1::V1Region" + [ ("plan", M.read (| plan |)); ("region_index", M.read (| region_index |)) ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F CS : Ty.t), + M.IsAssociatedFunction (Self F CS) "new" (new F CS). + End Impl_halo2_proofs_circuit_floor_planner_v1_V1Region_F_CS. + + Module Impl_halo2_proofs_circuit_layouter_RegionLayouter_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_F_for_halo2_proofs_circuit_floor_planner_v1_V1Region_F_CS. + Definition Self (F CS : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::circuit::floor_planner::v1::V1Region") [ F; CS ]. + + (* + fn enable_selector<'v>( + &'v self, + annotation: &'v (dyn Fn() -> String + 'v), + selector: &Selector, + offset: usize, + ) -> Result<(), Error> { + self.plan.cs.enable_selector( + annotation, + selector, + *self.plan.regions[*self.region_index] + offset, + ) + } + *) + Definition enable_selector (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; annotation; selector; offset ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let annotation := M.alloc (| annotation |) in + let selector := M.alloc (| selector |) in + let offset := M.alloc (| offset |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "enable_selector", + [ + Ty.apply (Ty.path "&") [ Ty.dyn [ ("core::ops::function::Fn::Trait", []) ] ]; + Ty.path "alloc::string::String" + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Region", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "cs" + |) + |); + M.read (| annotation |); + M.read (| selector |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "halo2_proofs::circuit::RegionStart", + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Region", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "regions" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "halo2_proofs::circuit::RegionIndex", + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Region", + "region_index" + |) + ] + |) + |) + ] + |) + ] + |) + |), + M.read (| offset |) + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign_advice<'v>( + &'v self, + annotation: &'v (dyn Fn() -> String + 'v), + column: Column, + offset: usize, + to: &'v mut (dyn FnMut() -> Result, Error> + 'v), + ) -> Result { + self.plan.cs.assign_advice( + annotation, + column, + *self.plan.regions[*self.region_index] + offset, + to, + )?; + + Ok(Cell { + region_index: self.region_index, + row_offset: offset, + column: column.into(), + }) + } + *) + Definition assign_advice (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; annotation; column; offset; to ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let annotation := M.alloc (| annotation |) in + let column := M.alloc (| column |) in + let offset := M.alloc (| offset |) in + let to := M.alloc (| to |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "assign_advice", + [ + Ty.apply + (Ty.path "&mut") + [ Ty.dyn [ ("core::ops::function::FnMut::Trait", []) ] ]; + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.apply + (Ty.path "&") + [ Ty.dyn [ ("core::ops::function::Fn::Trait", []) ] ]; + Ty.path "alloc::string::String" + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Region", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "cs" + |) + |); + M.read (| annotation |); + M.read (| column |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "halo2_proofs::circuit::RegionStart", + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Region", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "regions" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "halo2_proofs::circuit::RegionIndex", + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Region", + "region_index" + |) + ] + |) + |) + ] + |) + ] + |) + |), + M.read (| offset |) + |); + M.read (| to |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::circuit::Cell" + [ + ("region_index", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Region", + "region_index" + |) + |)); + ("row_offset", M.read (| offset |)); + ("column", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "into", + [] + |), + [ M.read (| column |) ] + |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn assign_advice_from_constant<'v>( + &'v self, + annotation: &'v (dyn Fn() -> String + 'v), + column: Column, + offset: usize, + constant: Assigned, + ) -> Result { + let advice = self.assign_advice(annotation, column, offset, &mut || Ok(constant))?; + self.constrain_constant(advice, constant)?; + + Ok(advice) + } + *) + Definition assign_advice_from_constant + (F CS : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; annotation; column; offset; constant ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let annotation := M.alloc (| annotation |) in + let column := M.alloc (| column |) in + let offset := M.alloc (| offset |) in + let constant := M.alloc (| constant |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let advice := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::layouter::RegionLayouter", + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::v1::V1Region") + [ F; CS ], + [ F ], + "assign_advice", + [] + |), + [ + M.read (| self |); + (* Unsize *) M.pointer_coercion (M.read (| annotation |)); + M.read (| column |); + M.read (| offset |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ M.read (| constant |) ])) + ] + |) + | _ => M.impossible (||) + end)) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::layouter::RegionLayouter", + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::v1::V1Region") + [ F; CS ], + [ F ], + "constrain_constant", + [] + |), + [ M.read (| self |); M.read (| advice |); M.read (| constant |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ M.read (| advice |) ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn assign_advice_from_instance<'v>( + &self, + annotation: &'v (dyn Fn() -> String + 'v), + instance: Column, + row: usize, + advice: Column, + offset: usize, + ) -> Result<(Cell, Option), Error> { + let value = self.plan.cs.query_instance(instance, row)?; + + let cell = self.assign_advice(annotation, advice, offset, &mut || { + value.ok_or(Error::Synthesis).map(|v| v.into()) + })?; + + self.plan.cs.copy( + cell.column, + *self.plan.regions[*cell.region_index] + cell.row_offset, + instance.into(), + row, + )?; + + Ok((cell, value)) + } + *) + Definition assign_advice_from_instance + (F CS : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; annotation; instance; row; advice; offset ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let annotation := M.alloc (| annotation |) in + let instance := M.alloc (| instance |) in + let row := M.alloc (| row |) in + let advice := M.alloc (| advice |) in + let offset := M.alloc (| offset |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let value := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "core::option::Option") [ F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "query_instance", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Region", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "cs" + |) + |); + M.read (| instance |); + M.read (| row |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.apply (Ty.path "core::option::Option") [ F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let cell := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::layouter::RegionLayouter", + Ty.apply + (Ty.path "halo2_proofs::circuit::floor_planner::v1::V1Region") + [ F; CS ], + [ F ], + "assign_advice", + [] + |), + [ + M.read (| self |); + (* Unsize *) M.pointer_coercion (M.read (| annotation |)); + M.read (| advice |); + M.read (| offset |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.function + [ Ty.tuple [ F ] ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ F ], + "ok_or", + [ + Ty.path + "halo2_proofs::plonk::error::Error" + ] + |), + [ + M.read (| value |); + Value.StructTuple + "halo2_proofs::plonk::error::Error::Synthesis" + [] + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let v := + M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + F, + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ], + "into", + [] + |), + [ M.read (| v |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.apply (Ty.path "core::option::Option") [ F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "copy", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Region", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "cs" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + cell, + "halo2_proofs::circuit::Cell", + "column" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "halo2_proofs::circuit::RegionStart", + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Region", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "regions" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "halo2_proofs::circuit::RegionIndex", + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cell, + "halo2_proofs::circuit::Cell", + "region_index" + |) + ] + |) + |) + ] + |) + ] + |) + |), + M.read (| + M.SubPointer.get_struct_record_field (| + cell, + "halo2_proofs::circuit::Cell", + "row_offset" + |) + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "into", + [] + |), + [ M.read (| instance |) ] + |); + M.read (| row |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.apply (Ty.path "core::option::Option") [ F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [ M.read (| cell |); M.read (| value |) ] ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn assign_fixed<'v>( + &'v self, + annotation: &'v (dyn Fn() -> String + 'v), + column: Column, + offset: usize, + to: &'v mut (dyn FnMut() -> Result, Error> + 'v), + ) -> Result { + self.plan.cs.assign_fixed( + annotation, + column, + *self.plan.regions[*self.region_index] + offset, + to, + )?; + + Ok(Cell { + region_index: self.region_index, + row_offset: offset, + column: column.into(), + }) + } + *) + Definition assign_fixed (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; annotation; column; offset; to ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let annotation := M.alloc (| annotation |) in + let column := M.alloc (| column |) in + let offset := M.alloc (| offset |) in + let to := M.alloc (| to |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "assign_fixed", + [ + Ty.apply + (Ty.path "&mut") + [ Ty.dyn [ ("core::ops::function::FnMut::Trait", []) ] ]; + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.apply + (Ty.path "&") + [ Ty.dyn [ ("core::ops::function::Fn::Trait", []) ] ]; + Ty.path "alloc::string::String" + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Region", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "cs" + |) + |); + M.read (| annotation |); + M.read (| column |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "halo2_proofs::circuit::RegionStart", + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Region", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "regions" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "halo2_proofs::circuit::RegionIndex", + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Region", + "region_index" + |) + ] + |) + |) + ] + |) + ] + |) + |), + M.read (| offset |) + |); + M.read (| to |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::circuit::Cell"; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::circuit::Cell" + [ + ("region_index", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Region", + "region_index" + |) + |)); + ("row_offset", M.read (| offset |)); + ("column", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "into", + [] + |), + [ M.read (| column |) ] + |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn constrain_constant(&self, cell: Cell, constant: Assigned) -> Result<(), Error> { + let mut constants = self.plan.constants.lock().unwrap(); + constants.push((constant, cell)); + Ok(()) + } + *) + Definition constrain_constant (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; cell; constant ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let cell := M.alloc (| cell |) in + let constant := M.alloc (| constant |) in + M.read (| + let constants := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "lock", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Region", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "constants" + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::circuit::Cell" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref_mut", + [] + |), + [ constants ] + |); + Value.Tuple [ M.read (| constant |); M.read (| cell |) ] + ] + |) + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + | _, _ => M.impossible + end. + + (* + fn constrain_equal(&self, left: Cell, right: Cell) -> Result<(), Error> { + self.plan.cs.copy( + left.column, + *self.plan.regions[*left.region_index] + left.row_offset, + right.column, + *self.plan.regions[*right.region_index] + right.row_offset, + )?; + + Ok(()) + } + *) + Definition constrain_equal (F CS : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F CS in + match τ, α with + | [], [ self; _ as left; _ as right ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let left := M.alloc (| left |) in + let right := M.alloc (| right |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + CS, + [ F ], + "copy", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Region", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "cs" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + left, + "halo2_proofs::circuit::Cell", + "column" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "halo2_proofs::circuit::RegionStart", + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Region", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "regions" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "halo2_proofs::circuit::RegionIndex", + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + left, + "halo2_proofs::circuit::Cell", + "region_index" + |) + ] + |) + |) + ] + |) + ] + |) + |), + M.read (| + M.SubPointer.get_struct_record_field (| + left, + "halo2_proofs::circuit::Cell", + "row_offset" + |) + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + right, + "halo2_proofs::circuit::Cell", + "column" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "halo2_proofs::circuit::RegionStart", + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::V1Region", + "plan" + |) + |), + "halo2_proofs::circuit::floor_planner::v1::V1Plan", + "regions" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "halo2_proofs::circuit::RegionIndex", + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + right, + "halo2_proofs::circuit::Cell", + "region_index" + |) + ] + |) + |) + ] + |) + ] + |) + |), + M.read (| + M.SubPointer.get_struct_record_field (| + right, + "halo2_proofs::circuit::Cell", + "row_offset" + |) + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F CS : Ty.t), + M.IsTraitInstance + "halo2_proofs::circuit::layouter::RegionLayouter" + (Self F CS) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("enable_selector", InstanceField.Method (enable_selector F CS)); + ("assign_advice", InstanceField.Method (assign_advice F CS)); + ("assign_advice_from_constant", + InstanceField.Method (assign_advice_from_constant F CS)); + ("assign_advice_from_instance", + InstanceField.Method (assign_advice_from_instance F CS)); + ("assign_fixed", InstanceField.Method (assign_fixed F CS)); + ("constrain_constant", InstanceField.Method (constrain_constant F CS)); + ("constrain_equal", InstanceField.Method (constrain_equal F CS)) + ]. + End Impl_halo2_proofs_circuit_layouter_RegionLayouter_where_ff_Field_F_where_halo2_proofs_plonk_circuit_Assignment_CS_F_F_for_halo2_proofs_circuit_floor_planner_v1_V1Region_F_CS. + End v1. + End floor_planner. +End circuit. diff --git a/CoqOfRust/halo2_proofs/circuit/floor_planner/v1/strategy.v b/CoqOfRust/halo2_proofs/circuit/floor_planner/v1/strategy.v new file mode 100644 index 000000000..2ad401a74 --- /dev/null +++ b/CoqOfRust/halo2_proofs/circuit/floor_planner/v1/strategy.v @@ -0,0 +1,3196 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuit. + Module floor_planner. + Module v1. + Module strategy. + (* StructRecord + { + name := "AllocatedRegion"; + ty_params := []; + fields := [ ("start", Ty.path "usize"); ("length", Ty.path "usize") ]; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_circuit_floor_planner_v1_strategy_AllocatedRegion. + Definition Self : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + [ + ("start", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "usize", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion", + "start" + |) + ] + |)); + ("length", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "usize", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion", + "length" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_circuit_floor_planner_v1_strategy_AllocatedRegion. + + Module Impl_core_default_Default_for_halo2_proofs_circuit_floor_planner_v1_strategy_AllocatedRegion. + Definition Self : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion". + + (* Default *) + Definition default (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [] => + ltac:(M.monadic + (Value.StructRecord + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + [ + ("start", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.path "usize", + [], + "default", + [] + |), + [] + |)); + ("length", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.path "usize", + [], + "default", + [] + |), + [] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::default::Default" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("default", InstanceField.Method default) ]. + End Impl_core_default_Default_for_halo2_proofs_circuit_floor_planner_v1_strategy_AllocatedRegion. + + Module Impl_core_fmt_Debug_for_halo2_proofs_circuit_floor_planner_v1_strategy_AllocatedRegion. + Definition Self : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AllocatedRegion" |); + M.read (| Value.String "start" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion", + "start" + |)); + M.read (| Value.String "length" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion", + "length" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_circuit_floor_planner_v1_strategy_AllocatedRegion. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_circuit_floor_planner_v1_strategy_AllocatedRegion. + Definition Self : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_circuit_floor_planner_v1_strategy_AllocatedRegion. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_circuit_floor_planner_v1_strategy_AllocatedRegion. + Definition Self : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + LogicalOp.and (| + BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion", + "start" + |) + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion", + "start" + |) + |)), + ltac:(M.monadic + (BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion", + "length" + |) + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion", + "length" + |) + |)))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_circuit_floor_planner_v1_strategy_AllocatedRegion. + + Module Impl_core_marker_StructuralEq_for_halo2_proofs_circuit_floor_planner_v1_strategy_AllocatedRegion. + Definition Self : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralEq_for_halo2_proofs_circuit_floor_planner_v1_strategy_AllocatedRegion. + + Module Impl_core_cmp_Eq_for_halo2_proofs_circuit_floor_planner_v1_strategy_AllocatedRegion. + Definition Self : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion". + + (* Eq *) + Definition assert_receiver_is_total_eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Eq" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("assert_receiver_is_total_eq", InstanceField.Method assert_receiver_is_total_eq) ]. + End Impl_core_cmp_Eq_for_halo2_proofs_circuit_floor_planner_v1_strategy_AllocatedRegion. + + Module Impl_core_cmp_Ord_for_halo2_proofs_circuit_floor_planner_v1_strategy_AllocatedRegion. + Definition Self : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion". + + (* + fn cmp(&self, other: &Self) -> cmp::Ordering { + self.start.cmp(&other.start) + } + *) + Definition cmp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.call_closure (| + M.get_trait_method (| "core::cmp::Ord", Ty.path "usize", [], "cmp", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion", + "start" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion", + "start" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Ord" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("cmp", InstanceField.Method cmp) ]. + End Impl_core_cmp_Ord_for_halo2_proofs_circuit_floor_planner_v1_strategy_AllocatedRegion. + + Module Impl_core_cmp_PartialOrd_for_halo2_proofs_circuit_floor_planner_v1_strategy_AllocatedRegion. + Definition Self : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion". + + (* + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } + *) + Definition partial_cmp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion", + [], + "cmp", + [] + |), + [ M.read (| self |); M.read (| other |) ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialOrd" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("partial_cmp", InstanceField.Method partial_cmp) ]. + End Impl_core_cmp_PartialOrd_for_halo2_proofs_circuit_floor_planner_v1_strategy_AllocatedRegion. + + (* StructRecord + { + name := "EmptySpace"; + ty_params := []; + fields := + [ + ("start", Ty.path "usize"); + ("end_", Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ]) + ]; + } *) + + Module Impl_halo2_proofs_circuit_floor_planner_v1_strategy_EmptySpace. + Definition Self : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace". + + (* + pub(crate) fn range(&self) -> Option> { + self.end.map(|end| self.start..end) + } + *) + Definition range (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ], + "map", + [ + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ]) + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace", + "end" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let end_ := M.copy (| γ |) in + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace", + "start" + |) + |)); + ("end_", M.read (| end_ |)) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_range : M.IsAssociatedFunction Self "range" range. + End Impl_halo2_proofs_circuit_floor_planner_v1_strategy_EmptySpace. + + (* StructTuple + { + name := "Allocations"; + ty_params := []; + fields := + [ + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.path "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion"; + Ty.path "alloc::alloc::Global" + ] + ]; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_circuit_floor_planner_v1_strategy_Allocations. + Definition Self : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructTuple + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations", + 0 + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_circuit_floor_planner_v1_strategy_Allocations. + + Module Impl_core_default_Default_for_halo2_proofs_circuit_floor_planner_v1_strategy_Allocations. + Definition Self : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations". + + (* Default *) + Definition default (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [] => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + [ + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion"; + Ty.path "alloc::alloc::Global" + ], + [], + "default", + [] + |), + [] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::default::Default" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("default", InstanceField.Method default) ]. + End Impl_core_default_Default_for_halo2_proofs_circuit_floor_planner_v1_strategy_Allocations. + + Module Impl_core_fmt_Debug_for_halo2_proofs_circuit_floor_planner_v1_strategy_Allocations. + Definition Self : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Allocations" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations", + 0 + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_circuit_floor_planner_v1_strategy_Allocations. + + Module Impl_halo2_proofs_circuit_floor_planner_v1_strategy_Allocations. + Definition Self : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations". + + (* + pub(crate) fn unbounded_interval_start(&self) -> usize { + self.0 + .iter() + .last() + .map(|r| r.start + r.length) + .unwrap_or(0) + } + *) + Definition unbounded_interval_start (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ] + ], + "map", + [ + Ty.path "usize"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ] + ] + ] + (Ty.path "usize") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::collections::btree::set::Iter") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ], + [], + "last", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion"; + Ty.path "alloc::alloc::Global" + ], + "iter", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations", + 0 + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let r := M.copy (| γ |) in + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| r |), + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion", + "start" + |) + |), + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| r |), + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion", + "length" + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + Value.Integer 0 + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_unbounded_interval_start : + M.IsAssociatedFunction Self "unbounded_interval_start" unbounded_interval_start. + + (* + pub(crate) fn free_intervals( + &self, + start: usize, + end: Option, + ) -> impl Iterator + '_ { + self.0 + .iter() + .map(Some) + .chain(Some(None)) + .scan(start, move |row, region| { + Some(if let Some(region) = region { + if end.map(|end| region.start >= end).unwrap_or(false) { + None + } else { + let ret = if *row < region.start { + Some(EmptySpace { + start: *row, + end: Some(region.start), + }) + } else { + None + }; + + *row = cmp::max( *row, region.start + region.length); + + ret + } + } else if end.map(|end| *row < end).unwrap_or(true) { + Some(EmptySpace { start: *row, end }) + } else { + None + }) + }) + .flatten() + } + *) + Definition free_intervals (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; start; end_ ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let start := M.alloc (| start |) in + let end_ := M.alloc (| end_ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::scan::Scan") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::collections::btree::set::Iter") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ]; + Ty.function + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ] + ]) + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ] + ] + ] + ]; + Ty.path "usize"; + Ty.function + [ + Ty.tuple + [ + Ty.apply (Ty.path "&mut") [ Ty.path "usize" ]; + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace" + ] + ]) + ], + [], + "flatten", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::collections::btree::set::Iter") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ]; + Ty.function + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ] + ]) + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ] + ] + ] + ], + [], + "scan", + [ + Ty.path "usize"; + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply (Ty.path "&mut") [ Ty.path "usize" ]; + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace" + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::collections::btree::set::Iter") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ]; + Ty.function + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ] + ]) + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ] + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::collections::btree::set::Iter") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ], + [], + "map", + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ] + ]; + Ty.function + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion"; + Ty.path "alloc::alloc::Global" + ], + "iter", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations", + 0 + |) + ] + |); + M.constructor_as_closure "core::option::Option::Some" + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ Value.StructTuple "core::option::Option::None" [] ] + ] + |); + M.read (| start |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let row := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let region := M.copy (| γ |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := region in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let region := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ Ty.path "bool" + ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "usize" + ], + "map", + [ + Ty.path + "bool"; + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize" + ] + ] + (Ty.path + "bool") + ] + |), + [ + M.read (| + end_ + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + end_ := + M.copy (| + γ + |) in + BinOp.Pure.ge + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + region + |), + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion", + "start" + |) + |)) + (M.read (| + end_ + |)))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |); + Value.Bool false + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))); + fun γ => + ltac:(M.monadic + (let ret := + M.copy (| + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (M.read (| + M.read (| + row + |) + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + region + |), + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion", + "start" + |) + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace" + [ + ("start", + M.read (| + M.read (| + row + |) + |)); + ("end_", + Value.StructTuple + "core::option::Option::Some" + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + region + |), + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion", + "start" + |) + |) + ]) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))) + ] + |) + |) in + let _ := + M.write (| + M.read (| row |), + M.call_closure (| + M.get_function (| + "core::cmp::max", + [ Ty.path "usize" ] + |), + [ + M.read (| + M.read (| row |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + region + |), + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion", + "start" + |) + |), + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + region + |), + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion", + "length" + |) + |) + |) + ] + |) + |) in + ret)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ Ty.path "bool" + ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "usize" + ], + "map", + [ + Ty.path + "bool"; + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize" + ] + ] + (Ty.path + "bool") + ] + |), + [ + M.read (| + end_ + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + end_ := + M.copy (| + γ + |) in + BinOp.Pure.lt + (M.read (| + M.read (| + row + |) + |)) + (M.read (| + end_ + |)))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |); + Value.Bool true + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace" + [ + ("start", + M.read (| + M.read (| row |) + |)); + ("end_", + M.read (| end_ |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))) + ] + |))) + ] + |) + |) + ])) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_free_intervals : + M.IsAssociatedFunction Self "free_intervals" free_intervals. + End Impl_halo2_proofs_circuit_floor_planner_v1_strategy_Allocations. + + Axiom CircuitAllocations : + (Ty.path "halo2_proofs::circuit::floor_planner::v1::strategy::CircuitAllocations") = + (Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations"; + Ty.path "std::hash::random::RandomState" + ]). + + (* + fn first_fit_region( + column_allocations: &mut CircuitAllocations, + region_columns: &[RegionColumn], + region_length: usize, + start: usize, + slack: Option, + ) -> Option { + let (c, remaining_columns) = match region_columns.split_first() { + Some(cols) => cols, + None => return Some(start), + }; + let end = slack.map(|slack| start + region_length + slack); + + // Iterate over the unallocated non-empty intervals in c that intersect [start, end). + for space in column_allocations + .entry( *c) + .or_default() + .clone() + .free_intervals(start, end) + { + // Do we have enough room for this column of the region in this interval? + let s_slack = space + .end + .map(|end| (end as isize - space.start as isize) - region_length as isize); + if let Some((slack, s_slack)) = slack.zip(s_slack) { + assert!(s_slack <= slack as isize); + } + if s_slack.unwrap_or(0) >= 0 { + let row = first_fit_region( + column_allocations, + remaining_columns, + region_length, + space.start, + s_slack.map(|s| s as usize), + ); + if let Some(row) = row { + if let Some(end) = end { + assert!(row + region_length <= end); + } + column_allocations + .get_mut(c) + .unwrap() + .0 + .insert(AllocatedRegion { + start: row, + length: region_length, + }); + return Some(row); + } + } + } + + // No placement worked; the caller will need to try other possibilities. + None + } + *) + Definition first_fit_region (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ column_allocations; region_columns; region_length; start; slack ] => + ltac:(M.monadic + (let column_allocations := M.alloc (| column_allocations |) in + let region_columns := M.alloc (| region_columns |) in + let region_length := M.alloc (| region_length |) in + let start := M.alloc (| start |) in + let slack := M.alloc (| slack |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "halo2_proofs::circuit::layouter::RegionColumn" ], + "split_first", + [] + |), + [ M.read (| region_columns |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let cols := M.copy (| γ0_0 |) in + cols)); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::option::Option::Some" + [ M.read (| start |) ] + |) + |) + |) + |))) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let c := M.copy (| γ0_0 |) in + let remaining_columns := M.copy (| γ0_1 |) in + let end_ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ], + "map", + [ + Ty.path "usize"; + Ty.function [ Ty.tuple [ Ty.path "usize" ] ] (Ty.path "usize") + ] + |), + [ + M.read (| slack |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let slack := M.copy (| γ |) in + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.read (| start |), + M.read (| region_length |) + |), + M.read (| slack |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.associated, + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations", + "free_intervals", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations", + [], + "clone", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::collections::hash::map::Entry") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ], + "or_default", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations"; + Ty.path + "std::hash::random::RandomState" + ], + "entry", + [] + |), + [ + M.read (| column_allocations |); + M.read (| M.read (| c |) |) + ] + |) + ] + |) + ] + |) + |); + M.read (| start |); + M.read (| end_ |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.associated, + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let space := M.copy (| γ0_0 |) in + let s_slack := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "usize" ], + "map", + [ + Ty.path "isize"; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.path "isize") + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + space, + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace", + "end" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let end_ := + M.copy (| γ |) in + BinOp.Panic.sub (| + Integer.Isize, + BinOp.Panic.sub (| + Integer.Isize, + M.rust_cast + (M.read (| + end_ + |)), + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + space, + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace", + "start" + |) + |)) + |), + M.rust_cast + (M.read (| + region_length + |)) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ Ty.path "usize" ], + "zip", + [ Ty.path "isize" ] + |), + [ + M.read (| slack |); + M.read (| s_slack |) + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let slack := M.copy (| γ1_0 |) in + let s_slack := M.copy (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.le + (M.read (| + s_slack + |)) + (M.rust_cast + (M.read (| + slack + |)))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic", + [] + |), + [ + M.read (| + Value.String + "assertion failed: s_slack <= slack as isize" + |) + ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ge + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ Ty.path "isize" ], + "unwrap_or", + [] + |), + [ + M.read (| s_slack |); + Value.Integer 0 + ] + |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let row := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::circuit::floor_planner::v1::strategy::first_fit_region", + [] + |), + [ + M.read (| + column_allocations + |); + M.read (| + remaining_columns + |); + M.read (| region_length |); + M.read (| + M.SubPointer.get_struct_record_field (| + space, + "halo2_proofs::circuit::floor_planner::v1::strategy::EmptySpace", + "start" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ Ty.path "isize" ], + "map", + [ + Ty.path "usize"; + Ty.function + [ + Ty.tuple + [ Ty.path "isize" + ] + ] + (Ty.path "usize") + ] + |), + [ + M.read (| s_slack |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let s := + M.copy (| + γ + |) in + M.rust_cast + (M.read (| + s + |)))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := row in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let row := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + end_ in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let end_ := + M.copy (| + γ0_0 + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.le + (BinOp.Panic.add (| + Integer.Usize, + M.read (| + row + |), + M.read (| + region_length + |) + |)) + (M.read (| + end_ + |))) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic", + [] + |), + [ + M.read (| + Value.String + "assertion failed: row + region_length <= end" + |) + ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion"; + Ty.path + "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations"; + Ty.path + "std::hash::random::RandomState" + ], + "get_mut", + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn" + ] + |), + [ + M.read (| + column_allocations + |); + M.read (| + c + |) + ] + |) + ] + |), + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations", + 0 + |); + Value.StructRecord + "halo2_proofs::circuit::floor_planner::v1::strategy::AllocatedRegion" + [ + ("start", + M.read (| + row + |)); + ("length", + M.read (| + region_length + |)) + ] + ] + |) + |) in + M.return_ (| + Value.StructTuple + "core::option::Option::Some" + [ M.read (| row |) ] + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple [] + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::option::Option::None" [] |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn slot_in( + region_shapes: Vec, + ) -> (Vec<(RegionStart, RegionShape)>, CircuitAllocations) { + // Tracks the empty regions for each column. + let mut column_allocations: CircuitAllocations = Default::default(); + + let regions = region_shapes + .into_iter() + .map(|region| { + // Sort the region's columns to ensure determinism. + // - An unstable sort is fine, because region.columns() returns a set. + // - The sort order relies on Column's Ord implementation! + let mut region_columns: Vec<_> = region.columns().iter().cloned().collect(); + region_columns.sort_unstable(); + + let region_start = first_fit_region( + &mut column_allocations, + ®ion_columns, + region.row_count(), + 0, + None, + ) + .expect("We can always fit a region somewhere"); + + (region_start.into(), region) + }) + .collect(); + + // Return the column allocations for potential further processing. + (regions, column_allocations) + } + *) + Definition slot_in (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ region_shapes ] => + ltac:(M.monadic + (let region_shapes := M.alloc (| region_shapes |) in + M.read (| + let column_allocations := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path + "halo2_proofs::circuit::floor_planner::v1::strategy::Allocations"; + Ty.path "std::hash::random::RandomState" + ], + [], + "default", + [] + |), + [] + |) + |) in + let regions := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionShape"; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ Ty.tuple [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ] + ] + (Ty.tuple + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path "halo2_proofs::circuit::layouter::RegionShape" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionShape"; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.tuple + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.function + [ + Ty.tuple + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ] + ] + (Ty.tuple + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path "halo2_proofs::circuit::layouter::RegionShape" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionShape"; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| region_shapes |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let region := M.copy (| γ |) in + M.read (| + let region_columns := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::cloned::Cloned") + [ + Ty.apply + (Ty.path + "std::collections::hash::set::Iter") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn" + ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "std::collections::hash::set::Iter") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn" + ], + [], + "cloned", + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn" + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::collections::hash::set::HashSet") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path + "std::hash::random::RandomState" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::circuit::layouter::RegionShape", + "columns", + [] + |), + [ region ] + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn" + ], + "sort_unstable", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ region_columns ] + |) + ] + |) + |) in + let region_start := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "usize" ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::circuit::floor_planner::v1::strategy::first_fit_region", + [] + |), + [ + column_allocations; + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ region_columns ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::circuit::layouter::RegionShape", + "row_count", + [] + |), + [ region ] + |); + Value.Integer 0; + Value.StructTuple + "core::option::Option::None" + [] + ] + |); + M.read (| + Value.String + "We can always fit a region somewhere" + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "usize", + [ + Ty.path + "halo2_proofs::circuit::RegionStart" + ], + "into", + [] + |), + [ M.read (| region_start |) ] + |); + M.read (| region |) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [ M.read (| regions |); M.read (| column_allocations |) ] |) + |))) + | _, _ => M.impossible + end. + + (* + pub fn slot_in_biggest_advice_first( + region_shapes: Vec, + ) -> (Vec, CircuitAllocations) { + let mut sorted_regions: Vec<_> = region_shapes.into_iter().collect(); + sorted_regions.sort_unstable_by_key(|shape| { + // Count the number of advice columns + let advice_cols = shape + .columns() + .iter() + .filter(|c| match c { + RegionColumn::Column(c) => matches!(c.column_type(), Any::Advice), + _ => false, + }) + .count(); + // Sort by advice area (since this has the most contention). + advice_cols * shape.row_count() + }); + sorted_regions.reverse(); + + // Lay out the sorted regions. + let (mut regions, column_allocations) = slot_in(sorted_regions); + + // Un-sort the regions so they match the original indexing. + regions.sort_unstable_by_key(|(_, region)| region.region_index().0); + let regions = regions.into_iter().map(|(start, _)| start).collect(); + + (regions, column_allocations) + } + *) + Definition slot_in_biggest_advice_first (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ region_shapes ] => + ltac:(M.monadic + (let region_shapes := M.alloc (| region_shapes |) in + M.read (| + let sorted_regions := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionShape"; + Ty.path "alloc::alloc::Global" + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionShape"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionShape"; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| region_shapes |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ], + "sort_unstable_by_key", + [ + Ty.path "usize"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ] + ] + ] + (Ty.path "usize") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionShape"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ sorted_regions ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let shape := M.copy (| γ |) in + M.read (| + let advice_cols := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "std::collections::hash::set::Iter") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn" + ] + ] + ] + ] + (Ty.path "bool") + ], + [], + "count", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "std::collections::hash::set::Iter") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn" + ], + [], + "filter", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn" + ] + ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::collections::hash::set::HashSet") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path + "std::hash::random::RandomState" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::circuit::layouter::RegionShape", + "columns", + [] + |), + [ M.read (| shape |) ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let c := M.copy (| γ |) in + M.read (| + M.match_operator (| + c, + [ + fun γ => + ltac:(M.monadic + (let γ := + M.read (| γ |) in + let γ := + M.read (| γ |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::circuit::layouter::RegionColumn::Column", + 0 + |) in + let c := + M.alloc (| + γ2_0 + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "column_type", + [] + |), + [ + M.read (| + c + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.read (| + γ + |) in + M.alloc (| + Value.Bool + true + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Bool + false + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Bool false + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + M.read (| advice_cols |), + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::circuit::layouter::RegionShape", + "row_count", + [] + |), + [ M.read (| shape |) ] + |) + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ], + "reverse", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionShape"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ sorted_regions ] + |) + ] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::circuit::floor_planner::v1::strategy::slot_in", + [] + |), + [ M.read (| sorted_regions |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let regions := M.copy (| γ0_0 |) in + let column_allocations := M.copy (| γ0_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path "halo2_proofs::circuit::layouter::RegionShape" + ] + ], + "sort_unstable_by_key", + [ + Ty.path "usize"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ] + ] + ] + ] + (Ty.path "usize") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ regions ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let region := M.alloc (| γ1_1 |) in + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::circuit::layouter::RegionShape", + "region_index", + [] + |), + [ M.read (| region |) ] + |) + |), + "halo2_proofs::circuit::RegionIndex", + 0 + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let regions := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ] + ] + ] + (Ty.path "halo2_proofs::circuit::RegionStart") + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ] + ] + ] + (Ty.path "halo2_proofs::circuit::RegionStart") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::circuit::RegionStart"; + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| regions |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let start := M.copy (| γ0_0 |) in + M.read (| start |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [ M.read (| regions |); M.read (| column_allocations |) ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + End strategy. + End v1. + End floor_planner. +End circuit. diff --git a/CoqOfRust/halo2_proofs/circuit/layouter.v b/CoqOfRust/halo2_proofs/circuit/layouter.v new file mode 100644 index 000000000..f787b86d7 --- /dev/null +++ b/CoqOfRust/halo2_proofs/circuit/layouter.v @@ -0,0 +1,2012 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuit. + Module layouter. + (* Trait *) + (* Empty module 'RegionLayouter' *) + + (* Trait *) + (* Empty module 'TableLayouter' *) + + (* StructRecord + { + name := "RegionShape"; + ty_params := []; + fields := + [ + ("region_index", Ty.path "halo2_proofs::circuit::RegionIndex"); + ("columns", + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path "std::hash::random::RandomState" + ]); + ("row_count", Ty.path "usize") + ]; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_circuit_layouter_RegionShape. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::layouter::RegionShape". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::circuit::layouter::RegionShape" + [ + ("region_index", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::circuit::RegionIndex", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::layouter::RegionShape", + "region_index" + |) + ] + |)); + ("columns", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path "std::hash::random::RandomState" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::layouter::RegionShape", + "columns" + |) + ] + |)); + ("row_count", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "usize", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::layouter::RegionShape", + "row_count" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_circuit_layouter_RegionShape. + + Module Impl_core_fmt_Debug_for_halo2_proofs_circuit_layouter_RegionShape. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::layouter::RegionShape". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "RegionShape" |); + M.read (| Value.String "region_index" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::layouter::RegionShape", + "region_index" + |)); + M.read (| Value.String "columns" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::layouter::RegionShape", + "columns" + |)); + M.read (| Value.String "row_count" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::layouter::RegionShape", + "row_count" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_circuit_layouter_RegionShape. + + (* + Enum RegionColumn + { + ty_params := []; + variants := + [ + { + name := "Column"; + item := + StructTuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ]; + discriminant := None; + }; + { + name := "Selector"; + item := StructTuple [ Ty.path "halo2_proofs::plonk::circuit::Selector" ]; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_marker_StructuralEq_for_halo2_proofs_circuit_layouter_RegionColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::layouter::RegionColumn". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralEq_for_halo2_proofs_circuit_layouter_RegionColumn. + + Module Impl_core_cmp_Eq_for_halo2_proofs_circuit_layouter_RegionColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::layouter::RegionColumn". + + (* Eq *) + Definition assert_receiver_is_total_eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Eq" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("assert_receiver_is_total_eq", InstanceField.Method assert_receiver_is_total_eq) ]. + End Impl_core_cmp_Eq_for_halo2_proofs_circuit_layouter_RegionColumn. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_circuit_layouter_RegionColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::layouter::RegionColumn". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_circuit_layouter_RegionColumn. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_circuit_layouter_RegionColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::layouter::RegionColumn". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::circuit::layouter::RegionColumn" ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::circuit::layouter::RegionColumn" ] + |), + [ M.read (| other |) ] + |) + |) in + M.alloc (| + LogicalOp.and (| + BinOp.Pure.eq (M.read (| __self_tag |)) (M.read (| __arg1_tag |)), + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| other |) ] |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::circuit::layouter::RegionColumn::Column", + 0 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::circuit::layouter::RegionColumn::Column", + 0 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "eq", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::circuit::layouter::RegionColumn::Selector", + 0 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::circuit::layouter::RegionColumn::Selector", + 0 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::plonk::circuit::Selector", + [ Ty.path "halo2_proofs::plonk::circuit::Selector" ], + "eq", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::intrinsics::unreachable", [] |), + [] + |) + |) + |))) + ] + |) + |))) + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_circuit_layouter_RegionColumn. + + Module Impl_core_marker_Copy_for_halo2_proofs_circuit_layouter_RegionColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::layouter::RegionColumn". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_circuit_layouter_RegionColumn. + + Module Impl_core_clone_Clone_for_halo2_proofs_circuit_layouter_RegionColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::layouter::RegionColumn". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.read (| self |))) ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_circuit_layouter_RegionColumn. + + Module Impl_core_fmt_Debug_for_halo2_proofs_circuit_layouter_RegionColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::layouter::RegionColumn". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::circuit::layouter::RegionColumn::Column", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Column" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::circuit::layouter::RegionColumn::Selector", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Selector" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_circuit_layouter_RegionColumn. + + Module Impl_core_hash_Hash_for_halo2_proofs_circuit_layouter_RegionColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::layouter::RegionColumn". + + (* Hash *) + Definition hash (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ __H ], [ self; state ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let state := M.alloc (| state |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::circuit::layouter::RegionColumn" ] + |), + [ M.read (| self |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::hash::Hash", + Ty.path "isize", + [], + "hash", + [ __H ] + |), + [ __self_tag; M.read (| state |) ] + |) + |) in + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::circuit::layouter::RegionColumn::Column", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::hash::Hash", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + [], + "hash", + [ __H ] + |), + [ M.read (| __self_0 |); M.read (| state |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::circuit::layouter::RegionColumn::Selector", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::hash::Hash", + Ty.path "halo2_proofs::plonk::circuit::Selector", + [], + "hash", + [ __H ] + |), + [ M.read (| __self_0 |); M.read (| state |) ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::hash::Hash" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("hash", InstanceField.Method hash) ]. + End Impl_core_hash_Hash_for_halo2_proofs_circuit_layouter_RegionColumn. + + Module Impl_core_convert_From_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Any_for_halo2_proofs_circuit_layouter_RegionColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::layouter::RegionColumn". + + (* + fn from(column: Column) -> RegionColumn { + RegionColumn::Column(column) + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ column ] => + ltac:(M.monadic + (let column := M.alloc (| column |) in + Value.StructTuple + "halo2_proofs::circuit::layouter::RegionColumn::Column" + [ M.read (| column |) ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) + [ + (* T *) + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Any_for_halo2_proofs_circuit_layouter_RegionColumn. + + Module Impl_core_convert_From_halo2_proofs_plonk_circuit_Selector_for_halo2_proofs_circuit_layouter_RegionColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::layouter::RegionColumn". + + (* + fn from(selector: Selector) -> RegionColumn { + RegionColumn::Selector(selector) + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ selector ] => + ltac:(M.monadic + (let selector := M.alloc (| selector |) in + Value.StructTuple + "halo2_proofs::circuit::layouter::RegionColumn::Selector" + [ M.read (| selector |) ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) [ (* T *) Ty.path "halo2_proofs::plonk::circuit::Selector" ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_halo2_proofs_plonk_circuit_Selector_for_halo2_proofs_circuit_layouter_RegionColumn. + + Module Impl_core_cmp_Ord_for_halo2_proofs_circuit_layouter_RegionColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::layouter::RegionColumn". + + (* + fn cmp(&self, other: &Self) -> cmp::Ordering { + match (self, other) { + (Self::Column(ref a), Self::Column(ref b)) => a.cmp(b), + (Self::Selector(ref a), Self::Selector(ref b)) => a.0.cmp(&b.0), + (Self::Column(_), Self::Selector(_)) => cmp::Ordering::Less, + (Self::Selector(_), Self::Column(_)) => cmp::Ordering::Greater, + } + } + *) + Definition cmp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| other |) ] |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::circuit::layouter::RegionColumn::Column", + 0 + |) in + let a := M.alloc (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::circuit::layouter::RegionColumn::Column", + 0 + |) in + let b := M.alloc (| γ2_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + [], + "cmp", + [] + |), + [ M.read (| a |); M.read (| b |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::circuit::layouter::RegionColumn::Selector", + 0 + |) in + let a := M.alloc (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::circuit::layouter::RegionColumn::Selector", + 0 + |) in + let b := M.alloc (| γ2_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::cmp::Ord", Ty.path "usize", [], "cmp", [] |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| a |), + "halo2_proofs::plonk::circuit::Selector", + 0 + |); + M.SubPointer.get_struct_tuple_field (| + M.read (| b |), + "halo2_proofs::plonk::circuit::Selector", + 0 + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::circuit::layouter::RegionColumn::Column", + 0 + |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::circuit::layouter::RegionColumn::Selector", + 0 + |) in + M.alloc (| Value.StructTuple "core::cmp::Ordering::Less" [] |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::circuit::layouter::RegionColumn::Selector", + 0 + |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::circuit::layouter::RegionColumn::Column", + 0 + |) in + M.alloc (| Value.StructTuple "core::cmp::Ordering::Greater" [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Ord" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("cmp", InstanceField.Method cmp) ]. + End Impl_core_cmp_Ord_for_halo2_proofs_circuit_layouter_RegionColumn. + + Module Impl_core_cmp_PartialOrd_for_halo2_proofs_circuit_layouter_RegionColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::layouter::RegionColumn". + + (* + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } + *) + Definition partial_cmp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path "halo2_proofs::circuit::layouter::RegionColumn", + [], + "cmp", + [] + |), + [ M.read (| self |); M.read (| other |) ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialOrd" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("partial_cmp", InstanceField.Method partial_cmp) ]. + End Impl_core_cmp_PartialOrd_for_halo2_proofs_circuit_layouter_RegionColumn. + + Module Impl_halo2_proofs_circuit_layouter_RegionShape. + Definition Self : Ty.t := Ty.path "halo2_proofs::circuit::layouter::RegionShape". + + (* + pub fn new(region_index: RegionIndex) -> Self { + RegionShape { + region_index, + columns: HashSet::default(), + row_count: 0, + } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ region_index ] => + ltac:(M.monadic + (let region_index := M.alloc (| region_index |) in + Value.StructRecord + "halo2_proofs::circuit::layouter::RegionShape" + [ + ("region_index", M.read (| region_index |)); + ("columns", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path "std::hash::random::RandomState" + ], + [], + "default", + [] + |), + [] + |)); + ("row_count", Value.Integer 0) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + + (* + pub fn region_index(&self) -> RegionIndex { + self.region_index + } + *) + Definition region_index (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::layouter::RegionShape", + "region_index" + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_region_index : + M.IsAssociatedFunction Self "region_index" region_index. + + (* + pub fn columns(&self) -> &HashSet { + &self.columns + } + *) + Definition columns (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::layouter::RegionShape", + "columns" + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_columns : M.IsAssociatedFunction Self "columns" columns. + + (* + pub fn row_count(&self) -> usize { + self.row_count + } + *) + Definition row_count (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::circuit::layouter::RegionShape", + "row_count" + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_row_count : M.IsAssociatedFunction Self "row_count" row_count. + End Impl_halo2_proofs_circuit_layouter_RegionShape. + + Module Impl_halo2_proofs_circuit_layouter_RegionLayouter_where_ff_Field_F_F_for_halo2_proofs_parallel_Parallel_halo2_proofs_circuit_layouter_RegionShape. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ]. + + (* + fn enable_selector<'v>( + &'v self, + _: &'v (dyn Fn() -> String + 'v), + selector: &Selector, + offset: usize, + ) -> Result<(), Error> { + let mut region_shape = self.lock().unwrap(); + + // Track the selector's fixed column as part of the region's shape. + region_shape.columns.insert(( *selector).into()); + region_shape.row_count = cmp::max(region_shape.row_count, offset + 1); + Ok(()) + } + *) + Definition enable_selector (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1; selector; offset ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let selector := M.alloc (| selector |) in + let offset := M.alloc (| offset |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.read (| + let region_shape := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ], + "lock", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ], + [], + "deref_mut", + [] + |), + [ region_shape ] + |), + "halo2_proofs::circuit::layouter::RegionShape", + "columns" + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "halo2_proofs::plonk::circuit::Selector", + [ Ty.path "halo2_proofs::circuit::layouter::RegionColumn" ], + "into", + [] + |), + [ M.read (| M.read (| selector |) |) ] + |) + ] + |) + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ], + [], + "deref_mut", + [] + |), + [ region_shape ] + |), + "halo2_proofs::circuit::layouter::RegionShape", + "row_count" + |), + M.call_closure (| + M.get_function (| "core::cmp::max", [ Ty.path "usize" ] |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ], + [], + "deref", + [] + |), + [ region_shape ] + |), + "halo2_proofs::circuit::layouter::RegionShape", + "row_count" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| offset |), + Value.Integer 1 + |) + ] + |) + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign_advice<'v>( + &'v self, + _: &'v (dyn Fn() -> String + 'v), + column: Column, + offset: usize, + _to: &'v mut (dyn FnMut() -> Result, Error> + 'v), + ) -> Result { + let mut region_shape = self.lock().unwrap(); + + region_shape + .columns + .insert(Column::::from(column).into()); + region_shape.row_count = cmp::max(region_shape.row_count, offset + 1); + + Ok(Cell { + region_index: region_shape.region_index, + row_offset: offset, + column: column.into(), + }) + } + *) + Definition assign_advice (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1; column; offset; _to ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let column := M.alloc (| column |) in + let offset := M.alloc (| offset |) in + let _to := M.alloc (| _to |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.read (| + let region_shape := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ], + "lock", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ], + [], + "deref_mut", + [] + |), + [ region_shape ] + |), + "halo2_proofs::circuit::layouter::RegionShape", + "columns" + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + [ Ty.path "halo2_proofs::circuit::layouter::RegionColumn" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + "from", + [] + |), + [ M.read (| column |) ] + |) + ] + |) + ] + |) + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ], + [], + "deref_mut", + [] + |), + [ region_shape ] + |), + "halo2_proofs::circuit::layouter::RegionShape", + "row_count" + |), + M.call_closure (| + M.get_function (| "core::cmp::max", [ Ty.path "usize" ] |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ], + [], + "deref", + [] + |), + [ region_shape ] + |), + "halo2_proofs::circuit::layouter::RegionShape", + "row_count" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| offset |), + Value.Integer 1 + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::circuit::Cell" + [ + ("region_index", + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" + ], + [], + "deref", + [] + |), + [ region_shape ] + |), + "halo2_proofs::circuit::layouter::RegionShape", + "region_index" + |) + |)); + ("row_offset", M.read (| offset |)); + ("column", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "into", + [] + |), + [ M.read (| column |) ] + |)) + ] + ] + |) + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign_advice_from_constant<'v>( + &'v self, + annotation: &'v (dyn Fn() -> String + 'v), + column: Column, + offset: usize, + constant: Assigned, + ) -> Result { + // The rest is identical to witnessing an advice cell. + self.assign_advice(annotation, column, offset, &mut || Ok(constant)) + } + *) + Definition assign_advice_from_constant (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; annotation; column; offset; constant ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let annotation := M.alloc (| annotation |) in + let column := M.alloc (| column |) in + let offset := M.alloc (| offset |) in + let constant := M.alloc (| constant |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::layouter::RegionLayouter", + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ], + [ F ], + "assign_advice", + [] + |), + [ + M.read (| self |); + (* Unsize *) M.pointer_coercion (M.read (| annotation |)); + M.read (| column |); + M.read (| offset |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ M.read (| constant |) ])) + ] + |) + | _ => M.impossible (||) + end)) + |)) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign_advice_from_instance<'v>( + &self, + _: &'v (dyn Fn() -> String + 'v), + _: Column, + _: usize, + advice: Column, + offset: usize, + ) -> Result<(Cell, Option), Error> { + let mut region_shape = self.lock().unwrap(); + + region_shape + .columns + .insert(Column::::from(advice).into()); + region_shape.row_count = cmp::max(region_shape.row_count, offset + 1); + + Ok(( + Cell { + region_index: region_shape.region_index, + row_offset: offset, + column: advice.into(), + }, + None, + )) + } + *) + Definition assign_advice_from_instance (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1; β2; β3; advice; offset ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let β2 := M.alloc (| β2 |) in + let β3 := M.alloc (| β3 |) in + let advice := M.alloc (| advice |) in + let offset := M.alloc (| offset |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β2, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β3, + [ + fun γ => + ltac:(M.monadic + (M.read (| + let region_shape := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ], + "lock", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ], + [], + "deref_mut", + [] + |), + [ region_shape ] + |), + "halo2_proofs::circuit::layouter::RegionShape", + "columns" + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionColumn" + ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ], + "from", + [] + |), + [ M.read (| advice |) ] + |) + ] + |) + ] + |) + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ], + [], + "deref_mut", + [] + |), + [ region_shape ] + |), + "halo2_proofs::circuit::layouter::RegionShape", + "row_count" + |), + M.call_closure (| + M.get_function (| + "core::cmp::max", + [ Ty.path "usize" ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ], + [], + "deref", + [] + |), + [ region_shape ] + |), + "halo2_proofs::circuit::layouter::RegionShape", + "row_count" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| offset |), + Value.Integer 1 + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.Tuple + [ + Value.StructRecord + "halo2_proofs::circuit::Cell" + [ + ("region_index", + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.path + "halo2_proofs::circuit::layouter::RegionShape" + ], + [], + "deref", + [] + |), + [ region_shape ] + |), + "halo2_proofs::circuit::layouter::RegionShape", + "region_index" + |) + |)); + ("row_offset", M.read (| offset |)); + ("column", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "into", + [] + |), + [ M.read (| advice |) ] + |)) + ]; + Value.StructTuple "core::option::Option::None" [] + ] + ] + |) + |))) + ] + |))) + ] + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign_fixed<'v>( + &'v self, + _: &'v (dyn Fn() -> String + 'v), + column: Column, + offset: usize, + _to: &'v mut (dyn FnMut() -> Result, Error> + 'v), + ) -> Result { + let mut region_shape = self.lock().unwrap(); + + region_shape + .columns + .insert(Column::::from(column).into()); + region_shape.row_count = cmp::max(region_shape.row_count, offset + 1); + + Ok(Cell { + region_index: region_shape.region_index, + row_offset: offset, + column: column.into(), + }) + } + *) + Definition assign_fixed (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1; column; offset; _to ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let column := M.alloc (| column |) in + let offset := M.alloc (| offset |) in + let _to := M.alloc (| _to |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.read (| + let region_shape := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ], + "lock", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.path "halo2_proofs::circuit::layouter::RegionColumn"; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ], + [], + "deref_mut", + [] + |), + [ region_shape ] + |), + "halo2_proofs::circuit::layouter::RegionShape", + "columns" + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + [ Ty.path "halo2_proofs::circuit::layouter::RegionColumn" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ], + "from", + [] + |), + [ M.read (| column |) ] + |) + ] + |) + ] + |) + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ], + [], + "deref_mut", + [] + |), + [ region_shape ] + |), + "halo2_proofs::circuit::layouter::RegionShape", + "row_count" + |), + M.call_closure (| + M.get_function (| "core::cmp::max", [ Ty.path "usize" ] |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" ], + [], + "deref", + [] + |), + [ region_shape ] + |), + "halo2_proofs::circuit::layouter::RegionShape", + "row_count" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| offset |), + Value.Integer 1 + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::circuit::Cell" + [ + ("region_index", + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.path "halo2_proofs::circuit::layouter::RegionShape" + ], + [], + "deref", + [] + |), + [ region_shape ] + |), + "halo2_proofs::circuit::layouter::RegionShape", + "region_index" + |) + |)); + ("row_offset", M.read (| offset |)); + ("column", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "into", + [] + |), + [ M.read (| column |) ] + |)) + ] + ] + |) + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn constrain_constant(&self, _cell: Cell, _constant: Assigned) -> Result<(), Error> { + // Global constants don't affect the region shape. + Ok(()) + } + *) + Definition constrain_constant (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _cell; _constant ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _cell := M.alloc (| _cell |) in + let _constant := M.alloc (| _constant |) in + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ])) + | _, _ => M.impossible + end. + + (* + fn constrain_equal(&self, _left: Cell, _right: Cell) -> Result<(), Error> { + // Equality constraints don't affect the region shape. + Ok(()) + } + *) + Definition constrain_equal (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _left; _right ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _left := M.alloc (| _left |) in + let _right := M.alloc (| _right |) in + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "halo2_proofs::circuit::layouter::RegionLayouter" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("enable_selector", InstanceField.Method (enable_selector F)); + ("assign_advice", InstanceField.Method (assign_advice F)); + ("assign_advice_from_constant", InstanceField.Method (assign_advice_from_constant F)); + ("assign_advice_from_instance", InstanceField.Method (assign_advice_from_instance F)); + ("assign_fixed", InstanceField.Method (assign_fixed F)); + ("constrain_constant", InstanceField.Method (constrain_constant F)); + ("constrain_equal", InstanceField.Method (constrain_equal F)) + ]. + End Impl_halo2_proofs_circuit_layouter_RegionLayouter_where_ff_Field_F_F_for_halo2_proofs_parallel_Parallel_halo2_proofs_circuit_layouter_RegionShape. + End layouter. +End circuit. diff --git a/CoqOfRust/halo2_proofs/dev.v b/CoqOfRust/halo2_proofs/dev.v new file mode 100644 index 000000000..e72f0d212 --- /dev/null +++ b/CoqOfRust/halo2_proofs/dev.v @@ -0,0 +1,25066 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module dev. + (* + Enum FailureLocation + { + ty_params := []; + variants := + [ + { + name := "InRegion"; + item := + StructRecord + [ + ("region", Ty.path "halo2_proofs::dev::metadata::Region"); + ("offset", Ty.path "usize") + ]; + discriminant := None; + }; + { + name := "OutsideRegion"; + item := StructRecord [ ("row", Ty.path "usize") ]; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_dev_FailureLocation. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::FailureLocation". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::FailureLocation::InRegion", + "region" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::FailureLocation::InRegion", + "offset" + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "InRegion" |); + M.read (| Value.String "region" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + M.read (| Value.String "offset" |); + (* Unsize *) M.pointer_coercion __self_1 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::FailureLocation::OutsideRegion", + "row" + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "OutsideRegion" |); + M.read (| Value.String "row" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_dev_FailureLocation. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_dev_FailureLocation. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::FailureLocation". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_dev_FailureLocation. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_dev_FailureLocation. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::FailureLocation". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::dev::FailureLocation" ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::dev::FailureLocation" ] + |), + [ M.read (| other |) ] + |) + |) in + M.alloc (| + LogicalOp.and (| + BinOp.Pure.eq (M.read (| __self_tag |)) (M.read (| __arg1_tag |)), + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| other |) ] |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::dev::FailureLocation::InRegion", + "region" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::dev::FailureLocation::InRegion", + "offset" + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::dev::FailureLocation::InRegion", + "region" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::dev::FailureLocation::InRegion", + "offset" + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::dev::metadata::Region", + [ Ty.path "halo2_proofs::dev::metadata::Region" ], + "eq", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |), + ltac:(M.monadic + (BinOp.Pure.eq + (M.read (| M.read (| __self_1 |) |)) + (M.read (| M.read (| __arg1_1 |) |)))) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::dev::FailureLocation::OutsideRegion", + "row" + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::dev::FailureLocation::OutsideRegion", + "row" + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + M.alloc (| + BinOp.Pure.eq + (M.read (| M.read (| __self_0 |) |)) + (M.read (| M.read (| __arg1_0 |) |)) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::intrinsics::unreachable", [] |), + [] + |) + |) + |))) + ] + |) + |))) + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_dev_FailureLocation. + + Module Impl_core_fmt_Display_for_halo2_proofs_dev_FailureLocation. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::FailureLocation". + + (* + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::InRegion { region, offset } => write!(f, "in {} at offset {}", region, offset), + Self::OutsideRegion { row } => { + write!(f, "on row {}", row) + } + } + } + *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::FailureLocation::InRegion", + "region" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::FailureLocation::InRegion", + "offset" + |) in + let region := M.alloc (| γ1_0 |) in + let offset := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "in " |); + M.read (| Value.String " at offset " |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "halo2_proofs::dev::metadata::Region" ] + ] + |), + [ region ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "usize" ] ] + |), + [ offset ] + |) + ] + |)) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::FailureLocation::OutsideRegion", + "row" + |) in + let row := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| Value.Array [ M.read (| Value.String "on row " |) ] |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "usize" ] ] + |), + [ row ] + |) + ] + |)) + ] + |) + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Display" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Display_for_halo2_proofs_dev_FailureLocation. + + Module Impl_halo2_proofs_dev_FailureLocation. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::FailureLocation". + + (* + fn find_expressions<'a, F: Field>( + cs: &ConstraintSystem, + regions: &[Region], + failure_row: usize, + failure_expressions: impl Iterator>, + ) -> Self { + let failure_columns: HashSet> = failure_expressions + .flat_map(|expression| { + expression.evaluate( + &|_| vec![], + &|_| panic!("virtual selectors are removed during optimization"), + &|index, _, _| vec![cs.fixed_queries[index].0.into()], + &|index, _, _| vec![cs.advice_queries[index].0.into()], + &|index, _, _| vec![cs.instance_queries[index].0.into()], + &|a| a, + &|mut a, mut b| { + a.append(&mut b); + a + }, + &|a, b| { + let mut a = a(); + let mut b = b(); + a.append(&mut b); + a + }, + &|a, _| a, + ) + }) + .collect(); + + Self::find(regions, failure_row, failure_columns) + } + *) + Definition find_expressions (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F; impl_Iterator_Item____'a_Expression_F__ ], + [ cs; regions; failure_row; failure_expressions ] => + ltac:(M.monadic + (let cs := M.alloc (| cs |) in + let regions := M.alloc (| regions |) in + let failure_row := M.alloc (| failure_row |) in + let failure_expressions := M.alloc (| failure_expressions |) in + M.read (| + let failure_columns := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + impl_Iterator_Item____'a_Expression_F__; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "std::hash::random::RandomState" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item____'a_Expression_F__, + [], + "flat_map", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| failure_expressions |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let expression := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "evaluate", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ Ty.tuple [ F ] ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ ("core::ops::function::Fn::Trait", []) + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ ("core::ops::function::Fn::Trait", []) + ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ]; + F + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| expression |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.never_to_any (| + M.call_closure (| + M.get_function (| + "std::panicking::begin_panic", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + Value.String + "virtual selectors are removed during optimization" + |) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let index := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| α2 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "into_vec", + [ + Ty.path + "alloc::alloc::Global" + ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_tuple_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + cs + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "fixed_queries" + |); + M.read (| + index + |) + ] + |), + 0 + |) + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let index := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| α2 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "into_vec", + [ + Ty.path + "alloc::alloc::Global" + ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_tuple_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + cs + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "advice_queries" + |); + M.read (| + index + |) + ] + |), + 0 + |) + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let index := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| α2 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "into_vec", + [ + Ty.path + "alloc::alloc::Global" + ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_tuple_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + cs + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "instance_queries" + |); + M.read (| + index + |) + ] + |), + 0 + |) + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.read (| a |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let b := M.copy (| γ |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path + "alloc::alloc::Global" + ], + "append", + [] + |), + [ a; b ] + |) + |) in + a + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let b := M.copy (| γ |) in + M.read (| + let a := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ], + [ Ty.tuple [] ], + "call", + [] + |), + [ + M.read (| a |); + Value.Tuple [] + ] + |) + |) in + let b := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ], + [ Ty.tuple [] ], + "call", + [] + |), + [ + M.read (| b |); + Value.Tuple [] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path + "alloc::alloc::Global" + ], + "append", + [] + |), + [ a; b ] + |) + |) in + a + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| a |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::FailureLocation", + "find", + [] + |), + [ M.read (| regions |); M.read (| failure_row |); M.read (| failure_columns |) ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_find_expressions : + M.IsAssociatedFunction Self "find_expressions" find_expressions. + + (* + fn find(regions: &[Region], failure_row: usize, failure_columns: HashSet>) -> Self { + regions + .iter() + .enumerate() + .find(|(_, r)| { + let (start, end) = r.rows.unwrap(); + // We match the region if any input columns overlap, rather than all of + // them, because matching complex selector columns is hard. As long as + // regions are rectangles, and failures occur due to assignments entirely + // within single regions, "any" will be equivalent to "all". If these + // assumptions change, we'll start getting bug reports from users :) + (start..=end).contains(&failure_row) && !failure_columns.is_disjoint(&r.columns) + }) + .map(|(r_i, r)| FailureLocation::InRegion { + region: (r_i, r.name.clone()).into(), + offset: failure_row as usize - r.rows.unwrap().0 as usize, + }) + .unwrap_or_else(|| FailureLocation::OutsideRegion { + row: failure_row as usize, + }) + } + *) + Definition find (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ regions; failure_row; failure_columns ] => + ltac:(M.monadic + (let regions := M.alloc (| regions |) in + let failure_row := M.alloc (| failure_row |) in + let failure_columns := M.alloc (| failure_columns |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::FailureLocation" ], + "unwrap_or_else", + [ Ty.function [ Ty.tuple [] ] (Ty.path "halo2_proofs::dev::FailureLocation") ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply (Ty.path "&") [ Ty.path "halo2_proofs::dev::Region" ] + ] + ], + "map", + [ + Ty.path "halo2_proofs::dev::FailureLocation"; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply (Ty.path "&") [ Ty.path "halo2_proofs::dev::Region" ] + ] + ] + ] + (Ty.path "halo2_proofs::dev::FailureLocation") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::dev::Region" ] + ], + [], + "find", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ Ty.path "halo2_proofs::dev::Region" ] + ] + ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::dev::Region" ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "halo2_proofs::dev::Region" ], + "iter", + [] + |), + [ M.read (| regions |) ] + |) + ] + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let r := M.alloc (| γ1_1 |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.tuple [ Ty.path "usize"; Ty.path "usize" ] ], + "unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| M.read (| r |) |), + "halo2_proofs::dev::Region", + "rows" + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let start := M.copy (| γ0_0 |) in + let end_ := M.copy (| γ0_1 |) in + M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::ops::range::RangeInclusive") + [ Ty.path "usize" ], + "contains", + [ Ty.path "usize" ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::ops::range::RangeInclusive") + [ Ty.path "usize" ], + "new", + [] + |), + [ M.read (| start |); M.read (| end_ |) + ] + |) + |); + failure_row + ] + |), + ltac:(M.monadic + (UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::collections::hash::set::HashSet") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path + "std::hash::random::RandomState" + ], + "is_disjoint", + [] + |), + [ + failure_columns; + M.SubPointer.get_struct_record_field (| + M.read (| M.read (| r |) |), + "halo2_proofs::dev::Region", + "columns" + |) + ] + |)))) + |) + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let r_i := M.copy (| γ0_0 |) in + let r := M.copy (| γ0_1 |) in + Value.StructRecord + "halo2_proofs::dev::FailureLocation::InRegion" + [ + ("region", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.tuple + [ Ty.path "usize"; Ty.path "alloc::string::String" ], + [ Ty.path "halo2_proofs::dev::metadata::Region" ], + "into", + [] + |), + [ + Value.Tuple + [ + M.read (| r_i |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "alloc::string::String", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| r |), + "halo2_proofs::dev::Region", + "name" + |) + ] + |) + ] + ] + |)); + ("offset", + BinOp.Panic.sub (| + Integer.Usize, + M.read (| M.use failure_row |), + M.read (| + M.use + (M.SubPointer.get_tuple_field (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ Ty.path "usize"; Ty.path "usize" ] + ], + "unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| r |), + "halo2_proofs::dev::Region", + "rows" + |) + |) + ] + |) + |), + 0 + |)) + |) + |)) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructRecord + "halo2_proofs::dev::FailureLocation::OutsideRegion" + [ ("row", M.read (| M.use failure_row |)) ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_find : M.IsAssociatedFunction Self "find" find. + End Impl_halo2_proofs_dev_FailureLocation. + + (* + Enum VerifyFailure + { + ty_params := []; + variants := + [ + { + name := "CellNotAssigned"; + item := + StructRecord + [ + ("gate", Ty.path "halo2_proofs::dev::metadata::Gate"); + ("region", Ty.path "halo2_proofs::dev::metadata::Region"); + ("column", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]); + ("offset", Ty.path "isize") + ]; + discriminant := None; + }; + { + name := "ConstraintNotSatisfied"; + item := + StructRecord + [ + ("constraint", Ty.path "halo2_proofs::dev::metadata::Constraint"); + ("location", Ty.path "halo2_proofs::dev::FailureLocation"); + ("cell_values", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String" + ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + discriminant := None; + }; + { + name := "ConstraintPoisoned"; + item := + StructRecord [ ("constraint", Ty.path "halo2_proofs::dev::metadata::Constraint") ]; + discriminant := None; + }; + { + name := "Lookup"; + item := + StructRecord + [ + ("name", Ty.apply (Ty.path "&") [ Ty.path "str" ]); + ("lookup_index", Ty.path "usize"); + ("location", Ty.path "halo2_proofs::dev::FailureLocation") + ]; + discriminant := None; + }; + { + name := "Permutation"; + item := + StructRecord + [ ("column", Ty.path "halo2_proofs::dev::metadata::Column"); ("row", Ty.path "usize") + ]; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_dev_VerifyFailure. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::VerifyFailure". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::CellNotAssigned", + "gate" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::CellNotAssigned", + "region" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::CellNotAssigned", + "column" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::CellNotAssigned", + "offset" + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + let __self_2 := M.alloc (| γ1_2 |) in + let __self_3 := M.alloc (| γ1_3 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field4_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "CellNotAssigned" |); + M.read (| Value.String "gate" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + M.read (| Value.String "region" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_1 |)); + M.read (| Value.String "column" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_2 |)); + M.read (| Value.String "offset" |); + (* Unsize *) M.pointer_coercion __self_3 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::ConstraintNotSatisfied", + "constraint" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::ConstraintNotSatisfied", + "location" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::ConstraintNotSatisfied", + "cell_values" + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + let __self_2 := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "ConstraintNotSatisfied" |); + M.read (| Value.String "constraint" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + M.read (| Value.String "location" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_1 |)); + M.read (| Value.String "cell_values" |); + (* Unsize *) M.pointer_coercion __self_2 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::ConstraintPoisoned", + "constraint" + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "ConstraintPoisoned" |); + M.read (| Value.String "constraint" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::Lookup", + "name" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::Lookup", + "lookup_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::Lookup", + "location" + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + let __self_2 := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Lookup" |); + M.read (| Value.String "name" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + M.read (| Value.String "lookup_index" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_1 |)); + M.read (| Value.String "location" |); + (* Unsize *) M.pointer_coercion __self_2 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::Permutation", + "column" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::Permutation", + "row" + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Permutation" |); + M.read (| Value.String "column" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + M.read (| Value.String "row" |); + (* Unsize *) M.pointer_coercion __self_1 + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_dev_VerifyFailure. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_dev_VerifyFailure. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::VerifyFailure". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_dev_VerifyFailure. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_dev_VerifyFailure. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::VerifyFailure". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::dev::VerifyFailure" ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::dev::VerifyFailure" ] + |), + [ M.read (| other |) ] + |) + |) in + M.alloc (| + LogicalOp.and (| + BinOp.Pure.eq (M.read (| __self_tag |)) (M.read (| __arg1_tag |)), + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| other |) ] |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::dev::VerifyFailure::CellNotAssigned", + "gate" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::dev::VerifyFailure::CellNotAssigned", + "region" + |) in + let γ2_2 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::dev::VerifyFailure::CellNotAssigned", + "column" + |) in + let γ2_3 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::dev::VerifyFailure::CellNotAssigned", + "offset" + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let __self_2 := M.alloc (| γ2_2 |) in + let __self_3 := M.alloc (| γ2_3 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::dev::VerifyFailure::CellNotAssigned", + "gate" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::dev::VerifyFailure::CellNotAssigned", + "region" + |) in + let γ2_2 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::dev::VerifyFailure::CellNotAssigned", + "column" + |) in + let γ2_3 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::dev::VerifyFailure::CellNotAssigned", + "offset" + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + let __arg1_2 := M.alloc (| γ2_2 |) in + let __arg1_3 := M.alloc (| γ2_3 |) in + M.alloc (| + LogicalOp.and (| + LogicalOp.and (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::dev::metadata::Gate", + [ Ty.path "halo2_proofs::dev::metadata::Gate" ], + "eq", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::dev::metadata::Region", + [ Ty.path "halo2_proofs::dev::metadata::Region" ], + "eq", + [] + |), + [ M.read (| __self_1 |); M.read (| __arg1_1 |) ] + |))) + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "eq", + [] + |), + [ M.read (| __self_2 |); M.read (| __arg1_2 |) ] + |))) + |), + ltac:(M.monadic + (BinOp.Pure.eq + (M.read (| M.read (| __self_3 |) |)) + (M.read (| M.read (| __arg1_3 |) |)))) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::dev::VerifyFailure::ConstraintNotSatisfied", + "constraint" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::dev::VerifyFailure::ConstraintNotSatisfied", + "location" + |) in + let γ2_2 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::dev::VerifyFailure::ConstraintNotSatisfied", + "cell_values" + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let __self_2 := M.alloc (| γ2_2 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::dev::VerifyFailure::ConstraintNotSatisfied", + "constraint" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::dev::VerifyFailure::ConstraintNotSatisfied", + "location" + |) in + let γ2_2 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::dev::VerifyFailure::ConstraintNotSatisfied", + "cell_values" + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + let __arg1_2 := M.alloc (| γ2_2 |) in + M.alloc (| + LogicalOp.and (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::dev::metadata::Constraint", + [ Ty.path "halo2_proofs::dev::metadata::Constraint" ], + "eq", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::dev::FailureLocation", + [ Ty.path "halo2_proofs::dev::FailureLocation" ], + "eq", + [] + |), + [ M.read (| __self_1 |); M.read (| __arg1_1 |) ] + |))) + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String" + ]; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "eq", + [] + |), + [ M.read (| __self_2 |); M.read (| __arg1_2 |) ] + |))) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::dev::VerifyFailure::ConstraintPoisoned", + "constraint" + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::dev::VerifyFailure::ConstraintPoisoned", + "constraint" + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::dev::metadata::Constraint", + [ Ty.path "halo2_proofs::dev::metadata::Constraint" ], + "eq", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::dev::VerifyFailure::Lookup", + "name" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::dev::VerifyFailure::Lookup", + "lookup_index" + |) in + let γ2_2 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::dev::VerifyFailure::Lookup", + "location" + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let __self_2 := M.alloc (| γ2_2 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::dev::VerifyFailure::Lookup", + "name" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::dev::VerifyFailure::Lookup", + "lookup_index" + |) in + let γ2_2 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::dev::VerifyFailure::Lookup", + "location" + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + let __arg1_2 := M.alloc (| γ2_2 |) in + M.alloc (| + LogicalOp.and (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ], + "eq", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |), + ltac:(M.monadic + (BinOp.Pure.eq + (M.read (| M.read (| __self_1 |) |)) + (M.read (| M.read (| __arg1_1 |) |)))) + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::dev::FailureLocation", + [ Ty.path "halo2_proofs::dev::FailureLocation" ], + "eq", + [] + |), + [ M.read (| __self_2 |); M.read (| __arg1_2 |) ] + |))) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::dev::VerifyFailure::Permutation", + "column" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::dev::VerifyFailure::Permutation", + "row" + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::dev::VerifyFailure::Permutation", + "column" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::dev::VerifyFailure::Permutation", + "row" + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::dev::metadata::Column", + [ Ty.path "halo2_proofs::dev::metadata::Column" ], + "eq", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |), + ltac:(M.monadic + (BinOp.Pure.eq + (M.read (| M.read (| __self_1 |) |)) + (M.read (| M.read (| __arg1_1 |) |)))) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::intrinsics::unreachable", [] |), + [] + |) + |) + |))) + ] + |) + |))) + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_dev_VerifyFailure. + + Module Impl_core_fmt_Display_for_halo2_proofs_dev_VerifyFailure. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::VerifyFailure". + + (* + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::CellNotAssigned { + gate, + region, + column, + offset, + } => { + write!( + f, + "{} uses {}, which requires cell in column {:?} at offset {} to be assigned.", + region, gate, column, offset + ) + } + Self::ConstraintNotSatisfied { + constraint, + location, + cell_values, + } => { + writeln!(f, "{} is not satisfied {}", constraint, location)?; + for (name, value) in cell_values { + writeln!(f, "- {} = {}", name, value)?; + } + Ok(()) + } + Self::ConstraintPoisoned { constraint } => { + write!( + f, + "{} is active on an unusable row - missing selector?", + constraint + ) + } + Self::Lookup { + name, + lookup_index, + location, + } => { + write!( + f, + "Lookup {}(index: {}) is not satisfied {}", + name, lookup_index, location + ) + } + Self::Permutation { column, row } => { + write!( + f, + "Equality constraint not satisfied by cell ({:?}, {})", + column, row + ) + } + } + } + *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::CellNotAssigned", + "gate" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::CellNotAssigned", + "region" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::CellNotAssigned", + "column" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::CellNotAssigned", + "offset" + |) in + let gate := M.alloc (| γ1_0 |) in + let region := M.alloc (| γ1_1 |) in + let column := M.alloc (| γ1_2 |) in + let offset := M.alloc (| γ1_3 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "" |); + M.read (| Value.String " uses " |); + M.read (| + Value.String ", which requires cell in column " + |); + M.read (| Value.String " at offset " |); + M.read (| Value.String " to be assigned." |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "halo2_proofs::dev::metadata::Region" ] + ] + |), + [ region ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "halo2_proofs::dev::metadata::Gate" ] + ] + |), + [ gate ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + |), + [ column ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "isize" ] ] + |), + [ offset ] + |) + ] + |)) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::ConstraintNotSatisfied", + "constraint" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::ConstraintNotSatisfied", + "location" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::ConstraintNotSatisfied", + "cell_values" + |) in + let constraint := M.alloc (| γ1_0 |) in + let location := M.alloc (| γ1_1 |) in + let cell_values := M.alloc (| γ1_2 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "core::fmt::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "" |); + M.read (| Value.String " is not satisfied " |); + M.read (| Value.String " +" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::dev::metadata::Constraint" + ] + ] + |), + [ constraint ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::dev::FailureLocation" + ] + ] + |), + [ location ] + |) + ] + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "core::fmt::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "core::fmt::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ M.read (| cell_values |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String" + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ2_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let name := M.alloc (| γ2_0 |) in + let value := M.alloc (| γ2_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "core::fmt::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String "- " + |); + M.read (| + Value.String " = " + |); + M.read (| + Value.String " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::dev::metadata::VirtualCell" + ] + ] + |), + [ name ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "alloc::string::String" + ] + ] + |), + [ value ] + |) + ] + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "core::fmt::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "core::fmt::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::ConstraintPoisoned", + "constraint" + |) in + let constraint := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "" |); + M.read (| + Value.String + " is active on an unusable row - missing selector?" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::dev::metadata::Constraint" + ] + ] + |), + [ constraint ] + |) + ] + |)) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::Lookup", + "name" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::Lookup", + "lookup_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::Lookup", + "location" + |) in + let name := M.alloc (| γ1_0 |) in + let lookup_index := M.alloc (| γ1_1 |) in + let location := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "Lookup " |); + M.read (| Value.String "(index: " |); + M.read (| Value.String ") is not satisfied " |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + ] + |), + [ name ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "usize" ] ] + |), + [ lookup_index ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "halo2_proofs::dev::FailureLocation" ] + ] + |), + [ location ] + |) + ] + |)) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::Permutation", + "column" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::dev::VerifyFailure::Permutation", + "row" + |) in + let column := M.alloc (| γ1_0 |) in + let row := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "Equality constraint not satisfied by cell (" + |); + M.read (| Value.String ", " |); + M.read (| Value.String ")" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "halo2_proofs::dev::metadata::Column" ] + ] + |), + [ column ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "usize" ] ] + |), + [ row ] + |) + ] + |)) + ] + |) + ] + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Display" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Display_for_halo2_proofs_dev_VerifyFailure. + + (* StructRecord + { + name := "Region"; + ty_params := []; + fields := + [ + ("name", Ty.path "alloc::string::String"); + ("columns", + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "std::hash::random::RandomState" + ]); + ("rows", + Ty.apply + (Ty.path "core::option::Option") + [ Ty.tuple [ Ty.path "usize"; Ty.path "usize" ] ]); + ("enabled_selectors", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::hash::random::RandomState" + ]); + ("cells", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "usize" + ]; + Ty.path "usize"; + Ty.path "std::hash::random::RandomState" + ]) + ]; + } *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_dev_Region. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::Region". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field5_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Region" |); + M.read (| Value.String "name" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::Region", + "name" + |)); + M.read (| Value.String "columns" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::Region", + "columns" + |)); + M.read (| Value.String "rows" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::Region", + "rows" + |)); + M.read (| Value.String "enabled_selectors" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::Region", + "enabled_selectors" + |)); + M.read (| Value.String "cells" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::Region", + "cells" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_dev_Region. + + Module Impl_halo2_proofs_dev_Region. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::Region". + + (* + fn update_extent(&mut self, column: Column, row: usize) { + self.columns.insert(column); + + // The region start is the earliest row assigned to. + // The region end is the latest row assigned to. + let (mut start, mut end) = self.rows.unwrap_or((row, row)); + if row < start { + // The first row assigned was not at start 0 within the region. + start = row; + } + if row > end { + end = row; + } + self.rows = Some((start, end)); + } + *) + Definition update_extent (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; column; row ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + let row := M.alloc (| row |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::Region", + "columns" + |); + M.read (| column |) + ] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.tuple [ Ty.path "usize"; Ty.path "usize" ] ], + "unwrap_or", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::Region", + "rows" + |) + |); + Value.Tuple [ M.read (| row |); M.read (| row |) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let start := M.copy (| γ0_0 |) in + let end_ := M.copy (| γ0_1 |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt (M.read (| row |)) (M.read (| start |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := M.write (| start, M.read (| row |) |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt (M.read (| row |)) (M.read (| end_ |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := M.write (| end_, M.read (| row |) |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::Region", + "rows" + |), + Value.StructTuple + "core::option::Option::Some" + [ Value.Tuple [ M.read (| start |); M.read (| end_ |) ] ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_update_extent : + M.IsAssociatedFunction Self "update_extent" update_extent. + + (* + fn track_cell(&mut self, column: Column, row: usize) { + // Keep track of how many times this cell has been assigned to. + let count = *self.cells.get(&(column, row)).unwrap_or(&0); + self.cells.insert((column, row), count + 1); + } + *) + Definition track_cell (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; column; row ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + let row := M.alloc (| row |) in + M.read (| + let count := + M.copy (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.path "usize" ] ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "usize" + ]; + Ty.path "usize"; + Ty.path "std::hash::random::RandomState" + ], + "get", + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "usize" + ] + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::Region", + "cells" + |); + M.alloc (| Value.Tuple [ M.read (| column |); M.read (| row |) ] |) + ] + |); + M.alloc (| Value.Integer 0 |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "usize" + ]; + Ty.path "usize"; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::Region", + "cells" + |); + Value.Tuple [ M.read (| column |); M.read (| row |) ]; + BinOp.Panic.add (| Integer.Usize, M.read (| count |), Value.Integer 1 |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_track_cell : M.IsAssociatedFunction Self "track_cell" track_cell. + + (* + fn is_assigned(&self, column: Column, row: usize) -> bool { + self.cells.contains_key(&(column, row)) + } + *) + Definition is_assigned (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; column; row ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + let row := M.alloc (| row |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "usize" + ]; + Ty.path "usize"; + Ty.path "std::hash::random::RandomState" + ], + "contains_key", + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "usize" + ] + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::Region", + "cells" + |); + M.alloc (| Value.Tuple [ M.read (| column |); M.read (| row |) ] |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_is_assigned : M.IsAssociatedFunction Self "is_assigned" is_assigned. + End Impl_halo2_proofs_dev_Region. + + (* + Enum CellValue + { + ty_params := [ "F" ]; + variants := + [ + { + name := "Unassigned"; + item := StructTuple []; + discriminant := None; + }; + { + name := "Assigned"; + item := StructTuple [ F ]; + discriminant := None; + }; + { + name := "Poison"; + item := StructTuple [ Ty.path "usize" ]; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_CellValue_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| Value.StructTuple "halo2_proofs::dev::CellValue::Unassigned" [] |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::dev::CellValue::Assigned", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::dev::CellValue::Assigned" + [ + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", F, [], "clone", [] |), + [ M.read (| __self_0 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::dev::CellValue::Poison", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::dev::CellValue::Poison" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "usize", + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_CellValue_F. + + Module Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_CellValue_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_CellValue_F. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_CellValue_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_str", + [] + |), + [ M.read (| f |); M.read (| Value.String "Unassigned" |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::dev::CellValue::Assigned", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Assigned" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::dev::CellValue::Poison", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Poison" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_CellValue_F. + + Module Impl_core_marker_StructuralPartialEq_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_CellValue_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::StructuralPartialEq" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_CellValue_F. + + Module Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_CellValue_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ]. + + (* PartialEq *) + Definition eq (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ] ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ] ] + |), + [ M.read (| other |) ] + |) + |) in + M.alloc (| + LogicalOp.and (| + BinOp.Pure.eq (M.read (| __self_tag |)) (M.read (| __arg1_tag |)), + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| other |) ] |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::dev::CellValue::Assigned", + 0 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::dev::CellValue::Assigned", + 0 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::cmp::PartialEq", F, [ F ], "eq", [] |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::dev::CellValue::Poison", + 0 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::dev::CellValue::Poison", + 0 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + M.alloc (| + BinOp.Pure.eq + (M.read (| M.read (| __self_0 |) |)) + (M.read (| M.read (| __arg1_0 |) |)) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Bool true |))) + ] + |) + |))) + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::cmp::PartialEq" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method (eq F)) ]. + End Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_CellValue_F. + + Module Impl_core_marker_StructuralEq_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_CellValue_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::StructuralEq" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralEq_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_CellValue_F. + + Module Impl_core_cmp_Eq_where_core_cmp_Eq_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_CellValue_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ]. + + (* Eq *) + Definition assert_receiver_is_total_eq (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::cmp::Eq" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("assert_receiver_is_total_eq", InstanceField.Method (assert_receiver_is_total_eq F)) ]. + End Impl_core_cmp_Eq_where_core_cmp_Eq_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_CellValue_F. + + (* + Enum Value + { + ty_params := [ "F" ]; + variants := + [ + { + name := "Real"; + item := StructTuple [ F ]; + discriminant := None; + }; + { + name := "Poison"; + item := StructTuple []; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::dev::Value::Real", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::dev::Value::Real" + [ + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", F, [], "clone", [] |), + [ M.read (| __self_0 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| Value.StructTuple "halo2_proofs::dev::Value::Poison" [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + + Module Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::dev::Value::Real", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Real" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_str", + [] + |), + [ M.read (| f |); M.read (| Value.String "Poison" |) ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + + Module Impl_core_marker_StructuralPartialEq_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::StructuralPartialEq" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + + Module Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ]. + + (* PartialEq *) + Definition eq (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ] ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ] ] + |), + [ M.read (| other |) ] + |) + |) in + M.alloc (| + LogicalOp.and (| + BinOp.Pure.eq (M.read (| __self_tag |)) (M.read (| __arg1_tag |)), + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| other |) ] |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::dev::Value::Real", + 0 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::dev::Value::Real", + 0 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::cmp::PartialEq", F, [ F ], "eq", [] |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Bool true |))) + ] + |) + |))) + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::cmp::PartialEq" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method (eq F)) ]. + End Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + + Module Impl_core_marker_StructuralEq_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::StructuralEq" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralEq_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + + Module Impl_core_cmp_Eq_where_core_cmp_Eq_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ]. + + (* Eq *) + Definition assert_receiver_is_total_eq (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::cmp::Eq" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("assert_receiver_is_total_eq", InstanceField.Method (assert_receiver_is_total_eq F)) ]. + End Impl_core_cmp_Eq_where_core_cmp_Eq_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + + Module Impl_core_cmp_Ord_where_core_cmp_Ord_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ]. + + (* Ord *) + Definition cmp (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ] ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ] ] + |), + [ M.read (| other |) ] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::cmp::Ord", Ty.path "isize", [], "cmp", [] |), + [ __self_tag; __arg1_tag ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| other |) ] |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::dev::Value::Real", + 0 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::dev::Value::Real", + 0 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::cmp::Ord", F, [], "cmp", [] |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "core::cmp::Ordering::Equal" [] |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let cmp := M.copy (| γ |) in + cmp)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::cmp::Ord" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("cmp", InstanceField.Method (cmp F)) ]. + End Impl_core_cmp_Ord_where_core_cmp_Ord_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + + Module Impl_core_cmp_PartialOrd_where_core_cmp_PartialOrd_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ]. + + (* PartialOrd *) + Definition partial_cmp (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ] ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ] ] + |), + [ M.read (| other |) ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| other |) ] |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::dev::Value::Real", + 0 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::dev::Value::Real", + 0 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + F, + [ F ], + "partial_cmp", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "isize", + [ Ty.path "isize" ], + "partial_cmp", + [] + |), + [ __self_tag; __arg1_tag ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::cmp::PartialOrd" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("partial_cmp", InstanceField.Method (partial_cmp F)) ]. + End Impl_core_cmp_PartialOrd_where_core_cmp_PartialOrd_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + + Module Impl_core_convert_From_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_halo2_proofs_dev_CellValue_F_for_halo2_proofs_dev_Value_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ]. + + (* + fn from(value: CellValue) -> Self { + match value { + // Cells that haven't been explicitly assigned to, default to zero. + CellValue::Unassigned => Value::Real(F::zero()), + CellValue::Assigned(v) => Value::Real(v), + CellValue::Poison(_) => Value::Poison, + } + } + *) + Definition from (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ value ] => + ltac:(M.monadic + (let value := M.alloc (| value |) in + M.read (| + M.match_operator (| + value, + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "halo2_proofs::dev::Value::Real" + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "zero", [] |), + [] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::dev::CellValue::Assigned", + 0 + |) in + let v := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructTuple "halo2_proofs::dev::Value::Real" [ M.read (| v |) ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::dev::CellValue::Poison", + 0 + |) in + M.alloc (| Value.StructTuple "halo2_proofs::dev::Value::Poison" [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::convert::From" + (Self F) + (* Trait polymorphic types *) + [ (* T *) Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ] ] + (* Instance *) [ ("from", InstanceField.Method (from F)) ]. + End Impl_core_convert_From_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_halo2_proofs_dev_CellValue_F_for_halo2_proofs_dev_Value_F. + + Module Impl_core_ops_arith_Neg_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ]. + + (* type Output = Self; *) + Definition _Output (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ]. + + (* + fn neg(self) -> Self::Output { + match self { + Value::Real(a) => Value::Real(-a), + _ => Value::Poison, + } + } + *) + Definition neg (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::dev::Value::Real", + 0 + |) in + let a := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::dev::Value::Real" + [ + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Neg", F, [], "neg", [] |), + [ M.read (| a |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "halo2_proofs::dev::Value::Poison" [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::Neg" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F)); ("neg", InstanceField.Method (neg F)) ]. + End Impl_core_ops_arith_Neg_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + + Module Impl_core_ops_arith_Add_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ]. + + (* type Output = Self; *) + Definition _Output (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ]. + + (* + fn add(self, rhs: Self) -> Self::Output { + match (self, rhs) { + (Value::Real(a), Value::Real(b)) => Value::Real(a + b), + _ => Value::Poison, + } + } + *) + Definition add (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| rhs |) ] |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::dev::Value::Real", + 0 + |) in + let a := M.copy (| γ1_0 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::dev::Value::Real", + 0 + |) in + let b := M.copy (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::dev::Value::Real" + [ + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Add", F, [ F ], "add", [] |), + [ M.read (| a |); M.read (| b |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "halo2_proofs::dev::Value::Poison" [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::Add" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F)); ("add", InstanceField.Method (add F)) ]. + End Impl_core_ops_arith_Add_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + + Module Impl_core_ops_arith_Mul_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ]. + + (* type Output = Self; *) + Definition _Output (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ]. + + (* + fn mul(self, rhs: Self) -> Self::Output { + match (self, rhs) { + (Value::Real(a), Value::Real(b)) => Value::Real(a * b), + // If poison is multiplied by zero, then we treat the poison as unconstrained + // and we don't propagate it. + (Value::Real(x), Value::Poison) | (Value::Poison, Value::Real(x)) + if x.is_zero_vartime() => + { + Value::Real(F::zero()) + } + _ => Value::Poison, + } + } + *) + Definition mul (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| rhs |) ] |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::dev::Value::Real", + 0 + |) in + let a := M.copy (| γ1_0 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::dev::Value::Real", + 0 + |) in + let b := M.copy (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::dev::Value::Real" + [ + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Mul", F, [ F ], "mul", [] |), + [ M.read (| a |); M.read (| b |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::dev::Value::Real", + 0 + |) in + let x := M.copy (| γ1_0 |) in + Value.Tuple [ x ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::dev::Value::Real", + 0 + |) in + let x := M.copy (| γ1_0 |) in + Value.Tuple [ x ])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ x ] => + let γ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "is_zero_vartime", + [] + |), + [ x ] + |) + |) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::dev::Value::Real" + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "zero", [] |), + [] + |) + ] + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "halo2_proofs::dev::Value::Poison" [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::Mul" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F)); ("mul", InstanceField.Method (mul F)) ]. + End Impl_core_ops_arith_Mul_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_Value_F. + + Module Impl_core_ops_arith_Mul_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_F_for_halo2_proofs_dev_Value_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ]. + + (* type Output = Self; *) + Definition _Output (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::Value") [ F ]. + + (* + fn mul(self, rhs: F) -> Self::Output { + match self { + Value::Real(lhs) => Value::Real(lhs * rhs), + // If poison is multiplied by zero, then we treat the poison as unconstrained + // and we don't propagate it. + Value::Poison if rhs.is_zero_vartime() => Value::Real(F::zero()), + _ => Value::Poison, + } + } + *) + Definition mul (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::dev::Value::Real", + 0 + |) in + let lhs := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::dev::Value::Real" + [ + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Mul", F, [ F ], "mul", [] |), + [ M.read (| lhs |); M.read (| rhs |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "is_zero_vartime", [] |), + [ rhs ] + |) + |) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::dev::Value::Real" + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "zero", [] |), + [] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "halo2_proofs::dev::Value::Poison" [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::Mul" + (Self F) + (* Trait polymorphic types *) [ (* Rhs *) F ] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F)); ("mul", InstanceField.Method (mul F)) ]. + End Impl_core_ops_arith_Mul_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_F_for_halo2_proofs_dev_Value_F. + + (* StructRecord + { + name := "MockProver"; + ty_params := [ "F" ]; + fields := + [ + ("k", Ty.path "u32"); + ("n", Ty.path "u32"); + ("cs", Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ]); + ("regions", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "halo2_proofs::dev::Region"; Ty.path "alloc::alloc::Global" ]); + ("current_region", + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::dev::Region"; + Ty.apply (Ty.path "std::sync::mutex::MutexGuard") [ Ty.tuple [] ] + ] + ]); + ("fixed", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]); + ("advice", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]); + ("instance", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]); + ("selectors", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]); + ("permutation", Ty.path "halo2_proofs::plonk::permutation::keygen::ParallelAssembly"); + ("usable_rows", Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_MockProver_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let names := + M.alloc (| + M.alloc (| + Value.Array + [ + M.read (| Value.String "k" |); + M.read (| Value.String "n" |); + M.read (| Value.String "cs" |); + M.read (| Value.String "regions" |); + M.read (| Value.String "current_region" |); + M.read (| Value.String "fixed" |); + M.read (| Value.String "advice" |); + M.read (| Value.String "instance" |); + M.read (| Value.String "selectors" |); + M.read (| Value.String "permutation" |); + M.read (| Value.String "usable_rows" |) + ] + |) + |) in + let values := + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockProver", + "k" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockProver", + "n" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockProver", + "cs" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockProver", + "regions" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockProver", + "current_region" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockProver", + "fixed" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockProver", + "advice" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockProver", + "instance" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockProver", + "selectors" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockProver", + "permutation" + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockProver", + "usable_rows" + |) + |)) + ] + |)) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_fields_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "MockProver" |); + (* Unsize *) M.pointer_coercion (M.read (| names |)); + M.read (| values |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_MockProver_F. + + (* StructRecord + { + name := "MockVerifier"; + ty_params := [ "F" ]; + fields := + [ + ("n", Ty.path "u32"); + ("cs", Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ]); + ("regions", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "halo2_proofs::dev::Region"; Ty.path "alloc::alloc::Global" ]); + ("fixed", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]); + ("advice", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]); + ("instance", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]); + ("permutation", Ty.path "halo2_proofs::plonk::permutation::keygen::Assembly"); + ("usable_rows", Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_MockVerifier_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::MockVerifier") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let names := + M.alloc (| + M.alloc (| + Value.Array + [ + M.read (| Value.String "n" |); + M.read (| Value.String "cs" |); + M.read (| Value.String "regions" |); + M.read (| Value.String "fixed" |); + M.read (| Value.String "advice" |); + M.read (| Value.String "instance" |); + M.read (| Value.String "permutation" |); + M.read (| Value.String "usable_rows" |) + ] + |) + |) in + let values := + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "n" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "cs" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "regions" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "fixed" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "advice" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "instance" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "permutation" + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "usable_rows" + |) + |)) + ] + |)) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_fields_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "MockVerifier" |); + (* Unsize *) M.pointer_coercion (M.read (| names |)); + M.read (| values |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_for_halo2_proofs_dev_MockVerifier_F. + + Module Impl_core_convert_Into_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_halo2_proofs_dev_MockVerifier_F_for_halo2_proofs_dev_MockProver_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ]. + + (* + fn into(self) -> MockVerifier { + MockVerifier { + n: self.n, + cs: self.cs, + regions: self.regions, + fixed: self.fixed, + advice: self.advice, + instance: self.instance, + permutation: self.permutation.into(), + usable_rows: self.usable_rows, + } + } + *) + Definition into (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::dev::MockVerifier" + [ + ("n", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::dev::MockProver", + "n" + |) + |)); + ("cs", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::dev::MockProver", + "cs" + |) + |)); + ("regions", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::dev::MockProver", + "regions" + |) + |)); + ("fixed", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::dev::MockProver", + "fixed" + |) + |)); + ("advice", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::dev::MockProver", + "advice" + |) + |)); + ("instance", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::dev::MockProver", + "instance" + |) + |)); + ("permutation", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + [ Ty.path "halo2_proofs::plonk::permutation::keygen::Assembly" ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::dev::MockProver", + "permutation" + |) + |) + ] + |)); + ("usable_rows", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::dev::MockProver", + "usable_rows" + |) + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::convert::Into" + (Self F) + (* Trait polymorphic types *) + [ (* T *) Ty.apply (Ty.path "halo2_proofs::dev::MockVerifier") [ F ] ] + (* Instance *) [ ("into", InstanceField.Method (into F)) ]. + End Impl_core_convert_Into_where_pairing_bn256_arithmetic_Group_F_where_ff_Field_F_halo2_proofs_dev_MockVerifier_F_for_halo2_proofs_dev_MockProver_F. + + Module Impl_halo2_proofs_plonk_circuit_Assignment_where_ff_Field_F_where_pairing_bn256_arithmetic_Group_F_F_for_halo2_proofs_parallel_Parallel_halo2_proofs_dev_MockProver_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ]. + + (* + fn is_in_prove_mode(&self) -> bool { + false + } + *) + Definition is_in_prove_mode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.Bool false)) + | _, _ => M.impossible + end. + + (* + fn enter_region(&self, name: N) + where + NR: Into, + N: FnOnce() -> NR, + { + let region_lock = REGION_LOCK.lock().unwrap(); + + let mut prover = self.lock().unwrap(); + + assert!(prover.current_region.is_none()); + prover.current_region = Some(( + Region { + name: name().into(), + columns: HashSet::default(), + rows: None, + enabled_selectors: HashMap::default(), + cells: HashMap::default(), + }, + region_lock, + )); + } + *) + Definition enter_region (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ NR; N ], [ self; name ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + M.read (| + let region_lock := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "std::sync::mutex::MutexGuard") [ Ty.tuple [] ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ Ty.apply (Ty.path "std::sync::mutex::MutexGuard") [ Ty.tuple [] ] ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "std::sync::mutex::Mutex") [ Ty.tuple [] ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "halo2_proofs::dev::REGION_LOCK", + [], + "deref", + [] + |), + [ M.read (| M.get_constant (| "halo2_proofs::dev::REGION_LOCK" |) |) ] + |) + ] + |) + ] + |) + |) in + let prover := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ], + "lock", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::dev::Region"; + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.tuple [] ] + ] + ], + "is_none", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] + ], + [], + "deref", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "current_region" + |) + ] + |)) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "assertion failed: prover.current_region.is_none()" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ], + [], + "deref_mut", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "current_region" + |), + Value.StructTuple + "core::option::Option::Some" + [ + Value.Tuple + [ + Value.StructRecord + "halo2_proofs::dev::Region" + [ + ("name", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + NR, + [ Ty.path "alloc::string::String" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + N, + [ Ty.tuple [] ], + "call_once", + [] + |), + [ M.read (| name |); Value.Tuple [] ] + |) + ] + |)); + ("columns", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "std::hash::random::RandomState" + ], + [], + "default", + [] + |), + [] + |)); + ("rows", Value.StructTuple "core::option::Option::None" []); + ("enabled_selectors", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::hash::random::RandomState" + ], + [], + "default", + [] + |), + [] + |)); + ("cells", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "usize" + ]; + Ty.path "usize"; + Ty.path "std::hash::random::RandomState" + ], + [], + "default", + [] + |), + [] + |)) + ]; + M.read (| region_lock |) + ] + ] + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + (* + fn exit_region(&self) { + let mut prover = self.lock().unwrap(); + + let (region, _) = prover.current_region.take().unwrap(); + prover.regions.push(region); + } + *) + Definition exit_region (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let prover := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ], + "lock", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::dev::Region"; + Ty.apply (Ty.path "std::sync::mutex::MutexGuard") [ Ty.tuple [] ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::dev::Region"; + Ty.apply (Ty.path "std::sync::mutex::MutexGuard") [ Ty.tuple [] ] + ] + ], + "take", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ], + [], + "deref_mut", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "current_region" + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let region := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "halo2_proofs::dev::Region"; Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ], + [], + "deref_mut", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "regions" + |); + M.read (| region |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + fn enable_selector(&self, _: A, selector: &Selector, row: usize) -> Result<(), Error> + where + A: FnOnce() -> AR, + AR: Into, + { + let mut prover = self.lock().unwrap(); + + if !prover.usable_rows.contains(&row) { + return Err(Error::not_enough_rows_available(prover.k)); + } + + // Track that this selector was enabled. We require that all selectors are enabled + // inside some region (i.e. no floating selectors). + prover + .current_region + .as_mut() + .unwrap() + .0 + .enabled_selectors + .entry( *selector) + .or_default() + .push(row); + + prover.selectors[selector.0][row] = true; + + Ok(()) + } + *) + Definition enable_selector (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ A; AR ], [ self; β1; selector; row ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let selector := M.alloc (| selector |) in + let row := M.alloc (| row |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.catch_return (| + ltac:(M.monadic + (M.read (| + let prover := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ], + "lock", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + "contains", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::MockProver") + [ F ] + ], + [], + "deref", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "usable_rows" + |); + row + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::error::Error", + "not_enough_rows_available", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::MockProver") + [ F ] + ], + [], + "deref", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "k" + |) + |) + ] + |) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::Entry") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ] + ], + "or_default", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::hash::random::RandomState" + ], + "entry", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_tuple_field (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::dev::Region"; + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ Ty.tuple [] ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::dev::Region"; + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ Ty.tuple [] ] + ] + ], + "as_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::MockProver") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "current_region" + |) + ] + |) + ] + |), + 0 + |), + "halo2_proofs::dev::Region", + "enabled_selectors" + |); + M.read (| M.read (| selector |) |) + ] + |) + ] + |); + M.read (| row |) + ] + |) + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::MockProver") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "selectors" + |); + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| selector |), + "halo2_proofs::plonk::circuit::Selector", + 0 + |) + |) + ] + |); + M.read (| row |) + ] + |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |) + |))) + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn query_instance(&self, column: Column, row: usize) -> Result, Error> { + let prover = self.lock().unwrap(); + + if !prover.usable_rows.contains(&row) { + return Err(Error::not_enough_rows_available(prover.k)); + } + + prover + .instance + .get(column.index()) + .and_then(|column| column.get(row)) + .map(|v| Some( *v)) + .ok_or(Error::BoundsFailure) + } + *) + Definition query_instance (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; column; row ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + let row := M.alloc (| row |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let prover := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ], + "lock", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + "contains", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::MockProver") + [ F ] + ], + [], + "deref", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "usable_rows" + |); + row + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::error::Error", + "not_enough_rows_available", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::MockProver") + [ F ] + ], + [], + "deref", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "k" + |) + |) + ] + |) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "core::option::Option") [ F ] ], + "ok_or", + [ Ty.path "halo2_proofs::plonk::error::Error" ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ F ] ], + "map", + [ + Ty.apply (Ty.path "core::option::Option") [ F ]; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ F ] ] ] + (Ty.apply (Ty.path "core::option::Option") [ F ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ] + ] + ], + "and_then", + [ + Ty.apply (Ty.path "&") [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ F ] ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ] + ], + "get", + [ Ty.path "usize" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::MockProver") + [ F ] + ], + [], + "deref", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "instance" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ], + "index", + [] + |), + [ column ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let column := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "get", + [ Ty.path "usize" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ M.read (| column |) ] + |); + M.read (| row |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let v := M.copy (| γ |) in + Value.StructTuple + "core::option::Option::Some" + [ M.read (| M.read (| v |) |) ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + Value.StructTuple "halo2_proofs::plonk::error::Error::BoundsFailure" [] + ] + |) + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn assign_advice( + &self, + _: A, + column: Column, + row: usize, + to: V, + ) -> Result<(), Error> + where + V: FnOnce() -> Result, + VR: Into>, + A: FnOnce() -> AR, + AR: Into, + { + let mut prover = self.lock().unwrap(); + + if !prover.usable_rows.contains(&row) { + return Err(Error::not_enough_rows_available(prover.k)); + } + + if let Some((region, _)) = prover.current_region.as_mut() { + region.update_extent(column.into(), row); + region.track_cell(column.into(), row); + } + + *prover + .advice + .get_mut(column.index()) + .and_then(|v| v.get_mut(row)) + .ok_or(Error::BoundsFailure)? = CellValue::Assigned(to()?.into().evaluate()); + + Ok(()) + } + *) + Definition assign_advice (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ V; VR; A; AR ], [ self; β1; column; row; to ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let column := M.alloc (| column |) in + let row := M.alloc (| row |) in + let to := M.alloc (| to |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.catch_return (| + ltac:(M.monadic + (M.read (| + let prover := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ], + "lock", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + "contains", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::MockProver") + [ F ] + ], + [], + "deref", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "usable_rows" + |); + row + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::error::Error", + "not_enough_rows_available", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::MockProver") + [ F ] + ], + [], + "deref", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "k" + |) + |) + ] + |) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::dev::Region"; + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.tuple [] ] + ] + ], + "as_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::MockProver") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "current_region" + |) + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ2_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let region := M.alloc (| γ2_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::Region", + "update_extent", + [] + |), + [ + M.read (| region |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "into", + [] + |), + [ M.read (| column |) ] + |); + M.read (| row |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::Region", + "track_cell", + [] + |), + [ + M.read (| region |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "into", + [] + |), + [ M.read (| column |) ] + |); + M.read (| row |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.write (| + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::CellValue") + [ F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::CellValue") + [ F ] + ] + ], + "ok_or", + [ Ty.path "halo2_proofs::plonk::error::Error" ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::CellValue") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "and_then", + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::CellValue") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::CellValue") + [ F ] + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::CellValue") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ], + "get_mut", + [ Ty.path "usize" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::MockProver") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "advice" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ], + "index", + [] + |), + [ column ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let v := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ] + ], + "get_mut", + [ Ty.path "usize" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ M.read (| v |) ] + |); + M.read (| row |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::error::Error::BoundsFailure" + [] + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |), + Value.StructTuple + "halo2_proofs::dev::CellValue::Assigned" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ], + "evaluate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + VR, + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ], + "into", + [] + |), + [ + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + VR; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + V, + [ Ty.tuple [] ], + "call_once", + [] + |), + [ M.read (| to |); Value.Tuple [] ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) + ] + |) + ] + |) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |) + |))) + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign_fixed( + &self, + _: A, + column: Column, + row: usize, + to: V, + ) -> Result<(), Error> + where + V: FnOnce() -> Result, + VR: Into>, + A: FnOnce() -> AR, + AR: Into, + { + let mut prover = self.lock().unwrap(); + + if !prover.usable_rows.contains(&row) { + return Err(Error::not_enough_rows_available(prover.k)); + } + + if let Some((region, _)) = prover.current_region.as_mut() { + region.update_extent(column.into(), row); + region.track_cell(column.into(), row); + } + + *prover + .fixed + .get_mut(column.index()) + .and_then(|v| v.get_mut(row)) + .ok_or(Error::BoundsFailure)? = CellValue::Assigned(to()?.into().evaluate()); + + Ok(()) + } + *) + Definition assign_fixed (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ V; VR; A; AR ], [ self; β1; column; row; to ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let column := M.alloc (| column |) in + let row := M.alloc (| row |) in + let to := M.alloc (| to |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.catch_return (| + ltac:(M.monadic + (M.read (| + let prover := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ], + "lock", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + "contains", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::MockProver") + [ F ] + ], + [], + "deref", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "usable_rows" + |); + row + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::error::Error", + "not_enough_rows_available", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::MockProver") + [ F ] + ], + [], + "deref", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "k" + |) + |) + ] + |) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::dev::Region"; + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.tuple [] ] + ] + ], + "as_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::MockProver") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "current_region" + |) + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ2_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let region := M.alloc (| γ2_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::Region", + "update_extent", + [] + |), + [ + M.read (| region |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "into", + [] + |), + [ M.read (| column |) ] + |); + M.read (| row |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::Region", + "track_cell", + [] + |), + [ + M.read (| region |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "into", + [] + |), + [ M.read (| column |) ] + |); + M.read (| row |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.write (| + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::CellValue") + [ F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::CellValue") + [ F ] + ] + ], + "ok_or", + [ Ty.path "halo2_proofs::plonk::error::Error" ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::CellValue") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "and_then", + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::CellValue") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::CellValue") + [ F ] + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::CellValue") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ], + "get_mut", + [ Ty.path "usize" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::MockProver") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "fixed" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ], + "index", + [] + |), + [ column ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let v := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ] + ], + "get_mut", + [ Ty.path "usize" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ M.read (| v |) ] + |); + M.read (| row |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::error::Error::BoundsFailure" + [] + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |), + Value.StructTuple + "halo2_proofs::dev::CellValue::Assigned" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ], + "evaluate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + VR, + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ], + "into", + [] + |), + [ + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + VR; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + V, + [ Ty.tuple [] ], + "call_once", + [] + |), + [ M.read (| to |); Value.Tuple [] ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) + ] + |) + ] + |) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |) + |))) + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn copy( + &self, + left_column: Column, + left_row: usize, + right_column: Column, + right_row: usize, + ) -> Result<(), crate::plonk::Error> { + let mut prover = self.lock().unwrap(); + + if !prover.usable_rows.contains(&left_row) || !prover.usable_rows.contains(&right_row) { + return Err(Error::not_enough_rows_available(prover.k)); + } + + prover + .permutation + .copy(left_column, left_row, right_column, right_row) + } + *) + Definition copy (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; left_column; left_row; right_column; right_row ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let left_column := M.alloc (| left_column |) in + let left_row := M.alloc (| left_row |) in + let right_column := M.alloc (| right_column |) in + let right_row := M.alloc (| right_row |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let prover := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ], + "lock", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.or (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + "contains", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::MockProver") + [ F ] + ], + [], + "deref", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "usable_rows" + |); + left_row + ] + |)), + ltac:(M.monadic + (UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + "contains", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::MockProver") + [ F ] + ], + [], + "deref", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "usable_rows" + |); + right_row + ] + |)))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::error::Error", + "not_enough_rows_available", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::MockProver") + [ F ] + ], + [], + "deref", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "k" + |) + |) + ] + |) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "copy", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ], + [], + "deref_mut", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "permutation" + |); + M.read (| left_column |); + M.read (| left_row |); + M.read (| right_column |); + M.read (| right_row |) + ] + |) + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn fill_from_row( + &self, + col: Column, + from_row: usize, + to: Option>, + ) -> Result<(), Error> { + let prover = self.lock().unwrap(); + + if !prover.usable_rows.contains(&from_row) { + return Err(Error::not_enough_rows_available(prover.k)); + } + + let usable_rows = prover.usable_rows.clone(); + drop(prover); + + for row in usable_rows.skip(from_row) { + self.assign_fixed(|| "", col, row, || to.ok_or(Error::Synthesis))?; + } + + Ok(()) + } + *) + Definition fill_from_row (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; col; from_row; to ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let col := M.alloc (| col |) in + let from_row := M.alloc (| from_row |) in + let to := M.alloc (| to |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let prover := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ], + "lock", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + "contains", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::MockProver") + [ F ] + ], + [], + "deref", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "usable_rows" + |); + from_row + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::error::Error", + "not_enough_rows_available", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::MockProver") + [ F ] + ], + [], + "deref", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "k" + |) + |) + ] + |) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let usable_rows := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ], + [], + "deref", + [] + |), + [ prover ] + |), + "halo2_proofs::dev::MockProver", + "usable_rows" + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::mem::drop", + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ] + ] + |), + [ M.read (| prover |) ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::skip::Skip") + [ Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ] ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "skip", + [] + |), + [ M.read (| usable_rows |); M.read (| from_row |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let row := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Assignment", + Ty.apply + (Ty.path + "halo2_proofs::parallel::Parallel") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::MockProver") + [ F ] + ], + [ F ], + "assign_fixed", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| self |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String "" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| col |); + M.read (| row |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ], + "ok_or", + [ + Ty.path + "halo2_proofs::plonk::error::Error" + ] + |), + [ + M.read (| to |); + Value.StructTuple + "halo2_proofs::plonk::error::Error::Synthesis" + [] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn push_namespace(&self, _: N) + where + NR: Into, + N: FnOnce() -> NR, + { + // TODO: Do something with namespaces :) + } + *) + Definition push_namespace (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ NR; N ], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Tuple [])) ] |))) + | _, _ => M.impossible + end. + + (* + fn pop_namespace(&self, _: Option) { + // TODO: Do something with namespaces :) + } + *) + Definition pop_namespace (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Tuple [])) ] |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "halo2_proofs::plonk::circuit::Assignment" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("is_in_prove_mode", InstanceField.Method (is_in_prove_mode F)); + ("enter_region", InstanceField.Method (enter_region F)); + ("exit_region", InstanceField.Method (exit_region F)); + ("enable_selector", InstanceField.Method (enable_selector F)); + ("query_instance", InstanceField.Method (query_instance F)); + ("assign_advice", InstanceField.Method (assign_advice F)); + ("assign_fixed", InstanceField.Method (assign_fixed F)); + ("copy", InstanceField.Method (copy F)); + ("fill_from_row", InstanceField.Method (fill_from_row F)); + ("push_namespace", InstanceField.Method (push_namespace F)); + ("pop_namespace", InstanceField.Method (pop_namespace F)) + ]. + End Impl_halo2_proofs_plonk_circuit_Assignment_where_ff_Field_F_where_pairing_bn256_arithmetic_Group_F_F_for_halo2_proofs_parallel_Parallel_halo2_proofs_dev_MockProver_F. + + Module Impl_halo2_proofs_dev_MockProver_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ]. + + (* + pub fn run>( + k: u32, + circuit: &ConcreteCircuit, + instance: Vec>, + ) -> Result, Error> { + let n = 1 << k; + + let mut cs = ConstraintSystem::default(); + let config = ConcreteCircuit::configure(&mut cs); + let cs = cs; + + if n < cs.minimum_rows() { + return Err(Error::not_enough_rows_available(k)); + } + + if instance.len() != cs.num_instance_columns { + return Err(Error::InvalidInstances); + } + + let instance = instance + .into_iter() + .map(|mut instance| { + if instance.len() > n - (cs.blinding_factors() + 1) { + return Err(Error::InstanceTooLarge); + } + + instance.resize(n, F::zero()); + Ok(instance) + }) + .collect::, _>>()?; + + // Fixed columns contain no blinding factors. + let fixed = vec![vec![CellValue::Unassigned; n]; cs.num_fixed_columns]; + let selectors = vec![vec![false; n]; cs.num_selectors]; + // Advice columns contain blinding factors. + let blinding_factors = cs.blinding_factors(); + let usable_rows = n - (blinding_factors + 1); + let advice = vec![ + { + let mut column = vec![CellValue::Unassigned; n]; + // Poison unusable rows. + for (i, cell) in column.iter_mut().enumerate().skip(usable_rows) { + *cell = CellValue::Poison(i); + } + column + }; + cs.num_advice_columns + ]; + let permutation = permutation::keygen::ParallelAssembly::new(n, &cs.permutation); + let constants = cs.constants.clone(); + + let mut prover = Parallel::new(MockProver { + k, + n: n as u32, + cs, + regions: vec![], + current_region: None, + fixed, + advice, + instance, + selectors, + permutation, + usable_rows: 0..usable_rows, + }); + + ConcreteCircuit::FloorPlanner::synthesize(&mut prover, circuit, config, constants)?; + + let mut prover = prover.into_inner(); + + let (cs, selector_polys) = prover.cs.compress_selectors(prover.selectors.clone()); + prover.cs = cs; + prover.fixed.extend(selector_polys.into_iter().map(|poly| { + let mut v = vec![CellValue::Unassigned; n]; + for (v, p) in v.iter_mut().zip(&poly[..]) { + *v = CellValue::Assigned( *p); + } + v + })); + + Ok(prover.into()) + } + *) + Definition run (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ ConcreteCircuit ], [ k; circuit; instance ] => + ltac:(M.monadic + (let k := M.alloc (| k |) in + let circuit := M.alloc (| circuit |) in + let instance := M.alloc (| instance |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let n := M.alloc (| BinOp.Panic.shl (| Value.Integer 1, M.read (| k |) |) |) in + let cs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + [], + "default", + [] + |), + [] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Circuit", + ConcreteCircuit, + [ F ], + "configure", + [] + |), + [ cs ] + |) + |) in + let cs := M.copy (| cs |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (M.read (| n |)) + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "minimum_rows", + [] + |), + [ cs ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::error::Error", + "not_enough_rows_available", + [] + |), + [ M.read (| k |) ] + |) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ instance ] + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_instance_columns" + |) + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "halo2_proofs::plonk::error::Error::InvalidInstances" + [] + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let instance := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| instance |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let instance := M.copy (| γ |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ instance ] + |)) + (BinOp.Panic.sub (| + Integer.Usize, + M.read (| n |), + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "blinding_factors", + [] + |), + [ cs ] + |), + Value.Integer 1 + |) + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "halo2_proofs::plonk::error::Error::InstanceTooLarge" + [] + ] + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" + ], + "resize", + [] + |), + [ + instance; + M.read (| n |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ M.read (| instance |) ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::MockVerifier") + [ F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let fixed := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ] ] + |), + [ + Value.StructTuple "halo2_proofs::dev::CellValue::Unassigned" []; + M.read (| n |) + ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_fixed_columns" + |) + |) + ] + |) + |) in + let selectors := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ Ty.path "bool" ] |), + [ Value.Bool false; M.read (| n |) ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_selectors" + |) + |) + ] + |) + |) in + let blinding_factors := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "blinding_factors", + [] + |), + [ cs ] + |) + |) in + let usable_rows := + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + M.read (| n |), + BinOp.Panic.add (| + Integer.Usize, + M.read (| blinding_factors |), + Value.Integer 1 + |) + |) + |) in + let advice := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.read (| + let column := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ] ] + |), + [ + Value.StructTuple "halo2_proofs::dev::CellValue::Unassigned" []; + M.read (| n |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::CellValue") + [ F ] + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::CellValue") + [ F ] + ] + ], + [], + "skip", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::CellValue") + [ F ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::CellValue") + [ F ] + ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::CellValue") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ column ] + |) + ] + |) + ] + |); + M.read (| usable_rows |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ] + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let i := M.copy (| γ1_0 |) in + let cell := M.copy (| γ1_1 |) in + let _ := + M.write (| + M.read (| cell |), + Value.StructTuple + "halo2_proofs::dev::CellValue::Poison" + [ M.read (| i |) ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + column + |); + M.read (| + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_columns" + |) + |) + ] + |) + |) in + let permutation := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "new", + [] + |), + [ + M.read (| n |); + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |) + ] + |) + |) in + let constants := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "constants" + |) + ] + |) + |) in + let prover := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ], + "new", + [] + |), + [ + Value.StructRecord + "halo2_proofs::dev::MockProver" + [ + ("k", M.read (| k |)); + ("n", M.rust_cast (M.read (| n |))); + ("cs", M.read (| cs |)); + ("regions", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::dev::Region"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("current_region", Value.StructTuple "core::option::Option::None" []); + ("fixed", M.read (| fixed |)); + ("advice", M.read (| advice |)); + ("instance", M.read (| instance |)); + ("selectors", M.read (| selectors |)); + ("permutation", M.read (| permutation |)); + ("usable_rows", + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| usable_rows |)) ]) + ] + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::FloorPlanner", + Ty.associated, + [], + "synthesize", + [ + F; + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ]; + ConcreteCircuit + ] + |), + [ + prover; + M.read (| circuit |); + M.read (| config |); + M.read (| constants |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::MockVerifier") + [ F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let prover := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::parallel::Parallel") + [ Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ] ], + "into_inner", + [] + |), + [ M.read (| prover |) ] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "compress_selectors", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + prover, + "halo2_proofs::dev::MockProver", + "cs" + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + prover, + "halo2_proofs::dev::MockProver", + "selectors" + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let cs := M.copy (| γ0_0 |) in + let selector_polys := M.copy (| γ0_1 |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + prover, + "halo2_proofs::dev::MockProver", + "cs" + |), + M.read (| cs |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::Extend", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ]; + Ty.path "alloc::alloc::Global" + ] + ], + "extend", + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + ] + |), + [ + M.SubPointer.get_struct_record_field (| + prover, + "halo2_proofs::dev::MockProver", + "fixed" + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::dev::CellValue") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| selector_polys |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let poly := M.copy (| γ |) in + M.read (| + let v := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ] + ] + |), + [ + Value.StructTuple + "halo2_proofs::dev::CellValue::Unassigned" + []; + M.read (| n |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ F ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ] + ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ v ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "core::ops::range::RangeFull" + ], + "index", + [] + |), + [ + poly; + Value.StructTuple + "core::ops::range::RangeFull" + [] + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let v := + M.copy (| + γ1_0 + |) in + let p := + M.copy (| + γ1_1 + |) in + let _ := + M.write (| + M.read (| v |), + Value.StructTuple + "halo2_proofs::dev::CellValue::Assigned" + [ + M.read (| + M.read (| + p + |) + |) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + v + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::dev::MockVerifier") [ F ] ], + "into", + [] + |), + [ M.read (| prover |) ] + |) + ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_run : forall (F : Ty.t), M.IsAssociatedFunction (Self F) "run" (run F). + End Impl_halo2_proofs_dev_MockProver_F. + + Module Impl_halo2_proofs_dev_MockVerifier_F. + Definition Self (F : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::dev::MockVerifier") [ F ]. + + (* + pub fn verify(&self) -> Result<(), Vec> { + self.verify_at_rows(self.usable_rows.clone(), self.usable_rows.clone()) + } + *) + Definition verify (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::dev::MockVerifier") [ F ], + "verify_at_rows", + [ Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ] ] + |), + [ + M.read (| self |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "usable_rows" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "usable_rows" + |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_verify : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "verify" (verify F). + + (* + pub fn verify_at_rows>( + &self, + gate_row_ids: I, + lookup_input_row_ids: I, + ) -> Result<(), Vec> { + let n = self.n as i32; + + // check all the row ids are valid + for row_id in gate_row_ids.clone() { + if !self.usable_rows.contains(&row_id) { + panic!("invalid gate row id {}", row_id) + } + } + for row_id in lookup_input_row_ids.clone() { + if !self.usable_rows.contains(&row_id) { + panic!("invalid lookup row id {}", row_id) + } + } + + // Check that within each region, all cells used in instantiated gates have been + // assigned to. + let selector_errors = self.regions.iter().enumerate().flat_map(|(r_i, r)| { + r.enabled_selectors.iter().flat_map(move |(selector, at)| { + // Find the gates enabled by this selector + self.cs + .gates + .iter() + // Assume that if a queried selector is enabled, the user wants to use the + // corresponding gate in some way. + // + // TODO: This will trip up on the reverse case, where leaving a selector + // un-enabled keeps a gate enabled. We could alternatively require that + // every selector is explicitly enabled or disabled on every row? But that + // seems messy and confusing. + .enumerate() + .filter(move |(_, g)| g.queried_selectors().contains(selector)) + .flat_map(move |(gate_index, gate)| { + at.iter().flat_map(move |selector_row| { + // Selectors are queried with no rotation. + let gate_row = *selector_row as i32; + + gate.queried_cells().iter().filter_map(move |cell| { + // Determine where this cell should have been assigned. + let cell_row = ((gate_row + n + cell.rotation.0) % n) as usize; + + // Check that it was assigned! + if r.is_assigned(cell.column, cell_row) { + None + } else { + Some(VerifyFailure::CellNotAssigned { + gate: (gate_index, gate.name()).into(), + region: (r_i, r.name.clone()).into(), + column: cell.column, + offset: cell_row as isize - r.rows.unwrap().0 as isize, + }) + } + }) + }) + }) + }) + }); + + // Check that all gates are satisfied for all rows. + let gate_errors = + self.cs + .gates + .iter() + .enumerate() + .flat_map(|(gate_index, gate)| { + let blinding_rows = + (self.n as usize - (self.cs.blinding_factors() + 1))..(self.n as usize); + (gate_row_ids + .clone() + .into_iter() + .chain(blinding_rows.into_iter())) + .flat_map(move |row| { + fn load_instance<'a, F: FieldExt, T: ColumnType>( + n: i32, + row: i32, + queries: &'a [(Column, Rotation)], + cells: &'a [Vec], + ) -> impl Fn(usize, usize, Rotation) -> Value + 'a + { + move |index, _, _| { + let (column, at) = &queries[index]; + let resolved_row = (row + n + at.0) % n; + Value::Real(cells[column.index()][resolved_row as usize]) + } + } + + fn load<'a, F: FieldExt, T: ColumnType>( + n: i32, + row: i32, + queries: &'a [(Column, Rotation)], + cells: &'a [Vec>], + ) -> impl Fn(usize, usize, Rotation) -> Value + 'a + { + move |index, _, _| { + let (column, at) = &queries[index]; + let resolved_row = (row + n + at.0) % n; + cells[column.index()][resolved_row as usize].into() + } + } + let row = row as i32; + gate.polynomials().iter().enumerate().filter_map( + move |(poly_index, poly)| match poly.evaluate_lazy( + &|scalar| Value::Real(scalar), + &|_| panic!("virtual selectors are removed during optimization"), + &load(n, row, &self.cs.fixed_queries, &self.fixed), + &load(n, row, &self.cs.advice_queries, &self.advice), + &load_instance(n, row, &self.cs.instance_queries, &self.instance), + &|a| -a, + &|a, b| a + b, + &|a, b| a * b, + &|a, scalar| a * scalar, + &Value::Real(F::zero()), + ) { + Value::Real(x) if x.is_zero_vartime() => None, + Value::Real(_) => Some(VerifyFailure::ConstraintNotSatisfied { + constraint: ( + (gate_index, gate.name()).into(), + poly_index, + gate.constraint_name(poly_index), + ) + .into(), + location: FailureLocation::find_expressions( + &self.cs, + &self.regions, + row as usize, + Some(poly).into_iter(), + ), + cell_values: util::cell_values( + gate, + poly, + &load(n, row, &self.cs.fixed_queries, &self.fixed), + &load(n, row, &self.cs.advice_queries, &self.advice), + &load_instance( + n, + row, + &self.cs.instance_queries, + &self.instance, + ), + ), + }), + Value::Poison => Some(VerifyFailure::ConstraintPoisoned { + constraint: ( + (gate_index, gate.name()).into(), + poly_index, + gate.constraint_name(poly_index), + ) + .into(), + }), + }, + ) + }) + }); + + // Check that all lookups exist in their respective tables. + let lookup_errors = + self.cs + .lookups + .iter() + .enumerate() + .flat_map(|(lookup_index, lookup)| { + let load = |expression: &Expression, row| { + expression.evaluate_lazy( + &|scalar| Value::Real(scalar), + &|_| panic!("virtual selectors are removed during optimization"), + &|index, _, _| { + let query = self.cs.fixed_queries[index]; + let column_index = query.0.index(); + let rotation = query.1 .0; + self.fixed[column_index] + [(row as i32 + n + rotation) as usize % n as usize] + .into() + }, + &|index, _, _| { + let query = self.cs.advice_queries[index]; + let column_index = query.0.index(); + let rotation = query.1 .0; + self.advice[column_index] + [(row as i32 + n + rotation) as usize % n as usize] + .into() + }, + &|index, _, _| { + let query = self.cs.instance_queries[index]; + let column_index = query.0.index(); + let rotation = query.1 .0; + Value::Real( + self.instance[column_index] + [(row as i32 + n + rotation) as usize % n as usize], + ) + }, + &|a| -a, + &|a, b| a + b, + &|a, b| a * b, + &|a, scalar| a * scalar, + &Value::Real(F::zero()), + ) + }; + + // In the real prover, the lookup expressions are never enforced on + // unusable rows, due to the (1 - (l_last(X) + l_blind(X))) term. + let table: std::collections::BTreeSet> = self + .usable_rows + .clone() + .map(|table_row| { + lookup + .table_expressions + .iter() + .map(move |c| load(c, table_row)) + .collect::>() + }) + .collect(); + lookup_input_row_ids + .clone() + .into_iter() + .filter_map(move |input_row| { + let inputs: Vec<_> = lookup + .input_expressions + .iter() + .map(|c| load(c, input_row)) + .collect(); + let lookup_passes = table.contains(&inputs); + if lookup_passes { + None + } else { + Some(VerifyFailure::Lookup { + name: lookup.name, + lookup_index, + location: FailureLocation::find_expressions( + &self.cs, + &self.regions, + input_row, + lookup.input_expressions.iter(), + ), + }) + } + }) + }); + + // Check that permutations preserve the original values of the cells. + let perm_errors = { + // Original values of columns involved in the permutation. + let original = |column, row| { + self.cs + .permutation + .get_columns() + .get(column) + .map(|c: &Column| match c.column_type() { + Any::Advice => self.advice[c.index()][row], + Any::Fixed => self.fixed[c.index()][row], + Any::Instance => CellValue::Assigned(self.instance[c.index()][row]), + }) + .unwrap() + }; + + // Iterate over each column of the permutation + self.permutation + .mapping + .iter() + .enumerate() + .flat_map(move |(column, values)| { + // Iterate over each row of the column to check that the cell's + // value is preserved by the mapping. + values.iter().enumerate().filter_map(move |(row, cell)| { + let original_cell = original(column, row); + let permuted_cell = original(cell.0 as usize, cell.1 as usize); + if original_cell == permuted_cell { + None + } else { + Some(VerifyFailure::Permutation { + column: ( *self.cs.permutation.get_columns().get(column).unwrap()) + .into(), + row, + }) + } + }) + }) + }; + + let mut errors: Vec<_> = iter::empty() + .chain(selector_errors) + .chain(gate_errors) + .chain(lookup_errors) + .chain(perm_errors) + .collect(); + if errors.is_empty() { + Ok(()) + } else { + // Remove any duplicate `ConstraintPoisoned` errors (we check all unavailable + // rows in case the trigger is row-specific, but the error message only points + // at the constraint). + errors.dedup_by(|a, b| match (a, b) { + ( + a @ VerifyFailure::ConstraintPoisoned { .. }, + b @ VerifyFailure::ConstraintPoisoned { .. }, + ) => a == b, + _ => false, + }); + Err(errors) + } + } + *) + Definition verify_at_rows (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ _ as I ], [ self; gate_row_ids; lookup_input_row_ids ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let gate_row_ids := M.alloc (| gate_row_ids |) in + let lookup_input_row_ids := M.alloc (| lookup_input_row_ids |) in + M.read (| + let n := + M.alloc (| + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "n" + |) + |)) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + I, + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", I, [], "clone", [] |), + [ gate_row_ids ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + I, + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let row_id := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + "contains", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "usable_rows" + |); + row_id + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic_fmt", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "invalid gate row id " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ row_id ] + |) + ] + |)) + ] + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + I, + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", I, [], "clone", [] |), + [ lookup_input_row_ids ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + I, + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let row_id := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + "contains", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "usable_rows" + |); + row_id + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic_fmt", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "invalid lookup row id " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ row_id ] + |) + ] + |)) + ] + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let selector_errors := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::dev::Region" ] + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.path "usize" ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "usize" ] ] ] + (Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "usize" ] ] ] + (Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "halo2_proofs::plonk::circuit::Selector" ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "usize" ] ] ] + (Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "usize" ] ] ] + (Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply (Ty.path "&") [ Ty.path "halo2_proofs::dev::Region" ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "usize" ] ] ] + (Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "usize" ] ] ] + (Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "halo2_proofs::plonk::circuit::Selector" ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "usize" ] ] ] + (Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "usize" ] ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ]) + ]) + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::dev::Region" ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "halo2_proofs::dev::Region" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::dev::Region"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "regions" + |) + ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let r_i := M.copy (| γ0_0 |) in + let r := M.copy (| γ0_1 |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ] + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ Ty.apply (Ty.path "&") [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::hash::random::RandomState" + ], + "iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| r |), + "halo2_proofs::dev::Region", + "enabled_selectors" + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let selector := M.copy (| γ0_0 |) in + let at_ := M.copy (| γ0_1 |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ], + [], + "filter", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "gates" + |) + ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let g := + M.alloc (| + γ1_1 + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ], + "contains", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ], + "queried_selectors", + [] + |), + [ + M.read (| + M.read (| + g + |) + |) + ] + |); + M.read (| + selector + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let gate_index := + M.copy (| γ0_0 |) in + let gate := + M.copy (| γ0_1 |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.path "usize" + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "usize" + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.path + "usize" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "usize"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + at_ + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + selector_row := + M.copy (| + γ + |) in + M.read (| + let + gate_row := + M.alloc (| + M.rust_cast + (M.read (| + M.read (| + selector_row + |) + |)) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ], + [], + "filter_map", + [ + Ty.path + "halo2_proofs::dev::VerifyFailure"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ + F + ], + "queried_cells", + [] + |), + [ + M.read (| + gate + |) + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + cell := + M.copy (| + γ + |) in + M.read (| + let + cell_row := + M.alloc (| + M.rust_cast + (BinOp.Panic.rem (| + Integer.I32, + BinOp.Panic.add (| + Integer.I32, + BinOp.Panic.add (| + Integer.I32, + M.read (| + gate_row + |), + M.read (| + n + |) + |), + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + cell + |), + "halo2_proofs::plonk::circuit::VirtualCell", + "rotation" + |), + "halo2_proofs::poly::Rotation", + 0 + |) + |) + |), + M.read (| + n + |) + |)) + |) in + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::dev::Region", + "is_assigned", + [] + |), + [ + M.read (| + r + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + cell + |), + "halo2_proofs::plonk::circuit::VirtualCell", + "column" + |) + |); + M.read (| + cell_row + |) + ] + |) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "halo2_proofs::dev::VerifyFailure::CellNotAssigned" + [ + ("gate", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ], + [ + Ty.path + "halo2_proofs::dev::metadata::Gate" + ], + "into", + [] + |), + [ + Value.Tuple + [ + M.read (| + gate_index + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ + F + ], + "name", + [] + |), + [ + M.read (| + gate + |) + ] + |) + ] + ] + |)); + ("region", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "alloc::string::String" + ], + [ + Ty.path + "halo2_proofs::dev::metadata::Region" + ], + "into", + [] + |), + [ + Value.Tuple + [ + M.read (| + r_i + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path + "alloc::string::String", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + r + |), + "halo2_proofs::dev::Region", + "name" + |) + ] + |) + ] + ] + |)); + ("column", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + cell + |), + "halo2_proofs::plonk::circuit::VirtualCell", + "column" + |) + |)); + ("offset", + BinOp.Panic.sub (| + Integer.Isize, + M.rust_cast + (M.read (| + cell_row + |)), + M.rust_cast + (M.read (| + M.SubPointer.get_tuple_field (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize" + ] + ], + "unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + r + |), + "halo2_proofs::dev::Region", + "rows" + |) + |) + ] + |) + |), + 0 + |) + |)) + |)) + ] + ] + |))) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let gate_errors := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ] ] + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ I; Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ] ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ I; Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ] ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ] ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "gates" + |) + ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let gate_index := M.copy (| γ0_0 |) in + let gate := M.copy (| γ0_1 |) in + M.read (| + let blinding_rows := + M.alloc (| + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + BinOp.Panic.sub (| + Integer.Usize, + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "n" + |) + |)), + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "blinding_factors", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "cs" + |) + ] + |), + Value.Integer 1 + |) + |)); + ("end_", + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "n" + |) + |))) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + I; + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ] + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + I, + [], + "chain", + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + I, + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + I, + [], + "clone", + [] + |), + [ gate_row_ids ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ M.read (| blinding_rows |) ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let row := M.copy (| γ |) in + M.read (| + let row := + M.alloc (| + M.rust_cast (M.read (| row |)) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ], + [], + "filter_map", + [ + Ty.path + "halo2_proofs::dev::VerifyFailure"; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ], + "polynomials", + [] + |), + [ M.read (| gate |) ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + poly_index := + M.copy (| + γ0_0 + |) in + let poly := + M.copy (| + γ0_1 + |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ], + "evaluate_lazy", + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ]; + Ty.function + [ + Ty.tuple + [ + F + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ]); + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ]); + Ty.associated; + Ty.associated; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ]; + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ]; + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ]; + F + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ]) + ] + |), + [ + M.read (| + poly + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + scalar := + M.copy (| + γ + |) in + Value.StructTuple + "halo2_proofs::dev::Value::Real" + [ + M.read (| + scalar + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.never_to_any (| + M.call_closure (| + M.get_function (| + "std::panicking::begin_panic", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + Value.String + "virtual selectors are removed during optimization" + |) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.call_closure (| + M.read (| + (* Unimplemented parent_kind *) + M.alloc (| + Value.Tuple + [] + |) + |), + [ + M.read (| + n + |); + M.read (| + row + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "fixed_queries" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ + F + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "fixed" + |) + ] + |) + ] + |) + |); + M.alloc (| + M.call_closure (| + M.read (| + (* Unimplemented parent_kind *) + M.alloc (| + Value.Tuple + [] + |) + |), + [ + M.read (| + n + |); + M.read (| + row + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "advice_queries" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ + F + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "advice" + |) + ] + |) + ] + |) + |); + M.alloc (| + M.call_closure (| + M.read (| + (* Unimplemented parent_kind *) + M.alloc (| + Value.Tuple + [] + |) + |), + [ + M.read (| + n + |); + M.read (| + row + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "instance_queries" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "instance" + |) + ] + |) + ] + |) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Neg", + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ], + [], + "neg", + [] + |), + [ + M.read (| + a + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + b := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ] + ], + "add", + [] + |), + [ + M.read (| + a + |); + M.read (| + b + |) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + b := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ] + ], + "mul", + [] + |), + [ + M.read (| + a + |); + M.read (| + b + |) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + scalar := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ], + [ + F + ], + "mul", + [] + |), + [ + M.read (| + a + |); + M.read (| + scalar + |) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + Value.StructTuple + "halo2_proofs::dev::Value::Real" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::dev::Value::Real", + 0 + |) in + let + x := + M.copy (| + γ0_0 + |) in + let + γ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "is_zero_vartime", + [] + |), + [ + x + ] + |) + |) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))); + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::dev::Value::Real", + 0 + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "halo2_proofs::dev::VerifyFailure::ConstraintNotSatisfied" + [ + ("constraint", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.tuple + [ + Ty.path + "halo2_proofs::dev::metadata::Gate"; + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ], + [ + Ty.path + "halo2_proofs::dev::metadata::Constraint" + ], + "into", + [] + |), + [ + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ], + [ + Ty.path + "halo2_proofs::dev::metadata::Gate" + ], + "into", + [] + |), + [ + Value.Tuple + [ + M.read (| + gate_index + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ + F + ], + "name", + [] + |), + [ + M.read (| + gate + |) + ] + |) + ] + ] + |); + M.read (| + poly_index + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ + F + ], + "constraint_name", + [] + |), + [ + M.read (| + gate + |); + M.read (| + poly_index + |) + ] + |) + ] + ] + |)); + ("location", + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::dev::FailureLocation", + "find_expressions", + [ + F; + Ty.apply + (Ty.path + "core::option::IntoIter") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ] + ] + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "cs" + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::dev::Region"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "regions" + |) + ] + |); + M.rust_cast + (M.read (| + row + |)); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ] + ], + [], + "into_iter", + [] + |), + [ + Value.StructTuple + "core::option::Option::Some" + [ + M.read (| + poly + |) + ] + ] + |) + ] + |)); + ("cell_values", + M.call_closure (| + M.get_function (| + "halo2_proofs::dev::util::cell_values", + [ + F; + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ] + |), + [ + M.read (| + gate + |); + M.read (| + poly + |); + M.alloc (| + M.call_closure (| + M.read (| + (* Unimplemented parent_kind *) + M.alloc (| + Value.Tuple + [] + |) + |), + [ + M.read (| + n + |); + M.read (| + row + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "fixed_queries" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ + F + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "fixed" + |) + ] + |) + ] + |) + |); + M.alloc (| + M.call_closure (| + M.read (| + (* Unimplemented parent_kind *) + M.alloc (| + Value.Tuple + [] + |) + |), + [ + M.read (| + n + |); + M.read (| + row + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "advice_queries" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ + F + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "advice" + |) + ] + |) + ] + |) + |); + M.alloc (| + M.call_closure (| + M.read (| + (* Unimplemented parent_kind *) + M.alloc (| + Value.Tuple + [] + |) + |), + [ + M.read (| + n + |); + M.read (| + row + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "instance_queries" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "instance" + |) + ] + |) + ] + |) + |) + ] + |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "halo2_proofs::dev::VerifyFailure::ConstraintPoisoned" + [ + ("constraint", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.tuple + [ + Ty.path + "halo2_proofs::dev::metadata::Gate"; + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ], + [ + Ty.path + "halo2_proofs::dev::metadata::Constraint" + ], + "into", + [] + |), + [ + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ], + [ + Ty.path + "halo2_proofs::dev::metadata::Gate" + ], + "into", + [] + |), + [ + Value.Tuple + [ + M.read (| + gate_index + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ + F + ], + "name", + [] + |), + [ + M.read (| + gate + |) + ] + |) + ] + ] + |); + M.read (| + poly_index + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ + F + ], + "constraint_name", + [] + |), + [ + M.read (| + gate + |); + M.read (| + poly_index + |) + ] + |) + ] + ] + |)) + ] + ] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let lookup_errors := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ] ] + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + I; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + I; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ] ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ] ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "lookups" + |) + ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let lookup_index := M.copy (| γ0_0 |) in + let lookup := M.copy (| γ0_1 |) in + M.read (| + let load := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let expression := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let row := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + "evaluate_lazy", + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]; + Ty.function + [ Ty.tuple [ F ] ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]; + F + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]) + ] + |), + [ + M.read (| expression |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let + scalar := + M.copy (| + γ + |) in + Value.StructTuple + "halo2_proofs::dev::Value::Real" + [ + M.read (| + scalar + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.never_to_any (| + M.call_closure (| + M.get_function (| + "std::panicking::begin_panic", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + Value.String + "virtual selectors are removed during optimization" + |) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let + index := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + let + query := + M.copy (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "fixed_queries" + |); + M.read (| + index + |) + ] + |) + |) in + let + column_index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ], + "index", + [] + |), + [ + M.SubPointer.get_tuple_field (| + query, + 0 + |) + ] + |) + |) in + let + rotation := + M.copy (| + M.SubPointer.get_struct_tuple_field (| + M.SubPointer.get_tuple_field (| + query, + 1 + |), + "halo2_proofs::poly::Rotation", + 0 + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ] + ], + "into", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ + F + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ + F + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "fixed" + |); + M.read (| + column_index + |) + ] + |); + BinOp.Panic.rem (| + Integer.Usize, + M.rust_cast + (BinOp.Panic.add (| + Integer.I32, + BinOp.Panic.add (| + Integer.I32, + M.rust_cast + (M.read (| + row + |)), + M.read (| + n + |) + |), + M.read (| + rotation + |) + |)), + M.rust_cast + (M.read (| + n + |)) + |) + ] + |) + |) + ] + |) + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let + index := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + let + query := + M.copy (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "advice_queries" + |); + M.read (| + index + |) + ] + |) + |) in + let + column_index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ], + "index", + [] + |), + [ + M.SubPointer.get_tuple_field (| + query, + 0 + |) + ] + |) + |) in + let + rotation := + M.copy (| + M.SubPointer.get_struct_tuple_field (| + M.SubPointer.get_tuple_field (| + query, + 1 + |), + "halo2_proofs::poly::Rotation", + 0 + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ] + ], + "into", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ + F + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ + F + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "advice" + |); + M.read (| + column_index + |) + ] + |); + BinOp.Panic.rem (| + Integer.Usize, + M.rust_cast + (BinOp.Panic.add (| + Integer.I32, + BinOp.Panic.add (| + Integer.I32, + M.rust_cast + (M.read (| + row + |)), + M.read (| + n + |) + |), + M.read (| + rotation + |) + |)), + M.rust_cast + (M.read (| + n + |)) + |) + ] + |) + |) + ] + |) + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let + index := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + let + query := + M.copy (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "instance_queries" + |); + M.read (| + index + |) + ] + |) + |) in + let + column_index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ], + "index", + [] + |), + [ + M.SubPointer.get_tuple_field (| + query, + 0 + |) + ] + |) + |) in + let + rotation := + M.copy (| + M.SubPointer.get_struct_tuple_field (| + M.SubPointer.get_tuple_field (| + query, + 1 + |), + "halo2_proofs::poly::Rotation", + 0 + |) + |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::dev::Value::Real" + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "instance" + |); + M.read (| + column_index + |) + ] + |); + BinOp.Panic.rem (| + Integer.Usize, + M.rust_cast + (BinOp.Panic.add (| + Integer.I32, + BinOp.Panic.add (| + Integer.I32, + M.rust_cast + (M.read (| + row + |)), + M.read (| + n + |) + |), + M.read (| + rotation + |) + |)), + M.rust_cast + (M.read (| + n + |)) + |) + ] + |) + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Neg", + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ], + [], + "neg", + [] + |), + [ + M.read (| + a + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (let + b := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ] + ], + "add", + [] + |), + [ + M.read (| + a + |); + M.read (| + b + |) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (let + b := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ] + ], + "mul", + [] + |), + [ + M.read (| + a + |); + M.read (| + b + |) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (let + scalar := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ], + [ + F + ], + "mul", + [] + |), + [ + M.read (| + a + |); + M.read (| + scalar + |) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + Value.StructTuple + "halo2_proofs::dev::Value::Real" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let table := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::Value") + [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::Value") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "map", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::Value") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::Value") + [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "usable_rows" + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let table_row := + M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + lookup + |), + "halo2_proofs::plonk::lookup::Argument", + "table_expressions" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let c := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ]; + Ty.path + "usize" + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ]; + Ty.path + "usize" + ] + ], + "call", + [] + |), + [ + load; + Value.Tuple + [ + M.read (| + c + |); + M.read (| + table_row + |) + ] + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + I, + [], + "filter_map", + [ + Ty.path "halo2_proofs::dev::VerifyFailure"; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + I, + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + I, + [], + "clone", + [] + |), + [ lookup_input_row_ids ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let input_row := M.copy (| γ |) in + M.read (| + let inputs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + lookup + |), + "halo2_proofs::plonk::lookup::Argument", + "input_expressions" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let c := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ]; + Ty.path + "usize" + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ + F + ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ]; + Ty.path + "usize" + ] + ], + "call", + [] + |), + [ + load; + Value.Tuple + [ + M.read (| + c + |); + M.read (| + input_row + |) + ] + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let lookup_passes := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + "contains", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::Value") + [ F ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ table; inputs ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use lookup_passes in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "halo2_proofs::dev::VerifyFailure::Lookup" + [ + ("name", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + lookup + |), + "halo2_proofs::plonk::lookup::Argument", + "name" + |) + |)); + ("lookup_index", + M.read (| + lookup_index + |)); + ("location", + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::dev::FailureLocation", + "find_expressions", + [ + F; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "cs" + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::dev::Region"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "regions" + |) + ] + |); + M.read (| + input_row + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + lookup + |), + "halo2_proofs::plonk::lookup::Argument", + "input_expressions" + |) + ] + |) + ] + |) + ] + |)) + ] + ] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let perm_errors := + M.copy (| + let original := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let column := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let row := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::CellValue") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ], + "map", + [ + Ty.apply + (Ty.path "halo2_proofs::dev::CellValue") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::dev::CellValue") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "get", + [ Ty.path "usize" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::plonk::permutation::Argument", + "get_columns", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |) + ] + |) + |) + ] + |); + M.read (| column |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let c := M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "column_type", + [] + |), + [ M.read (| c |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.read (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" + ], + "index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "advice" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "index", + [] + |), + [ + M.read (| + c + |) + ] + |) + ] + |); + M.read (| row |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := + M.read (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" + ], + "index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "fixed" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "index", + [] + |), + [ + M.read (| + c + |) + ] + |) + ] + |); + M.read (| row |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := + M.read (| γ |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::dev::CellValue::Assigned" + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "instance" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "index", + [] + |), + [ + M.read (| + c + |) + ] + |) + ] + |); + M.read (| + row + |) + ] + |) + |) + ] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::MockVerifier", + "permutation" + |), + "halo2_proofs::plonk::permutation::keygen::Assembly", + "mapping" + |) + ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let column := M.copy (| γ0_0 |) in + let values := M.copy (| γ0_1 |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] ] + ], + [], + "filter_map", + [ + Ty.path "halo2_proofs::dev::VerifyFailure"; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| values |) ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let row := M.copy (| γ0_0 |) in + let cell := M.copy (| γ0_1 |) in + M.read (| + let original_cell := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize" + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ]), + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize" + ] + ], + "call", + [] + |), + [ + original; + Value.Tuple + [ + M.read (| column |); + M.read (| row |) + ] + ] + |) + |) in + let permuted_cell := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize" + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ]), + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize" + ] + ], + "call", + [] + |), + [ + original; + Value.Tuple + [ + M.rust_cast + (M.read (| + M.SubPointer.get_tuple_field (| + M.read (| cell |), + 0 + |) + |)); + M.rust_cast + (M.read (| + M.SubPointer.get_tuple_field (| + M.read (| cell |), + 1 + |) + |)) + ] + ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::dev::CellValue") + [ F ] + ], + "eq", + [] + |), + [ + original_cell; + permuted_cell + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "halo2_proofs::dev::VerifyFailure::Permutation" + [ + ("column", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + [ + Ty.path + "halo2_proofs::dev::metadata::Column" + ], + "into", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "get", + [ + Ty.path + "usize" + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::plonk::permutation::Argument", + "get_columns", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::dev::MockVerifier", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |) + ] + |) + |) + ] + |); + M.read (| + column + |) + ] + |) + ] + |) + |) + ] + |)); + ("row", + M.read (| row |)) + ] + ] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) + |) in + let errors := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::dev::Region" ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ Ty.path "halo2_proofs::dev::Region" ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]) + ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + I; + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + I; + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ F ] + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + I; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + I; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "halo2_proofs::dev::VerifyFailure"; Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::dev::Region" ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ Ty.path "halo2_proofs::dev::Region" ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]) + ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + I; + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + I; + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ F ] + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + I; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + I; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::dev::Region" ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ Ty.path "halo2_proofs::dev::Region" ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]) + ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + I; + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + I; + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ]) + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ F ] + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + I; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + I; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::dev::Region" ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ Ty.path "halo2_proofs::dev::Region" ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]) + ]) + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + I; + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + I; + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]) + ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::dev::Region" ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ Ty.path "halo2_proofs::dev::Region" ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + ] + (Ty.path "bool") + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ]; + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ]) + ]) + ]) + ]) + ]) + ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "core::iter::sources::empty::empty", + [ Ty.path "halo2_proofs::dev::VerifyFailure" ] + |), + [] + |); + M.read (| selector_errors |) + ] + |); + M.read (| gate_errors |) + ] + |); + M.read (| lookup_errors |) + ] + |); + M.read (| perm_errors |) + ] + |) + ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::dev::VerifyFailure"; + Ty.path "alloc::alloc::Global" + ], + "is_empty", + [] + |), + [ errors ] + |) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::dev::VerifyFailure"; + Ty.path "alloc::alloc::Global" + ], + "dedup_by", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ]; + Ty.apply + (Ty.path "&mut") + [ Ty.path "halo2_proofs::dev::VerifyFailure" ] + ] + ] + (Ty.path "bool") + ] + |), + [ + errors; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let b := M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| + Value.Tuple + [ M.read (| a |); M.read (| b |) ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let a := M.copy (| γ0_0 |) in + let γ0_0 := M.read (| γ0_0 |) in + let b := M.copy (| γ0_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "&mut") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ], + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure" + ] + ], + "eq", + [] + |), + [ a; b ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Bool false |))) + ] + |) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Err" [ M.read (| errors |) ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_verify_at_rows : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "verify_at_rows" (verify_at_rows F). + End Impl_halo2_proofs_dev_MockVerifier_F. +End dev. diff --git a/CoqOfRust/halo2_proofs/dev/cost.v b/CoqOfRust/halo2_proofs/dev/cost.v new file mode 100644 index 000000000..f0387d04f --- /dev/null +++ b/CoqOfRust/halo2_proofs/dev/cost.v @@ -0,0 +1,5388 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module dev. + Module cost. + (* StructRecord + { + name := "CircuitCost"; + ty_params := [ "G"; "ConcreteCircuit" ]; + fields := + [ + ("k", Ty.path "usize"); + ("max_deg", Ty.path "usize"); + ("advice_columns", Ty.path "usize"); + ("instance_queries", Ty.path "usize"); + ("advice_queries", Ty.path "usize"); + ("fixed_queries", Ty.path "usize"); + ("lookups", Ty.path "usize"); + ("permutation_cols", Ty.path "usize"); + ("point_sets", Ty.path "usize"); + ("_marker", + Ty.apply (Ty.path "core::marker::PhantomData") [ Ty.tuple [ G; ConcreteCircuit ] ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_G_where_group_prime_PrimeGroup_G_where_core_fmt_Debug_ConcreteCircuit_where_halo2_proofs_plonk_circuit_Circuit_ConcreteCircuit_associated_type_for_halo2_proofs_dev_cost_CircuitCost_G_ConcreteCircuit. + Definition Self (G ConcreteCircuit : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::dev::cost::CircuitCost") [ G; ConcreteCircuit ]. + + (* Debug *) + Definition fmt (G ConcreteCircuit : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G ConcreteCircuit in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let names := + M.alloc (| + M.alloc (| + Value.Array + [ + M.read (| Value.String "k" |); + M.read (| Value.String "max_deg" |); + M.read (| Value.String "advice_columns" |); + M.read (| Value.String "instance_queries" |); + M.read (| Value.String "advice_queries" |); + M.read (| Value.String "fixed_queries" |); + M.read (| Value.String "lookups" |); + M.read (| Value.String "permutation_cols" |); + M.read (| Value.String "point_sets" |); + M.read (| Value.String "_marker" |) + ] + |) + |) in + let values := + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "k" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "max_deg" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "advice_columns" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "instance_queries" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "advice_queries" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "fixed_queries" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "lookups" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "permutation_cols" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "point_sets" + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "_marker" + |) + |)) + ] + |)) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_fields_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "CircuitCost" |); + (* Unsize *) M.pointer_coercion (M.read (| names |)); + M.read (| values |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (G ConcreteCircuit : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self G ConcreteCircuit) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt G ConcreteCircuit)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_G_where_group_prime_PrimeGroup_G_where_core_fmt_Debug_ConcreteCircuit_where_halo2_proofs_plonk_circuit_Circuit_ConcreteCircuit_associated_type_for_halo2_proofs_dev_cost_CircuitCost_G_ConcreteCircuit. + + (* StructRecord + { + name := "Assembly"; + ty_params := []; + fields := + [ + ("selectors", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + (* StructRecord + { + name := "AssemblyAssigner"; + ty_params := []; + fields := + [ + ("selectors", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_dev_cost_AssemblyAssigner. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::cost::AssemblyAssigner". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::dev::cost::AssemblyAssigner" + [ + ("selectors", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::AssemblyAssigner", + "selectors" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_dev_cost_AssemblyAssigner. + + Module Impl_core_convert_Into_halo2_proofs_dev_cost_Assembly_for_halo2_proofs_dev_cost_AssemblyAssigner. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::cost::AssemblyAssigner". + + (* + fn into(self) -> Assembly { + Assembly { + selectors: Arc::try_unwrap(self.selectors) + .unwrap() + .into_inner() + .unwrap(), + } + } + *) + Definition into (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::dev::cost::Assembly" + [ + ("selectors", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ], + "into_inner", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "try_unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::dev::cost::AssemblyAssigner", + "selectors" + |) + |) + ] + |) + ] + |) + ] + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::Into" + Self + (* Trait polymorphic types *) [ (* T *) Ty.path "halo2_proofs::dev::cost::Assembly" ] + (* Instance *) [ ("into", InstanceField.Method into) ]. + End Impl_core_convert_Into_halo2_proofs_dev_cost_Assembly_for_halo2_proofs_dev_cost_AssemblyAssigner. + + Module Impl_halo2_proofs_plonk_circuit_Assignment_where_ff_Field_F_F_for_halo2_proofs_dev_cost_AssemblyAssigner. + Definition Self (F : Ty.t) : Ty.t := Ty.path "halo2_proofs::dev::cost::AssemblyAssigner". + + (* + fn is_in_prove_mode(&self) -> bool { + false + } + *) + Definition is_in_prove_mode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.Bool false)) + | _, _ => M.impossible + end. + + (* + fn enter_region(&self, _: N) + where + NR: Into, + N: FnOnce() -> NR, + { + // Do nothing; we don't care about regions in this context. + } + *) + Definition enter_region (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ NR; N ], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Tuple [])) ] |))) + | _, _ => M.impossible + end. + + (* + fn exit_region(&self) { + // Do nothing; we don't care about regions in this context. + } + *) + Definition exit_region (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.Tuple [])) + | _, _ => M.impossible + end. + + (* + fn enable_selector(&self, _: A, selector: &Selector, row: usize) -> Result<(), Error> + where + A: FnOnce() -> AR, + AR: Into, + { + let mut selectors = self.selectors.lock().unwrap(); + + selectors[selector.0][row] = true; + + Ok(()) + } + *) + Definition enable_selector (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ A; AR ], [ self; β1; selector; row ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let selector := M.alloc (| selector |) in + let row := M.alloc (| row |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.read (| + let selectors := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::AssemblyAssigner", + "selectors" + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref_mut", + [] + |), + [ selectors ] + |); + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| selector |), + "halo2_proofs::plonk::circuit::Selector", + 0 + |) + |) + ] + |); + M.read (| row |) + ] + |), + Value.Bool true + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn query_instance(&self, _: Column, _: usize) -> Result, Error> { + Ok(None) + } + *) + Definition query_instance (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1; β2 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let β2 := M.alloc (| β2 |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β2, + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ Value.StructTuple "core::option::Option::None" [] ])) + ] + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign_advice( + &self, + _: A, + _: Column, + _: usize, + _: V, + ) -> Result<(), Error> + where + V: FnOnce() -> Result, + VR: Into>, + A: FnOnce() -> AR, + AR: Into, + { + Ok(()) + } + *) + Definition assign_advice (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ V; VR; A; AR ], [ self; β1; β2; β3; β4 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let β2 := M.alloc (| β2 |) in + let β3 := M.alloc (| β3 |) in + let β4 := M.alloc (| β4 |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β2, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β3, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β4, + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ])) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign_fixed( + &self, + _: A, + _: Column, + _: usize, + _: V, + ) -> Result<(), Error> + where + V: FnOnce() -> Result, + VR: Into>, + A: FnOnce() -> AR, + AR: Into, + { + Ok(()) + } + *) + Definition assign_fixed (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ V; VR; A; AR ], [ self; β1; β2; β3; β4 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let β2 := M.alloc (| β2 |) in + let β3 := M.alloc (| β3 |) in + let β4 := M.alloc (| β4 |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β2, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β3, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β4, + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ])) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn copy(&self, _: Column, _: usize, _: Column, _: usize) -> Result<(), Error> { + Ok(()) + } + *) + Definition copy (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1; β2; β3; β4 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let β2 := M.alloc (| β2 |) in + let β3 := M.alloc (| β3 |) in + let β4 := M.alloc (| β4 |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β2, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β3, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β4, + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ])) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn fill_from_row( + &self, + _: Column, + _: usize, + _: Option>, + ) -> Result<(), Error> { + Ok(()) + } + *) + Definition fill_from_row (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1; β2; β3 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let β2 := M.alloc (| β2 |) in + let β3 := M.alloc (| β3 |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β2, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β3, + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ])) + ] + |))) + ] + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn push_namespace(&self, _: N) + where + NR: Into, + N: FnOnce() -> NR, + { + // Do nothing; we don't care about namespaces in this context. + } + *) + Definition push_namespace (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ NR; N ], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Tuple [])) ] |))) + | _, _ => M.impossible + end. + + (* + fn pop_namespace(&self, _: Option) { + // Do nothing; we don't care about namespaces in this context. + } + *) + Definition pop_namespace (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Tuple [])) ] |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "halo2_proofs::plonk::circuit::Assignment" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("is_in_prove_mode", InstanceField.Method (is_in_prove_mode F)); + ("enter_region", InstanceField.Method (enter_region F)); + ("exit_region", InstanceField.Method (exit_region F)); + ("enable_selector", InstanceField.Method (enable_selector F)); + ("query_instance", InstanceField.Method (query_instance F)); + ("assign_advice", InstanceField.Method (assign_advice F)); + ("assign_fixed", InstanceField.Method (assign_fixed F)); + ("copy", InstanceField.Method (copy F)); + ("fill_from_row", InstanceField.Method (fill_from_row F)); + ("push_namespace", InstanceField.Method (push_namespace F)); + ("pop_namespace", InstanceField.Method (pop_namespace F)) + ]. + End Impl_halo2_proofs_plonk_circuit_Assignment_where_ff_Field_F_F_for_halo2_proofs_dev_cost_AssemblyAssigner. + + Module Impl_halo2_proofs_dev_cost_CircuitCost_G_ConcreteCircuit. + Definition Self (G ConcreteCircuit : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::dev::cost::CircuitCost") [ G; ConcreteCircuit ]. + + (* + pub fn measure(k: usize, circuit: &ConcreteCircuit) -> Self { + // Collect the layout details. + let mut cs = ConstraintSystem::default(); + let config = ConcreteCircuit::configure(&mut cs); + let mut assembly = AssemblyAssigner { + selectors: Arc::new(Mutex::new(vec![vec![false; 1 << k]; cs.num_selectors])), + }; + ConcreteCircuit::FloorPlanner::synthesize( + &mut assembly, + circuit, + config, + cs.constants.clone(), + ) + .unwrap(); + + let assembly: Assembly = assembly.into(); + + let (cs, _) = cs.compress_selectors(assembly.selectors); + + assert!((1 << k) >= cs.minimum_rows()); + + // Figure out how many point sets we have due to queried cells. + let mut column_queries: HashMap, HashSet> = HashMap::new(); + for (c, r) in iter::empty() + .chain( + cs.advice_queries + .iter() + .map(|(c, r)| (Column::::from( *c), *r)), + ) + .chain(cs.instance_queries.iter().map(|(c, r)| (( *c).into(), *r))) + .chain(cs.fixed_queries.iter().map(|(c, r)| (( *c).into(), *r))) + .chain( + cs.permutation + .get_columns() + .into_iter() + .map(|c| (c, Rotation::cur())), + ) + { + column_queries.entry(c).or_default().insert(r.0); + } + let mut point_sets: HashSet> = HashSet::new(); + for (_, r) in column_queries { + // Sort the query sets so we merge duplicates. + let mut query_set: Vec<_> = r.into_iter().collect(); + query_set.sort_unstable(); + point_sets.insert(query_set); + } + + // Include lookup polynomials in point sets: + point_sets.insert(vec![0, 1]); // product_poly + point_sets.insert(vec![-1, 0]); // permuted_input_poly + point_sets.insert(vec![0]); // permuted_table_poly + + // Include permutation polynomials in point sets. + point_sets.insert(vec![0, 1]); // permutation_product_poly + let max_deg = cs.degree(); + let permutation_cols = cs.permutation.get_columns().len(); + if permutation_cols > max_deg - 2 { + // permutation_product_poly for chaining chunks. + point_sets.insert(vec![-((cs.blinding_factors() + 1) as i32), 0, 1]); + } + + CircuitCost { + k, + max_deg, + advice_columns: cs.num_advice_columns, + instance_queries: cs.instance_queries.len(), + advice_queries: cs.advice_queries.len(), + fixed_queries: cs.fixed_queries.len(), + lookups: cs.lookups.len(), + permutation_cols, + point_sets: point_sets.len(), + _marker: PhantomData::default(), + } + } + *) + Definition measure (G ConcreteCircuit : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G ConcreteCircuit in + match τ, α with + | [], [ k; circuit ] => + ltac:(M.monadic + (let k := M.alloc (| k |) in + let circuit := M.alloc (| circuit |) in + M.read (| + let cs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + [], + "default", + [] + |), + [] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Circuit", + ConcreteCircuit, + [ Ty.associated ], + "configure", + [] + |), + [ cs ] + |) + |) in + let assembly := + M.alloc (| + Value.StructRecord + "halo2_proofs::dev::cost::AssemblyAssigner" + [ + ("selectors", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ Ty.path "bool" ] + |), + [ + Value.Bool false; + BinOp.Panic.shl (| Value.Integer 1, M.read (| k |) |) + ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_selectors" + |) + |) + ] + |) + ] + |) + ] + |)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::FloorPlanner", + Ty.associated, + [], + "synthesize", + [ + Ty.associated; + Ty.path "halo2_proofs::dev::cost::AssemblyAssigner"; + ConcreteCircuit + ] + |), + [ + assembly; + M.read (| circuit |); + M.read (| config |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "constants" + |) + ] + |) + ] + |) + ] + |) + |) in + let assembly := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "halo2_proofs::dev::cost::AssemblyAssigner", + [ Ty.path "halo2_proofs::dev::cost::Assembly" ], + "into", + [] + |), + [ M.read (| assembly |) ] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "compress_selectors", + [] + |), + [ + M.read (| cs |); + M.read (| + M.SubPointer.get_struct_record_field (| + assembly, + "halo2_proofs::dev::cost::Assembly", + "selectors" + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let cs := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.ge + (BinOp.Panic.shl (| Value.Integer 1, M.read (| k |) |)) + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "minimum_rows", + [] + |), + [ cs ] + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "assertion failed: (1 << k) >= cs.minimum_rows()" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let column_queries := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ Ty.path "i32"; Ty.path "std::hash::random::RandomState" ]; + Ty.path "std::hash::random::RandomState" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]) + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]) + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]) + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]) + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]) + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]) + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]) + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]) + ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "core::iter::sources::empty::empty", + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + |), + [] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + [], + "map", + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "advice_queries" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let c := M.alloc (| γ1_0 |) in + let r := M.alloc (| γ1_1 |) in + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ], + "from", + [] + |), + [ + M.read (| + M.read (| c |) + |) + ] + |); + M.read (| + M.read (| r |) + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + [], + "map", + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "instance_queries" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let c := M.alloc (| γ1_0 |) in + let r := M.alloc (| γ1_1 |) in + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "into", + [] + |), + [ + M.read (| + M.read (| c |) + |) + ] + |); + M.read (| M.read (| r |) |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + [], + "map", + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "fixed_queries" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let c := M.alloc (| γ1_0 |) in + let r := M.alloc (| γ1_1 |) in + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "into", + [] + |), + [ M.read (| M.read (| c |) |) ] + |); + M.read (| M.read (| r |) |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::plonk::permutation::Argument", + "get_columns", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let c := M.copy (| γ |) in + Value.Tuple + [ + M.read (| c |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]) + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let c := M.copy (| γ1_0 |) in + let r := M.copy (| γ1_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::collections::hash::set::HashSet") + [ + Ty.path "i32"; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::collections::hash::map::Entry") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.apply + (Ty.path + "std::collections::hash::set::HashSet") + [ + Ty.path "i32"; + Ty.path + "std::hash::random::RandomState" + ] + ], + "or_default", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.apply + (Ty.path + "std::collections::hash::set::HashSet") + [ + Ty.path "i32"; + Ty.path + "std::hash::random::RandomState" + ]; + Ty.path + "std::hash::random::RandomState" + ], + "entry", + [] + |), + [ column_queries; M.read (| c |) ] + |) + ] + |); + M.read (| + M.SubPointer.get_struct_tuple_field (| + r, + "halo2_proofs::poly::Rotation", + 0 + |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let point_sets := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "i32"; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::hash::random::RandomState" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ Ty.path "i32"; Ty.path "std::hash::random::RandomState" ]; + Ty.path "std::hash::random::RandomState" + ], + [], + "into_iter", + [] + |), + [ M.read (| column_queries |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "std::collections::hash::map::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ]; + Ty.apply + (Ty.path + "std::collections::hash::set::HashSet") + [ + Ty.path "i32"; + Ty.path "std::hash::random::RandomState" + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let r := M.copy (| γ1_1 |) in + let query_set := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "std::collections::hash::set::IntoIter") + [ Ty.path "i32" ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "i32"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "std::collections::hash::set::HashSet") + [ + Ty.path "i32"; + Ty.path + "std::hash::random::RandomState" + ], + [], + "into_iter", + [] + |), + [ M.read (| r |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "i32" ], + "sort_unstable", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "i32"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ query_set ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::collections::hash::set::HashSet") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "i32"; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ point_sets; M.read (| query_set |) ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "i32"; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + point_sets; + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "i32" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "array") [ Ty.path "i32" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array [ Value.Integer 0; Value.Integer 1 ] + |) + ] + |) + |)) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "i32"; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + point_sets; + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "i32" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "array") [ Ty.path "i32" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array [ Value.Integer (-1); Value.Integer 0 ] + |) + ] + |) + |)) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "i32"; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + point_sets; + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "i32" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "array") [ Ty.path "i32" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.alloc (| Value.Array [ Value.Integer 0 ] |) ] + |) + |)) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "i32"; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + point_sets; + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "i32" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "array") [ Ty.path "i32" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array [ Value.Integer 0; Value.Integer 1 ] + |) + ] + |) + |)) + ] + |) + ] + |) + |) in + let max_deg := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "degree", + [] + |), + [ cs ] + |) + |) in + let permutation_cols := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::permutation::Argument", + "get_columns", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |) + ] + |) + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| permutation_cols |)) + (BinOp.Panic.sub (| + Integer.Usize, + M.read (| max_deg |), + Value.Integer 2 + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "i32"; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + point_sets; + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "i32" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "i32" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + UnOp.Panic.neg (| + Integer.I32, + M.rust_cast + (BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "blinding_factors", + [] + |), + [ cs ] + |), + Value.Integer 1 + |)) + |); + Value.Integer 0; + Value.Integer 1 + ] + |) + ] + |) + |)) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::dev::cost::CircuitCost" + [ + ("k", M.read (| k |)); + ("max_deg", M.read (| max_deg |)); + ("advice_columns", + M.read (| + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_columns" + |) + |)); + ("instance_queries", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "instance_queries" + |) + ] + |)); + ("advice_queries", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "advice_queries" + |) + ] + |)); + ("fixed_queries", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "fixed_queries" + |) + ] + |)); + ("lookups", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "lookups" + |) + ] + |)); + ("permutation_cols", M.read (| permutation_cols |)); + ("point_sets", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "i32"; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::hash::random::RandomState" + ], + "len", + [] + |), + [ point_sets ] + |)); + ("_marker", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "core::marker::PhantomData") + [ Ty.tuple [ G; ConcreteCircuit ] ], + [], + "default", + [] + |), + [] + |)) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_measure : + forall (G ConcreteCircuit : Ty.t), + M.IsAssociatedFunction (Self G ConcreteCircuit) "measure" (measure G ConcreteCircuit). + + (* + fn permutation_chunks(&self) -> usize { + let chunk_size = self.max_deg - 2; + (self.permutation_cols + chunk_size - 1) / chunk_size + } + *) + Definition permutation_chunks + (G ConcreteCircuit : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self G ConcreteCircuit in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let chunk_size := + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "max_deg" + |) + |), + Value.Integer 2 + |) + |) in + M.alloc (| + BinOp.Panic.div (| + Integer.Usize, + BinOp.Panic.sub (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "permutation_cols" + |) + |), + M.read (| chunk_size |) + |), + Value.Integer 1 + |), + M.read (| chunk_size |) + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_permutation_chunks : + forall (G ConcreteCircuit : Ty.t), + M.IsAssociatedFunction + (Self G ConcreteCircuit) + "permutation_chunks" + (permutation_chunks G ConcreteCircuit). + + (* + pub fn marginal_proof_size(&self) -> MarginalProofSize { + let chunks = self.permutation_chunks(); + + MarginalProofSize { + // Cells: + // - 1 commitment per advice column per instance + // - 1 eval per instance column query per instance + // - 1 eval per advice column query per instance + instance: ProofContribution::new(0, self.instance_queries), + advice: ProofContribution::new(self.advice_columns, self.advice_queries), + + // Lookup arguments: + // - 3 commitments per lookup argument per instance + // - 5 evals per lookup argument per instance + lookups: ProofContribution::new(3 * self.lookups, 5 * self.lookups), + + // Global permutation argument: + // - chunks commitments per instance + // - 2*chunks + (chunks - 1) evals per instance + equality: ProofContribution::new(chunks, 3 * chunks - 1), + + _marker: PhantomData::default(), + } + } + *) + Definition marginal_proof_size + (G ConcreteCircuit : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self G ConcreteCircuit in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let chunks := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::dev::cost::CircuitCost") + [ G; ConcreteCircuit ], + "permutation_chunks", + [] + |), + [ M.read (| self |) ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::dev::cost::MarginalProofSize" + [ + ("instance", + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "new", + [] + |), + [ + Value.Integer 0; + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "instance_queries" + |) + |) + ] + |)); + ("advice", + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "new", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "advice_columns" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "advice_queries" + |) + |) + ] + |)); + ("lookups", + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "new", + [] + |), + [ + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 3, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "lookups" + |) + |) + |); + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 5, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "lookups" + |) + |) + |) + ] + |)); + ("equality", + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "new", + [] + |), + [ + M.read (| chunks |); + BinOp.Panic.sub (| + Integer.Usize, + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 3, + M.read (| chunks |) + |), + Value.Integer 1 + |) + ] + |)); + ("_marker", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply (Ty.path "core::marker::PhantomData") [ G ], + [], + "default", + [] + |), + [] + |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_marginal_proof_size : + forall (G ConcreteCircuit : Ty.t), + M.IsAssociatedFunction + (Self G ConcreteCircuit) + "marginal_proof_size" + (marginal_proof_size G ConcreteCircuit). + + (* + pub fn proof_size(&self, instances: usize) -> ProofSize { + let marginal = self.marginal_proof_size(); + + ProofSize { + // Cells: + // - marginal cost per instance + // - 1 eval per fixed column query + instance: marginal.instance * instances, + advice: marginal.advice * instances, + fixed: ProofContribution::new(0, self.fixed_queries), + + // Lookup arguments: + // - marginal cost per instance + lookups: marginal.lookups * instances, + + // Global permutation argument: + // - marginal cost per instance + // - 1 eval per column + equality: marginal.equality * instances + + ProofContribution::new(0, self.permutation_cols), + + // Vanishing argument: + // - 1 + (max_deg - 1) commitments + // - 1 random_poly eval + vanishing: ProofContribution::new(self.max_deg, 1), + + // Multiopening argument: + // - f_commitment + // - 1 eval per set of points in multiopen argument + multiopen: ProofContribution::new(1, self.point_sets), + + // Polycommit: + // - s_poly commitment + // - inner product argument (2 * k round commitments) + // - a + // - xi + polycomm: ProofContribution::new(1 + 2 * self.k, 2), + + _marker: PhantomData::default(), + } + } + *) + Definition proof_size (G ConcreteCircuit : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G ConcreteCircuit in + match τ, α with + | [], [ self; instances ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let instances := M.alloc (| instances |) in + M.read (| + let marginal := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::dev::cost::CircuitCost") + [ G; ConcreteCircuit ], + "marginal_proof_size", + [] + |), + [ M.read (| self |) ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::dev::cost::ProofSize" + [ + ("instance", + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.path "halo2_proofs::dev::cost::ProofContribution", + [ Ty.path "usize" ], + "mul", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + marginal, + "halo2_proofs::dev::cost::MarginalProofSize", + "instance" + |) + |); + M.read (| instances |) + ] + |)); + ("advice", + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.path "halo2_proofs::dev::cost::ProofContribution", + [ Ty.path "usize" ], + "mul", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + marginal, + "halo2_proofs::dev::cost::MarginalProofSize", + "advice" + |) + |); + M.read (| instances |) + ] + |)); + ("fixed", + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "new", + [] + |), + [ + Value.Integer 0; + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "fixed_queries" + |) + |) + ] + |)); + ("lookups", + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.path "halo2_proofs::dev::cost::ProofContribution", + [ Ty.path "usize" ], + "mul", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + marginal, + "halo2_proofs::dev::cost::MarginalProofSize", + "lookups" + |) + |); + M.read (| instances |) + ] + |)); + ("equality", + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.path "halo2_proofs::dev::cost::ProofContribution", + [ Ty.path "halo2_proofs::dev::cost::ProofContribution" ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.path "halo2_proofs::dev::cost::ProofContribution", + [ Ty.path "usize" ], + "mul", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + marginal, + "halo2_proofs::dev::cost::MarginalProofSize", + "equality" + |) + |); + M.read (| instances |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "new", + [] + |), + [ + Value.Integer 0; + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "permutation_cols" + |) + |) + ] + |) + ] + |)); + ("vanishing", + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "new", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "max_deg" + |) + |); + Value.Integer 1 + ] + |)); + ("multiopen", + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "new", + [] + |), + [ + Value.Integer 1; + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "point_sets" + |) + |) + ] + |)); + ("polycomm", + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "new", + [] + |), + [ + BinOp.Panic.add (| + Integer.Usize, + Value.Integer 1, + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::CircuitCost", + "k" + |) + |) + |) + |); + Value.Integer 2 + ] + |)); + ("_marker", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply (Ty.path "core::marker::PhantomData") [ G ], + [], + "default", + [] + |), + [] + |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_proof_size : + forall (G ConcreteCircuit : Ty.t), + M.IsAssociatedFunction (Self G ConcreteCircuit) "proof_size" (proof_size G ConcreteCircuit). + End Impl_halo2_proofs_dev_cost_CircuitCost_G_ConcreteCircuit. + + (* StructRecord + { + name := "ProofContribution"; + ty_params := []; + fields := [ ("commitments", Ty.path "usize"); ("evaluations", Ty.path "usize") ]; + } *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_dev_cost_ProofContribution. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::cost::ProofContribution". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "ProofContribution" |); + M.read (| Value.String "commitments" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::ProofContribution", + "commitments" + |)); + M.read (| Value.String "evaluations" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::ProofContribution", + "evaluations" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_dev_cost_ProofContribution. + + Module Impl_halo2_proofs_dev_cost_ProofContribution. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::cost::ProofContribution". + + (* + fn new(commitments: usize, evaluations: usize) -> Self { + ProofContribution { + commitments, + evaluations, + } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ commitments; evaluations ] => + ltac:(M.monadic + (let commitments := M.alloc (| commitments |) in + let evaluations := M.alloc (| evaluations |) in + Value.StructRecord + "halo2_proofs::dev::cost::ProofContribution" + [ ("commitments", M.read (| commitments |)); ("evaluations", M.read (| evaluations |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + + (* + fn len(&self, point: usize, scalar: usize) -> usize { + self.commitments * point + self.evaluations * scalar + } + *) + Definition len (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; point; scalar ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let point := M.alloc (| point |) in + let scalar := M.alloc (| scalar |) in + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.mul (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::ProofContribution", + "commitments" + |) + |), + M.read (| point |) + |), + BinOp.Panic.mul (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::ProofContribution", + "evaluations" + |) + |), + M.read (| scalar |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_len : M.IsAssociatedFunction Self "len" len. + End Impl_halo2_proofs_dev_cost_ProofContribution. + + Module Impl_core_ops_arith_Add_for_halo2_proofs_dev_cost_ProofContribution. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::cost::ProofContribution". + + (* type Output = Self; *) + Definition _Output : Ty.t := Ty.path "halo2_proofs::dev::cost::ProofContribution". + + (* + fn add(self, rhs: Self) -> Self::Output { + Self { + commitments: self.commitments + rhs.commitments, + evaluations: self.evaluations + rhs.evaluations, + } + } + *) + Definition add (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + Value.StructRecord + "halo2_proofs::dev::cost::ProofContribution" + [ + ("commitments", + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::dev::cost::ProofContribution", + "commitments" + |) + |), + M.read (| + M.SubPointer.get_struct_record_field (| + rhs, + "halo2_proofs::dev::cost::ProofContribution", + "commitments" + |) + |) + |)); + ("evaluations", + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::dev::cost::ProofContribution", + "evaluations" + |) + |), + M.read (| + M.SubPointer.get_struct_record_field (| + rhs, + "halo2_proofs::dev::cost::ProofContribution", + "evaluations" + |) + |) + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::ops::arith::Add" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("Output", InstanceField.Ty _Output); ("add", InstanceField.Method add) ]. + End Impl_core_ops_arith_Add_for_halo2_proofs_dev_cost_ProofContribution. + + Module Impl_core_ops_arith_Mul_usize_for_halo2_proofs_dev_cost_ProofContribution. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::cost::ProofContribution". + + (* type Output = Self; *) + Definition _Output : Ty.t := Ty.path "halo2_proofs::dev::cost::ProofContribution". + + (* + fn mul(self, instances: usize) -> Self::Output { + Self { + commitments: self.commitments * instances, + evaluations: self.evaluations * instances, + } + } + *) + Definition mul (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; instances ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let instances := M.alloc (| instances |) in + Value.StructRecord + "halo2_proofs::dev::cost::ProofContribution" + [ + ("commitments", + BinOp.Panic.mul (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::dev::cost::ProofContribution", + "commitments" + |) + |), + M.read (| instances |) + |)); + ("evaluations", + BinOp.Panic.mul (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::dev::cost::ProofContribution", + "evaluations" + |) + |), + M.read (| instances |) + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::ops::arith::Mul" + Self + (* Trait polymorphic types *) [ (* Rhs *) Ty.path "usize" ] + (* Instance *) + [ ("Output", InstanceField.Ty _Output); ("mul", InstanceField.Method mul) ]. + End Impl_core_ops_arith_Mul_usize_for_halo2_proofs_dev_cost_ProofContribution. + + (* StructRecord + { + name := "MarginalProofSize"; + ty_params := [ "G" ]; + fields := + [ + ("instance", Ty.path "halo2_proofs::dev::cost::ProofContribution"); + ("advice", Ty.path "halo2_proofs::dev::cost::ProofContribution"); + ("lookups", Ty.path "halo2_proofs::dev::cost::ProofContribution"); + ("equality", Ty.path "halo2_proofs::dev::cost::ProofContribution"); + ("_marker", Ty.apply (Ty.path "core::marker::PhantomData") [ G ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_G_where_group_prime_PrimeGroup_G_for_halo2_proofs_dev_cost_MarginalProofSize_G. + Definition Self (G : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::dev::cost::MarginalProofSize") [ G ]. + + (* Debug *) + Definition fmt (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field5_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "MarginalProofSize" |); + M.read (| Value.String "instance" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::MarginalProofSize", + "instance" + |)); + M.read (| Value.String "advice" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::MarginalProofSize", + "advice" + |)); + M.read (| Value.String "lookups" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::MarginalProofSize", + "lookups" + |)); + M.read (| Value.String "equality" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::MarginalProofSize", + "equality" + |)); + M.read (| Value.String "_marker" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::MarginalProofSize", + "_marker" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (G : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self G) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt G)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_G_where_group_prime_PrimeGroup_G_for_halo2_proofs_dev_cost_MarginalProofSize_G. + + Module Impl_core_convert_From_where_group_prime_PrimeGroup_G_halo2_proofs_dev_cost_MarginalProofSize_G_for_usize. + Definition Self (G : Ty.t) : Ty.t := Ty.path "usize". + + (* + fn from(proof: MarginalProofSize) -> Self { + let point = G::Repr::default().as_ref().len(); + let scalar = ::Repr::default().as_ref().len(); + + proof.instance.len(point, scalar) + + proof.advice.len(point, scalar) + + proof.lookups.len(point, scalar) + + proof.equality.len(point, scalar) + } + *) + Definition from (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ proof ] => + ltac:(M.monadic + (let proof := M.alloc (| proof |) in + M.read (| + let point := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u8" ], + "len", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.associated, + [], + "default", + [] + |), + [] + |) + |) + ] + |) + ] + |) + |) in + let scalar := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u8" ], + "len", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.associated, + [], + "default", + [] + |), + [] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + proof, + "halo2_proofs::dev::cost::MarginalProofSize", + "instance" + |); + M.read (| point |); + M.read (| scalar |) + ] + |), + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + proof, + "halo2_proofs::dev::cost::MarginalProofSize", + "advice" + |); + M.read (| point |); + M.read (| scalar |) + ] + |) + |), + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + proof, + "halo2_proofs::dev::cost::MarginalProofSize", + "lookups" + |); + M.read (| point |); + M.read (| scalar |) + ] + |) + |), + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + proof, + "halo2_proofs::dev::cost::MarginalProofSize", + "equality" + |); + M.read (| point |); + M.read (| scalar |) + ] + |) + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (G : Ty.t), + M.IsTraitInstance + "core::convert::From" + (Self G) + (* Trait polymorphic types *) + [ (* T *) Ty.apply (Ty.path "halo2_proofs::dev::cost::MarginalProofSize") [ G ] ] + (* Instance *) [ ("from", InstanceField.Method (from G)) ]. + End Impl_core_convert_From_where_group_prime_PrimeGroup_G_halo2_proofs_dev_cost_MarginalProofSize_G_for_usize. + + (* StructRecord + { + name := "ProofSize"; + ty_params := [ "G" ]; + fields := + [ + ("instance", Ty.path "halo2_proofs::dev::cost::ProofContribution"); + ("advice", Ty.path "halo2_proofs::dev::cost::ProofContribution"); + ("fixed", Ty.path "halo2_proofs::dev::cost::ProofContribution"); + ("lookups", Ty.path "halo2_proofs::dev::cost::ProofContribution"); + ("equality", Ty.path "halo2_proofs::dev::cost::ProofContribution"); + ("vanishing", Ty.path "halo2_proofs::dev::cost::ProofContribution"); + ("multiopen", Ty.path "halo2_proofs::dev::cost::ProofContribution"); + ("polycomm", Ty.path "halo2_proofs::dev::cost::ProofContribution"); + ("_marker", Ty.apply (Ty.path "core::marker::PhantomData") [ G ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_G_where_group_prime_PrimeGroup_G_for_halo2_proofs_dev_cost_ProofSize_G. + Definition Self (G : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::dev::cost::ProofSize") [ G ]. + + (* Debug *) + Definition fmt (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let names := + M.alloc (| + M.alloc (| + Value.Array + [ + M.read (| Value.String "instance" |); + M.read (| Value.String "advice" |); + M.read (| Value.String "fixed" |); + M.read (| Value.String "lookups" |); + M.read (| Value.String "equality" |); + M.read (| Value.String "vanishing" |); + M.read (| Value.String "multiopen" |); + M.read (| Value.String "polycomm" |); + M.read (| Value.String "_marker" |) + ] + |) + |) in + let values := + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::ProofSize", + "instance" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::ProofSize", + "advice" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::ProofSize", + "fixed" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::ProofSize", + "lookups" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::ProofSize", + "equality" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::ProofSize", + "vanishing" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::ProofSize", + "multiopen" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::ProofSize", + "polycomm" + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::cost::ProofSize", + "_marker" + |) + |)) + ] + |)) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_fields_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "ProofSize" |); + (* Unsize *) M.pointer_coercion (M.read (| names |)); + M.read (| values |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (G : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self G) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt G)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_G_where_group_prime_PrimeGroup_G_for_halo2_proofs_dev_cost_ProofSize_G. + + Module Impl_core_convert_From_where_group_prime_PrimeGroup_G_halo2_proofs_dev_cost_ProofSize_G_for_usize. + Definition Self (G : Ty.t) : Ty.t := Ty.path "usize". + + (* + fn from(proof: ProofSize) -> Self { + let point = G::Repr::default().as_ref().len(); + let scalar = ::Repr::default().as_ref().len(); + + proof.instance.len(point, scalar) + + proof.advice.len(point, scalar) + + proof.fixed.len(point, scalar) + + proof.lookups.len(point, scalar) + + proof.equality.len(point, scalar) + + proof.vanishing.len(point, scalar) + + proof.multiopen.len(point, scalar) + + proof.polycomm.len(point, scalar) + } + *) + Definition from (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ proof ] => + ltac:(M.monadic + (let proof := M.alloc (| proof |) in + M.read (| + let point := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u8" ], + "len", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.associated, + [], + "default", + [] + |), + [] + |) + |) + ] + |) + ] + |) + |) in + let scalar := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u8" ], + "len", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.associated, + [], + "default", + [] + |), + [] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + proof, + "halo2_proofs::dev::cost::ProofSize", + "instance" + |); + M.read (| point |); + M.read (| scalar |) + ] + |), + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + proof, + "halo2_proofs::dev::cost::ProofSize", + "advice" + |); + M.read (| point |); + M.read (| scalar |) + ] + |) + |), + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + proof, + "halo2_proofs::dev::cost::ProofSize", + "fixed" + |); + M.read (| point |); + M.read (| scalar |) + ] + |) + |), + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + proof, + "halo2_proofs::dev::cost::ProofSize", + "lookups" + |); + M.read (| point |); + M.read (| scalar |) + ] + |) + |), + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + proof, + "halo2_proofs::dev::cost::ProofSize", + "equality" + |); + M.read (| point |); + M.read (| scalar |) + ] + |) + |), + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + proof, + "halo2_proofs::dev::cost::ProofSize", + "vanishing" + |); + M.read (| point |); + M.read (| scalar |) + ] + |) + |), + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + proof, + "halo2_proofs::dev::cost::ProofSize", + "multiopen" + |); + M.read (| point |); + M.read (| scalar |) + ] + |) + |), + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::dev::cost::ProofContribution", + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + proof, + "halo2_proofs::dev::cost::ProofSize", + "polycomm" + |); + M.read (| point |); + M.read (| scalar |) + ] + |) + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (G : Ty.t), + M.IsTraitInstance + "core::convert::From" + (Self G) + (* Trait polymorphic types *) + [ (* T *) Ty.apply (Ty.path "halo2_proofs::dev::cost::ProofSize") [ G ] ] + (* Instance *) [ ("from", InstanceField.Method (from G)) ]. + End Impl_core_convert_From_where_group_prime_PrimeGroup_G_halo2_proofs_dev_cost_ProofSize_G_for_usize. + End cost. +End dev. diff --git a/CoqOfRust/halo2_proofs/dev/gates.v b/CoqOfRust/halo2_proofs/dev/gates.v new file mode 100644 index 000000000..8e17a2dff --- /dev/null +++ b/CoqOfRust/halo2_proofs/dev/gates.v @@ -0,0 +1,8107 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module dev. + Module gates. + (* StructRecord + { + name := "Constraint"; + ty_params := []; + fields := + [ + ("name", Ty.apply (Ty.path "&") [ Ty.path "str" ]); + ("expression", Ty.path "alloc::string::String"); + ("queries", + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ Ty.path "alloc::string::String"; Ty.path "alloc::alloc::Global" ]) + ]; + } *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_dev_gates_Constraint. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::gates::Constraint". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Constraint" |); + M.read (| Value.String "name" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::gates::Constraint", + "name" + |)); + M.read (| Value.String "expression" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::gates::Constraint", + "expression" + |)); + M.read (| Value.String "queries" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::gates::Constraint", + "queries" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_dev_gates_Constraint. + + (* StructRecord + { + name := "Gate"; + ty_params := []; + fields := + [ + ("name", Ty.apply (Ty.path "&") [ Ty.path "str" ]); + ("constraints", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "halo2_proofs::dev::gates::Constraint"; Ty.path "alloc::alloc::Global" ]) + ]; + } *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_dev_gates_Gate. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::gates::Gate". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Gate" |); + M.read (| Value.String "name" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::gates::Gate", + "name" + |)); + M.read (| Value.String "constraints" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::gates::Gate", + "constraints" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_dev_gates_Gate. + + (* StructRecord + { + name := "CircuitGates"; + ty_params := []; + fields := + [ + ("gates", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "halo2_proofs::dev::gates::Gate"; Ty.path "alloc::alloc::Global" ]); + ("total_negations", Ty.path "usize"); + ("total_additions", Ty.path "usize"); + ("total_multiplications", Ty.path "usize") + ]; + } *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_dev_gates_CircuitGates. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::gates::CircuitGates". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field4_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "CircuitGates" |); + M.read (| Value.String "gates" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::gates::CircuitGates", + "gates" + |)); + M.read (| Value.String "total_negations" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::gates::CircuitGates", + "total_negations" + |)); + M.read (| Value.String "total_additions" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::gates::CircuitGates", + "total_additions" + |)); + M.read (| Value.String "total_multiplications" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::gates::CircuitGates", + "total_multiplications" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_dev_gates_CircuitGates. + + Module Impl_halo2_proofs_dev_gates_CircuitGates. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::gates::CircuitGates". + + (* + pub fn collect>() -> Self { + // Collect the graph details. + let mut cs = ConstraintSystem::default(); + let _ = C::configure(&mut cs); + + let gates = cs + .gates + .iter() + .map(|gate| Gate { + name: gate.name(), + constraints: gate + .polynomials() + .iter() + .enumerate() + .map(|(i, constraint)| Constraint { + name: gate.constraint_name(i), + expression: constraint.evaluate( + &util::format_value, + &|selector| format!("S{}", selector.0), + &|_, column, rotation| format!("F{}@{}", column, rotation.0), + &|_, column, rotation| format!("A{}@{}", column, rotation.0), + &|_, column, rotation| format!("I{}@{}", column, rotation.0), + &|a| { + if a.contains(' ') { + format!("-({})", a) + } else { + format!("-{}", a) + } + }, + &|a, b| { + if let Some(b) = b.strip_prefix('-') { + format!("{} - {}", a, b) + } else { + format!("{} + {}", a, b) + } + }, + &|a, b| { + let a = a(); + let b = b(); + match (a.contains(' '), b.contains(' ')) { + (false, false) => format!("{} * {}", a, b), + (false, true) => format!("{} * ({})", a, b), + (true, false) => format!("({}) * {}", a, b), + (true, true) => format!("({}) * ({})", a, b), + } + }, + &|a, s| { + if a.contains(' ') { + format!("({}) * {}", a, util::format_value(s)) + } else { + format!("{} * {}", a, util::format_value(s)) + } + }, + ), + queries: constraint.evaluate( + &|_| BTreeSet::default(), + &|selector| vec![format!("S{}", selector.0)].into_iter().collect(), + &|_, column, rotation| { + vec![format!("F{}@{}", column, rotation.0)] + .into_iter() + .collect() + }, + &|_, column, rotation| { + vec![format!("A{}@{}", column, rotation.0)] + .into_iter() + .collect() + }, + &|_, column, rotation| { + vec![format!("I{}@{}", column, rotation.0)] + .into_iter() + .collect() + }, + &|a| a, + &|mut a, mut b| { + a.append(&mut b); + a + }, + &|a, b| { + let mut a = a(); + let mut b = b(); + a.append(&mut b); + a + }, + &|a, _| a, + ), + }) + .collect(), + }) + .collect(); + + let (total_negations, total_additions, total_multiplications) = cs + .gates + .iter() + .flat_map(|gate| { + gate.polynomials().iter().map(|poly| { + poly.evaluate( + &|_| (0, 0, 0), + &|_| (0, 0, 0), + &|_, _, _| (0, 0, 0), + &|_, _, _| (0, 0, 0), + &|_, _, _| (0, 0, 0), + &|(a_n, a_a, a_m)| (a_n + 1, a_a, a_m), + &|(a_n, a_a, a_m), (b_n, b_a, b_m)| (a_n + b_n, a_a + b_a + 1, a_m + b_m), + &|a, b| { + let (a_n, a_a, a_m) = a(); + let (b_n, b_a, b_m) = b(); + (a_n + b_n, a_a + b_a, a_m + b_m + 1) + }, + &|(a_n, a_a, a_m), _| (a_n, a_a, a_m + 1), + ) + }) + }) + .fold((0, 0, 0), |(acc_n, acc_a, acc_m), (n, a, m)| { + (acc_n + n, acc_a + a, acc_m + m) + }); + + CircuitGates { + gates, + total_negations, + total_additions, + total_multiplications, + } + } + *) + Definition collect (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F; C ], [] => + ltac:(M.monadic + (M.read (| + let cs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + [], + "default", + [] + |), + [] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Circuit", + C, + [ F ], + "configure", + [] + |), + [ cs ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let gates := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + (Ty.path "halo2_proofs::dev::gates::Gate") + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::dev::gates::Gate"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ] + ], + [], + "map", + [ + Ty.path "halo2_proofs::dev::gates::Gate"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + (Ty.path "halo2_proofs::dev::gates::Gate") + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "gates" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let gate := M.copy (| γ |) in + Value.StructRecord + "halo2_proofs::dev::gates::Gate" + [ + ("name", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ], + "name", + [] + |), + [ M.read (| gate |) ] + |)); + ("constraints", + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.path + "halo2_proofs::dev::gates::Constraint") + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::dev::gates::Constraint"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ], + [], + "map", + [ + Ty.path + "halo2_proofs::dev::gates::Constraint"; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.path + "halo2_proofs::dev::gates::Constraint") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ], + "polynomials", + [] + |), + [ M.read (| gate |) ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let i := + M.copy (| + γ0_0 + |) in + let constraint := + M.copy (| + γ0_1 + |) in + Value.StructRecord + "halo2_proofs::dev::gates::Constraint" + [ + ("name", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ], + "constraint_name", + [] + |), + [ + M.read (| + gate + |); + M.read (| + i + |) + ] + |)); + ("expression", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + "evaluate", + [ + Ty.path + "alloc::string::String"; + Ty.function + [ F ] + (Ty.path + "alloc::string::String"); + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ] + ] + (Ty.path + "alloc::string::String"); + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + (Ty.path + "alloc::string::String"); + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + (Ty.path + "alloc::string::String"); + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + (Ty.path + "alloc::string::String"); + Ty.function + [ + Ty.tuple + [ + Ty.path + "alloc::string::String" + ] + ] + (Ty.path + "alloc::string::String"); + Ty.function + [ + Ty.tuple + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::string::String" + ] + ] + (Ty.path + "alloc::string::String"); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ] + ] + ] + ] + (Ty.path + "alloc::string::String"); + Ty.function + [ + Ty.tuple + [ + Ty.path + "alloc::string::String"; + F + ] + ] + (Ty.path + "alloc::string::String") + ] + |), + [ + M.read (| + constraint + |); + M.alloc (| + M.get_function (| + "halo2_proofs::dev::util::format_value", + [ F ] + |) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + selector := + M.copy (| + γ + |) in + M.read (| + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "S" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "usize" + ] + |), + [ + M.SubPointer.get_struct_tuple_field (| + selector, + "halo2_proofs::plonk::circuit::Selector", + 0 + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1; + α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + column := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (let + rotation := + M.copy (| + γ + |) in + M.read (| + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "F" + |); + M.read (| + Value.String + "@" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "usize" + ] + |), + [ + column + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "i32" + ] + |), + [ + M.SubPointer.get_struct_tuple_field (| + rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1; + α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + column := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (let + rotation := + M.copy (| + γ + |) in + M.read (| + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "A" + |); + M.read (| + Value.String + "@" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "usize" + ] + |), + [ + column + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "i32" + ] + |), + [ + M.SubPointer.get_struct_tuple_field (| + rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1; + α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + column := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (let + rotation := + M.copy (| + γ + |) in + M.read (| + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "I" + |); + M.read (| + Value.String + "@" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "usize" + ] + |), + [ + column + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "i32" + ] + |), + [ + M.SubPointer.get_struct_tuple_field (| + rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.read (| + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "str", + "contains", + [ + Ty.path + "char" + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + a + ] + |); + Value.UnicodeChar + 32 + ] + |) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "-(" + |); + M.read (| + Value.String + ")" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + a + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)); + fun + γ => + ltac:(M.monadic + (let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "-" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + a + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + b := + M.copy (| + γ + |) in + M.read (| + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "str", + "strip_prefix", + [ + Ty.path + "char" + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + b + ] + |); + Value.UnicodeChar + 45 + ] + |) + |) in + let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + b := + M.copy (| + γ0_0 + |) in + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " - " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + a + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + b + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)); + fun + γ => + ltac:(M.monadic + (let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " + " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + a + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + b + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)) + ] + |) + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + b := + M.copy (| + γ + |) in + M.read (| + let + a := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ], + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.read (| + a + |); + Value.Tuple + [] + ] + |) + |) in + let + b := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ], + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.read (| + b + |); + Value.Tuple + [] + ] + |) + |) in + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "str", + "contains", + [ + Ty.path + "char" + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + a + ] + |); + Value.UnicodeChar + 32 + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "str", + "contains", + [ + Ty.path + "char" + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + b + ] + |); + Value.UnicodeChar + 32 + ] + |) + ] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ0_0 + |), + Value.Bool + false + |) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ0_1 + |), + Value.Bool + false + |) in + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " * " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + a + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + b + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ0_0 + |), + Value.Bool + false + |) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ0_1 + |), + Value.Bool + true + |) in + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " * (" + |); + M.read (| + Value.String + ")" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + a + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + b + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ0_0 + |), + Value.Bool + true + |) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ0_1 + |), + Value.Bool + false + |) in + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "(" + |); + M.read (| + Value.String + ") * " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + a + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + b + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ0_0 + |), + Value.Bool + true + |) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ0_1 + |), + Value.Bool + true + |) in + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "(" + |); + M.read (| + Value.String + ") * (" + |); + M.read (| + Value.String + ")" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + a + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + b + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)) + ] + |) + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + s := + M.copy (| + γ + |) in + M.read (| + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "str", + "contains", + [ + Ty.path + "char" + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + a + ] + |); + Value.UnicodeChar + 32 + ] + |) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "(" + |); + M.read (| + Value.String + ") * " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + a + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::dev::util::format_value", + [ + F + ] + |), + [ + M.read (| + s + |) + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)); + fun + γ => + ltac:(M.monadic + (let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " * " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + a + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::dev::util::format_value", + [ + F + ] + |), + [ + M.read (| + s + |) + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)) + ] + |) + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |) + ] + |)); + ("queries", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + "evaluate", + [ + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + F + ] + ] + (Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ] + ] + (Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + (Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + (Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + (Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ] + ] + ] + ] + (Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ]; + F + ] + ] + (Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| + constraint + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ], + [], + "default", + [] + |), + [] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + selector := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.path + "alloc::string::String" + ], + "into_vec", + [ + Ty.path + "alloc::alloc::Global" + ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.path + "alloc::string::String" + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.read (| + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "S" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "usize" + ] + |), + [ + M.SubPointer.get_struct_tuple_field (| + selector, + "halo2_proofs::plonk::circuit::Selector", + 0 + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1; + α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + column := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (let + rotation := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.path + "alloc::string::String" + ], + "into_vec", + [ + Ty.path + "alloc::alloc::Global" + ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.path + "alloc::string::String" + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.read (| + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "F" + |); + M.read (| + Value.String + "@" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "usize" + ] + |), + [ + column + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "i32" + ] + |), + [ + M.SubPointer.get_struct_tuple_field (| + rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |) + ] + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1; + α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + column := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (let + rotation := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.path + "alloc::string::String" + ], + "into_vec", + [ + Ty.path + "alloc::alloc::Global" + ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.path + "alloc::string::String" + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.read (| + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "A" + |); + M.read (| + Value.String + "@" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "usize" + ] + |), + [ + column + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "i32" + ] + |), + [ + M.SubPointer.get_struct_tuple_field (| + rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |) + ] + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1; + α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + column := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (let + rotation := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.path + "alloc::string::String" + ], + "into_vec", + [ + Ty.path + "alloc::alloc::Global" + ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.path + "alloc::string::String" + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.read (| + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "I" + |); + M.read (| + Value.String + "@" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "usize" + ] + |), + [ + column + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "i32" + ] + |), + [ + M.SubPointer.get_struct_tuple_field (| + rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |) + ] + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.read (| + a + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + b := + M.copy (| + γ + |) in + M.read (| + let + _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ], + "append", + [] + |), + [ + a; + b + ] + |) + |) in + a + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + b := + M.copy (| + γ + |) in + M.read (| + let + a := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ], + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.read (| + a + |); + Value.Tuple + [] + ] + |) + |) in + let + b := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ], + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.read (| + b + |); + Value.Tuple + [] + ] + |) + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ], + "append", + [] + |), + [ + a; + b + ] + |) + |) in + a + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + a + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |) + ] + |)) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |)) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + (Ty.tuple + [ Ty.path "usize"; Ty.path "usize"; Ty.path "usize" ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + (Ty.tuple + [ Ty.path "usize"; Ty.path "usize"; Ty.path "usize" ]) + ]) + ], + [], + "fold", + [ + Ty.tuple [ Ty.path "usize"; Ty.path "usize"; Ty.path "usize" ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ Ty.path "usize"; Ty.path "usize"; Ty.path "usize" ]; + Ty.tuple + [ Ty.path "usize"; Ty.path "usize"; Ty.path "usize" ] + ] + ] + (Ty.tuple [ Ty.path "usize"; Ty.path "usize"; Ty.path "usize" ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ] + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + (Ty.tuple + [ Ty.path "usize"; Ty.path "usize"; Ty.path "usize" ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + (Ty.tuple + [ Ty.path "usize"; Ty.path "usize"; Ty.path "usize" ]) + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "gates" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let gate := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + [], + "map", + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "usize" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "usize" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ], + "polynomials", + [] + |), + [ M.read (| gate |) ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let poly := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + "evaluate", + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "usize" + ]; + Ty.function + [ Ty.tuple [ F ] ] + (Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "usize" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ] + ] + (Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "usize" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + (Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "usize" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + (Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "usize" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + (Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "usize" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "usize" + ] + ] + ] + (Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "usize" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "usize" + ]; + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "usize" + ] + ] + ] + (Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "usize" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ] + ] + ] + ] + (Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "usize" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "usize" + ]; + F + ] + ] + (Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "usize" + ]) + ] + |), + [ + M.read (| poly |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (Value.Tuple + [ + Value.Integer + 0; + Value.Integer + 0; + Value.Integer + 0 + ])) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (Value.Tuple + [ + Value.Integer + 0; + Value.Integer + 0; + Value.Integer + 0 + ])) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.Tuple + [ + Value.Integer + 0; + Value.Integer + 0; + Value.Integer + 0 + ])) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.Tuple + [ + Value.Integer + 0; + Value.Integer + 0; + Value.Integer + 0 + ])) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.Tuple + [ + Value.Integer + 0; + Value.Integer + 0; + Value.Integer + 0 + ])) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + γ0_2 := + M.SubPointer.get_tuple_field (| + γ, + 2 + |) in + let + a_n := + M.copy (| + γ0_0 + |) in + let + a_a := + M.copy (| + γ0_1 + |) in + let + a_m := + M.copy (| + γ0_2 + |) in + Value.Tuple + [ + BinOp.Panic.add (| + Integer.Usize, + M.read (| + a_n + |), + Value.Integer + 1 + |); + M.read (| + a_a + |); + M.read (| + a_m + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + γ0_2 := + M.SubPointer.get_tuple_field (| + γ, + 2 + |) in + let + a_n := + M.copy (| + γ0_0 + |) in + let + a_a := + M.copy (| + γ0_1 + |) in + let + a_m := + M.copy (| + γ0_2 + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + γ0_2 := + M.SubPointer.get_tuple_field (| + γ, + 2 + |) in + let + b_n := + M.copy (| + γ0_0 + |) in + let + b_a := + M.copy (| + γ0_1 + |) in + let + b_m := + M.copy (| + γ0_2 + |) in + Value.Tuple + [ + BinOp.Panic.add (| + Integer.Usize, + M.read (| + a_n + |), + M.read (| + b_n + |) + |); + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.read (| + a_a + |), + M.read (| + b_a + |) + |), + Value.Integer + 1 + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + a_m + |), + M.read (| + b_m + |) + |) + ])) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + b := + M.copy (| + γ + |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ], + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.read (| + a + |); + Value.Tuple + [] + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + γ0_2 := + M.SubPointer.get_tuple_field (| + γ, + 2 + |) in + let + a_n := + M.copy (| + γ0_0 + |) in + let + a_a := + M.copy (| + γ0_1 + |) in + let + a_m := + M.copy (| + γ0_2 + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ], + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.read (| + b + |); + Value.Tuple + [] + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + γ0_2 := + M.SubPointer.get_tuple_field (| + γ, + 2 + |) in + let + b_n := + M.copy (| + γ0_0 + |) in + let + b_a := + M.copy (| + γ0_1 + |) in + let + b_m := + M.copy (| + γ0_2 + |) in + M.alloc (| + Value.Tuple + [ + BinOp.Panic.add (| + Integer.Usize, + M.read (| + a_n + |), + M.read (| + b_n + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + a_a + |), + M.read (| + b_a + |) + |); + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.read (| + a_m + |), + M.read (| + b_m + |) + |), + Value.Integer + 1 + |) + ] + |))) + ] + |))) + ] + |) + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + γ0_2 := + M.SubPointer.get_tuple_field (| + γ, + 2 + |) in + let + a_n := + M.copy (| + γ0_0 + |) in + let + a_a := + M.copy (| + γ0_1 + |) in + let + a_m := + M.copy (| + γ0_2 + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.Tuple + [ + M.read (| + a_n + |); + M.read (| + a_a + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + a_m + |), + Value.Integer + 1 + |) + ])) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + Value.Tuple [ Value.Integer 0; Value.Integer 0; Value.Integer 0 ]; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_2 := M.SubPointer.get_tuple_field (| γ, 2 |) in + let acc_n := M.copy (| γ0_0 |) in + let acc_a := M.copy (| γ0_1 |) in + let acc_m := M.copy (| γ0_2 |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_2 := + M.SubPointer.get_tuple_field (| γ, 2 |) in + let n := M.copy (| γ0_0 |) in + let a := M.copy (| γ0_1 |) in + let m := M.copy (| γ0_2 |) in + Value.Tuple + [ + BinOp.Panic.add (| + Integer.Usize, + M.read (| acc_n |), + M.read (| n |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| acc_a |), + M.read (| a |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| acc_m |), + M.read (| m |) + |) + ])) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_2 := M.SubPointer.get_tuple_field (| γ, 2 |) in + let total_negations := M.copy (| γ0_0 |) in + let total_additions := M.copy (| γ0_1 |) in + let total_multiplications := M.copy (| γ0_2 |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::dev::gates::CircuitGates" + [ + ("gates", M.read (| gates |)); + ("total_negations", M.read (| total_negations |)); + ("total_additions", M.read (| total_additions |)); + ("total_multiplications", M.read (| total_multiplications |)) + ] + |))) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_collect : M.IsAssociatedFunction Self "collect" collect. + + (* + pub fn queries_to_csv(&self) -> String { + let mut queries = BTreeSet::new(); + for gate in &self.gates { + for constraint in &gate.constraints { + for query in &constraint.queries { + queries.insert(query); + } + } + } + + let mut ret = String::new(); + let w = &mut ret; + for query in &queries { + write!(w, "{},", query).unwrap(); + } + writeln!(w, "Name").unwrap(); + + for gate in &self.gates { + for constraint in &gate.constraints { + for query in &queries { + if constraint.queries.contains( *query) { + write!(w, "1").unwrap(); + } else { + write!(w, "0").unwrap(); + } + write!(w, ",").unwrap(); + } + writeln!(w, "{}/{}", gate.name, constraint.name).unwrap(); + } + } + ret + } + *) + Definition queries_to_csv (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let queries := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.apply (Ty.path "&") [ Ty.path "alloc::string::String" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::dev::gates::Gate"; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::gates::CircuitGates", + "gates" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::dev::gates::Gate" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let gate := M.copy (| γ0_0 |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::dev::gates::Constraint"; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| gate |), + "halo2_proofs::dev::gates::Gate", + "constraints" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::dev::gates::Constraint" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let constraint := + M.copy (| γ0_0 |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| constraint |), + "halo2_proofs::dev::gates::Constraint", + "queries" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := + M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::collections::btree::set::Iter") + [ + Ty.path + "alloc::string::String" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let query := + M.copy (| + γ0_0 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "alloc::string::String" + ]; + Ty.path + "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + queries; + M.read (| + query + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let ret := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "alloc::string::String", "new", [] |), + [] + |) + |) in + let w := M.alloc (| ret |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.apply (Ty.path "&") [ Ty.path "alloc::string::String" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ queries ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::collections::btree::set::Iter") + [ + Ty.apply + (Ty.path "&") + [ Ty.path "alloc::string::String" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let query := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "core::fmt::Error" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::fmt::Write", + Ty.path "alloc::string::String", + [], + "write_fmt", + [] + |), + [ + M.read (| w |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "" |); + M.read (| Value.String "," |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "alloc::string::String" + ] + ] + ] + |), + [ query ] + |) + ] + |)) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "core::fmt::Error" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::fmt::Write", + Ty.path "alloc::string::String", + [], + "write_fmt", + [] + |), + [ + M.read (| w |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| Value.Array [ M.read (| Value.String "Name +" |) ] |)) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::dev::gates::Gate"; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::gates::CircuitGates", + "gates" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::dev::gates::Gate" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let gate := M.copy (| γ0_0 |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::dev::gates::Constraint"; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| gate |), + "halo2_proofs::dev::gates::Gate", + "constraints" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::dev::gates::Constraint" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let constraint := + M.copy (| γ0_0 |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "alloc::string::String" + ]; + Ty.path + "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ queries ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := + M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::collections::btree::set::Iter") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "alloc::string::String" + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + query := + M.copy (| + γ0_0 + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "alloc::string::String"; + Ty.path + "alloc::alloc::Global" + ], + "contains", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + constraint + |), + "halo2_proofs::dev::gates::Constraint", + "queries" + |); + M.read (| + M.read (| + query + |) + |) + ] + |) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "core::fmt::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::fmt::Write", + Ty.path + "alloc::string::String", + [], + "write_fmt", + [] + |), + [ + M.read (| + w + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "1" + |) + ] + |)) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))); + fun + γ => + ltac:(M.monadic + (let + _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "core::fmt::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::fmt::Write", + Ty.path + "alloc::string::String", + [], + "write_fmt", + [] + |), + [ + M.read (| + w + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "0" + |) + ] + |)) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "core::fmt::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::fmt::Write", + Ty.path + "alloc::string::String", + [], + "write_fmt", + [] + |), + [ + M.read (| + w + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "," + |) + ] + |)) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "core::fmt::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::fmt::Write", + Ty.path + "alloc::string::String", + [], + "write_fmt", + [] + |), + [ + M.read (| w |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "/" + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + gate + |), + "halo2_proofs::dev::gates::Gate", + "name" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + constraint + |), + "halo2_proofs::dev::gates::Constraint", + "name" + |) + ] + |) + ] + |)) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + ret + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_queries_to_csv : + M.IsAssociatedFunction Self "queries_to_csv" queries_to_csv. + End Impl_halo2_proofs_dev_gates_CircuitGates. + + Module Impl_core_fmt_Display_for_halo2_proofs_dev_gates_CircuitGates. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::gates::CircuitGates". + + (* + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { + for gate in &self.gates { + writeln!(f, "{}:", gate.name)?; + for constraint in &gate.constraints { + if constraint.name.is_empty() { + writeln!(f, "- {}", constraint.expression)?; + } else { + writeln!(f, "- {}:", constraint.name)?; + writeln!(f, " {}", constraint.expression)?; + } + } + } + writeln!(f, "Total gates: {}", self.gates.len())?; + writeln!( + f, + "Total custom constraint polynomials: {}", + self.gates + .iter() + .map(|gate| gate.constraints.len()) + .sum::() + )?; + writeln!(f, "Total negations: {}", self.total_negations)?; + writeln!(f, "Total additions: {}", self.total_additions)?; + writeln!(f, "Total multiplications: {}", self.total_multiplications) + } + *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::dev::gates::Gate"; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::gates::CircuitGates", + "gates" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::dev::gates::Gate" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let gate := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "core::fmt::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "" |); + M.read (| Value.String ": +" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| gate |), + "halo2_proofs::dev::gates::Gate", + "name" + |) + ] + |) + ] + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "core::fmt::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path "core::fmt::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::dev::gates::Constraint"; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| gate |), + "halo2_proofs::dev::gates::Gate", + "constraints" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::dev::gates::Constraint" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let constraint := + M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "str", + "is_empty", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + constraint + |), + "halo2_proofs::dev::gates::Constraint", + "name" + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "core::fmt::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| + f + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "- " + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + constraint + |), + "halo2_proofs::dev::gates::Constraint", + "expression" + |) + ] + |) + ] + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "core::fmt::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "core::fmt::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple [] + |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "core::fmt::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| + f + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "- " + |); + M.read (| + Value.String + ": +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + constraint + |), + "halo2_proofs::dev::gates::Constraint", + "name" + |) + ] + |) + ] + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "core::fmt::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "core::fmt::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "core::fmt::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| + f + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + " " + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + constraint + |), + "halo2_proofs::dev::gates::Constraint", + "expression" + |) + ] + |) + ] + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "core::fmt::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "core::fmt::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "core::fmt::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "Total gates: " |); + M.read (| Value.String " +" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::dev::gates::Gate"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::gates::CircuitGates", + "gates" + |) + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "core::fmt::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "core::fmt::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "core::fmt::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String "Total custom constraint polynomials: " + |); + M.read (| Value.String " +" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::dev::gates::Gate" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::dev::gates::Gate" + ] + ] + ] + (Ty.path "usize") + ], + [], + "sum", + [ Ty.path "usize" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::dev::gates::Gate" + ], + [], + "map", + [ + Ty.path "usize"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::dev::gates::Gate" + ] + ] + ] + (Ty.path "usize") + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "halo2_proofs::dev::gates::Gate" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::dev::gates::Gate"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::gates::CircuitGates", + "gates" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let gate := + M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::dev::gates::Constraint"; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| gate |), + "halo2_proofs::dev::gates::Gate", + "constraints" + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "core::fmt::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "core::fmt::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "core::fmt::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "Total negations: " |); + M.read (| Value.String " +" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::gates::CircuitGates", + "total_negations" + |) + ] + |) + ] + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "core::fmt::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "core::fmt::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "core::fmt::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "Total additions: " |); + M.read (| Value.String " +" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::gates::CircuitGates", + "total_additions" + |) + ] + |) + ] + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "core::fmt::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "core::fmt::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "Total multiplications: " |); + M.read (| Value.String " +" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::gates::CircuitGates", + "total_multiplications" + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Display" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Display_for_halo2_proofs_dev_gates_CircuitGates. + End gates. +End dev. diff --git a/CoqOfRust/halo2_proofs/dev/metadata.v b/CoqOfRust/halo2_proofs/dev/metadata.v new file mode 100644 index 000000000..1c321429c --- /dev/null +++ b/CoqOfRust/halo2_proofs/dev/metadata.v @@ -0,0 +1,2444 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module dev. + Module metadata. + (* StructRecord + { + name := "Column"; + ty_params := []; + fields := + [ ("column_type", Ty.path "halo2_proofs::plonk::circuit::Any"); ("index", Ty.path "usize") + ]; + } *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_dev_metadata_Column. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Column". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Column" |); + M.read (| Value.String "column_type" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Column", + "column_type" + |)); + M.read (| Value.String "index" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Column", + "index" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_dev_metadata_Column. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_dev_metadata_Column. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Column". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_dev_metadata_Column. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_dev_metadata_Column. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Column". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::plonk::circuit::Any", + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Column", + "column_type" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::Column", + "column_type" + |) + ] + |), + ltac:(M.monadic + (BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Column", + "index" + |) + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::Column", + "index" + |) + |)))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_dev_metadata_Column. + + Module Impl_core_marker_StructuralEq_for_halo2_proofs_dev_metadata_Column. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Column". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralEq_for_halo2_proofs_dev_metadata_Column. + + Module Impl_core_cmp_Eq_for_halo2_proofs_dev_metadata_Column. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Column". + + (* Eq *) + Definition assert_receiver_is_total_eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Eq" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("assert_receiver_is_total_eq", InstanceField.Method assert_receiver_is_total_eq) ]. + End Impl_core_cmp_Eq_for_halo2_proofs_dev_metadata_Column. + + Module Impl_core_cmp_PartialOrd_for_halo2_proofs_dev_metadata_Column. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Column". + + (* PartialOrd *) + Definition partial_cmp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "halo2_proofs::plonk::circuit::Any", + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + "partial_cmp", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Column", + "column_type" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::Column", + "column_type" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "usize", + [ Ty.path "usize" ], + "partial_cmp", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Column", + "index" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::Column", + "index" + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let cmp := M.copy (| γ |) in + cmp)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialOrd" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("partial_cmp", InstanceField.Method partial_cmp) ]. + End Impl_core_cmp_PartialOrd_for_halo2_proofs_dev_metadata_Column. + + Module Impl_core_cmp_Ord_for_halo2_proofs_dev_metadata_Column. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Column". + + (* Ord *) + Definition cmp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path "halo2_proofs::plonk::circuit::Any", + [], + "cmp", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Column", + "column_type" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::Column", + "column_type" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::cmp::Ord", Ty.path "usize", [], "cmp", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Column", + "index" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::Column", + "index" + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let cmp := M.copy (| γ |) in + cmp)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Ord" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("cmp", InstanceField.Method cmp) ]. + End Impl_core_cmp_Ord_for_halo2_proofs_dev_metadata_Column. + + Module Impl_core_fmt_Display_for_halo2_proofs_dev_metadata_Column. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Column". + + (* + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "Column('{:?}', {})", self.column_type, self.index) + } + *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_fmt", [] |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Arguments", "new_v1", [] |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "Column('" |); + M.read (| Value.String "', " |); + M.read (| Value.String ")" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Column", + "column_type" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Column", + "index" + |) + ] + |) + ] + |)) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Display" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Display_for_halo2_proofs_dev_metadata_Column. + + Module Impl_core_convert_From_Tuple_halo2_proofs_plonk_circuit_Any_usize__for_halo2_proofs_dev_metadata_Column. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Column". + + (* + fn from((column_type, index): (Any, usize)) -> Self { + Column { column_type, index } + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ β0 ] => + ltac:(M.monadic + (let β0 := M.alloc (| β0 |) in + M.match_operator (| + β0, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let column_type := M.copy (| γ0_0 |) in + let index := M.copy (| γ0_1 |) in + Value.StructRecord + "halo2_proofs::dev::metadata::Column" + [ ("column_type", M.read (| column_type |)); ("index", M.read (| index |)) ])) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) + [ (* T *) Ty.tuple [ Ty.path "halo2_proofs::plonk::circuit::Any"; Ty.path "usize" ] ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_Tuple_halo2_proofs_plonk_circuit_Any_usize__for_halo2_proofs_dev_metadata_Column. + + Module Impl_core_convert_From_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Any_for_halo2_proofs_dev_metadata_Column. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Column". + + (* + fn from(column: plonk::Column) -> Self { + Column { + column_type: *column.column_type(), + index: column.index(), + } + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ column ] => + ltac:(M.monadic + (let column := M.alloc (| column |) in + Value.StructRecord + "halo2_proofs::dev::metadata::Column" + [ + ("column_type", + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + "column_type", + [] + |), + [ column ] + |) + |)); + ("index", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + "index", + [] + |), + [ column ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) + [ + (* T *) + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Any_for_halo2_proofs_dev_metadata_Column. + + (* StructRecord + { + name := "VirtualCell"; + ty_params := []; + fields := + [ + ("name", Ty.apply (Ty.path "&") [ Ty.path "str" ]); + ("column", Ty.path "halo2_proofs::dev::metadata::Column"); + ("rotation", Ty.path "i32") + ]; + } *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_dev_metadata_VirtualCell. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::VirtualCell". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "VirtualCell" |); + M.read (| Value.String "name" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::VirtualCell", + "name" + |)); + M.read (| Value.String "column" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::VirtualCell", + "column" + |)); + M.read (| Value.String "rotation" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::VirtualCell", + "rotation" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_dev_metadata_VirtualCell. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_dev_metadata_VirtualCell. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::VirtualCell". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_dev_metadata_VirtualCell. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_dev_metadata_VirtualCell. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::VirtualCell". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + LogicalOp.and (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::VirtualCell", + "name" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::VirtualCell", + "name" + |) + ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::dev::metadata::Column", + [ Ty.path "halo2_proofs::dev::metadata::Column" ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::VirtualCell", + "column" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::VirtualCell", + "column" + |) + ] + |))) + |), + ltac:(M.monadic + (BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::VirtualCell", + "rotation" + |) + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::VirtualCell", + "rotation" + |) + |)))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_dev_metadata_VirtualCell. + + Module Impl_core_marker_StructuralEq_for_halo2_proofs_dev_metadata_VirtualCell. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::VirtualCell". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralEq_for_halo2_proofs_dev_metadata_VirtualCell. + + Module Impl_core_cmp_Eq_for_halo2_proofs_dev_metadata_VirtualCell. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::VirtualCell". + + (* Eq *) + Definition assert_receiver_is_total_eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + Value.DeclaredButUndefined, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) ] + |))) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Eq" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("assert_receiver_is_total_eq", InstanceField.Method assert_receiver_is_total_eq) ]. + End Impl_core_cmp_Eq_for_halo2_proofs_dev_metadata_VirtualCell. + + Module Impl_core_cmp_PartialOrd_for_halo2_proofs_dev_metadata_VirtualCell. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::VirtualCell". + + (* PartialOrd *) + Definition partial_cmp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ], + "partial_cmp", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::VirtualCell", + "name" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::VirtualCell", + "name" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "halo2_proofs::dev::metadata::Column", + [ Ty.path "halo2_proofs::dev::metadata::Column" ], + "partial_cmp", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::VirtualCell", + "column" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::VirtualCell", + "column" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "i32", + [ Ty.path "i32" ], + "partial_cmp", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::VirtualCell", + "rotation" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::VirtualCell", + "rotation" + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let cmp := M.copy (| γ |) in + cmp)) + ] + |))); + fun γ => + ltac:(M.monadic + (let cmp := M.copy (| γ |) in + cmp)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialOrd" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("partial_cmp", InstanceField.Method partial_cmp) ]. + End Impl_core_cmp_PartialOrd_for_halo2_proofs_dev_metadata_VirtualCell. + + Module Impl_core_cmp_Ord_for_halo2_proofs_dev_metadata_VirtualCell. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::VirtualCell". + + (* Ord *) + Definition cmp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [], + "cmp", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::VirtualCell", + "name" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::VirtualCell", + "name" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path "halo2_proofs::dev::metadata::Column", + [], + "cmp", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::VirtualCell", + "column" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::VirtualCell", + "column" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path "i32", + [], + "cmp", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::VirtualCell", + "rotation" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::VirtualCell", + "rotation" + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let cmp := M.copy (| γ |) in + cmp)) + ] + |))); + fun γ => + ltac:(M.monadic + (let cmp := M.copy (| γ |) in + cmp)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Ord" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("cmp", InstanceField.Method cmp) ]. + End Impl_core_cmp_Ord_for_halo2_proofs_dev_metadata_VirtualCell. + + Module Impl_core_convert_From_Tuple_halo2_proofs_dev_metadata_Column_i32__for_halo2_proofs_dev_metadata_VirtualCell. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::VirtualCell". + + (* + fn from((column, rotation): (Column, i32)) -> Self { + VirtualCell { + name: "", + column, + rotation, + } + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ β0 ] => + ltac:(M.monadic + (let β0 := M.alloc (| β0 |) in + M.match_operator (| + β0, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let column := M.copy (| γ0_0 |) in + let rotation := M.copy (| γ0_1 |) in + Value.StructRecord + "halo2_proofs::dev::metadata::VirtualCell" + [ + ("name", M.read (| Value.String "" |)); + ("column", M.read (| column |)); + ("rotation", M.read (| rotation |)) + ])) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) + [ (* T *) Ty.tuple [ Ty.path "halo2_proofs::dev::metadata::Column"; Ty.path "i32" ] ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_Tuple_halo2_proofs_dev_metadata_Column_i32__for_halo2_proofs_dev_metadata_VirtualCell. + + Module Impl_core_convert_From_Tuple_ref__str_halo2_proofs_dev_metadata_Column_i32__for_halo2_proofs_dev_metadata_VirtualCell. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::VirtualCell". + + (* + fn from((name, column, rotation): (&'static str, Column, i32)) -> Self { + VirtualCell { + name, + column, + rotation, + } + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ β0 ] => + ltac:(M.monadic + (let β0 := M.alloc (| β0 |) in + M.match_operator (| + β0, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_2 := M.SubPointer.get_tuple_field (| γ, 2 |) in + let name := M.copy (| γ0_0 |) in + let column := M.copy (| γ0_1 |) in + let rotation := M.copy (| γ0_2 |) in + Value.StructRecord + "halo2_proofs::dev::metadata::VirtualCell" + [ + ("name", M.read (| name |)); + ("column", M.read (| column |)); + ("rotation", M.read (| rotation |)) + ])) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) + [ + (* T *) + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.path "halo2_proofs::dev::metadata::Column"; + Ty.path "i32" + ] + ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_Tuple_ref__str_halo2_proofs_dev_metadata_Column_i32__for_halo2_proofs_dev_metadata_VirtualCell. + + Module Impl_core_convert_From_halo2_proofs_plonk_circuit_VirtualCell_for_halo2_proofs_dev_metadata_VirtualCell. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::VirtualCell". + + (* + fn from(c: plonk::VirtualCell) -> Self { + VirtualCell { + name: "", + column: c.column.into(), + rotation: c.rotation.0, + } + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ c ] => + ltac:(M.monadic + (let c := M.alloc (| c |) in + Value.StructRecord + "halo2_proofs::dev::metadata::VirtualCell" + [ + ("name", M.read (| Value.String "" |)); + ("column", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + [ Ty.path "halo2_proofs::dev::metadata::Column" ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + c, + "halo2_proofs::plonk::circuit::VirtualCell", + "column" + |) + |) + ] + |)); + ("rotation", + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.SubPointer.get_struct_record_field (| + c, + "halo2_proofs::plonk::circuit::VirtualCell", + "rotation" + |), + "halo2_proofs::poly::Rotation", + 0 + |) + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) + [ (* T *) Ty.path "halo2_proofs::plonk::circuit::VirtualCell" ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_halo2_proofs_plonk_circuit_VirtualCell_for_halo2_proofs_dev_metadata_VirtualCell. + + Module Impl_core_fmt_Display_for_halo2_proofs_dev_metadata_VirtualCell. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::VirtualCell". + + (* + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}@{}", self.column, self.rotation)?; + if !self.name.is_empty() { + write!(f, "({})", self.name)?; + } + Ok(()) + } + *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "core::fmt::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "" |); + M.read (| Value.String "@" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "halo2_proofs::dev::metadata::Column" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::VirtualCell", + "column" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "i32" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::VirtualCell", + "rotation" + |) + ] + |) + ] + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "core::fmt::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "core::fmt::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| Ty.path "str", "is_empty", [] |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::VirtualCell", + "name" + |) + |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "core::fmt::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "(" |); + M.read (| Value.String ")" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::VirtualCell", + "name" + |) + ] + |) + ] + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "core::fmt::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "core::fmt::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Display" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Display_for_halo2_proofs_dev_metadata_VirtualCell. + + (* StructRecord + { + name := "Gate"; + ty_params := []; + fields := + [ ("index", Ty.path "usize"); ("name", Ty.apply (Ty.path "&") [ Ty.path "str" ]) ]; + } *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_dev_metadata_Gate. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Gate". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Gate" |); + M.read (| Value.String "index" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Gate", + "index" + |)); + M.read (| Value.String "name" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Gate", + "name" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_dev_metadata_Gate. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_dev_metadata_Gate. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Gate". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_dev_metadata_Gate. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_dev_metadata_Gate. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Gate". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + LogicalOp.and (| + BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Gate", + "index" + |) + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::Gate", + "index" + |) + |)), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Gate", + "name" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::Gate", + "name" + |) + ] + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_dev_metadata_Gate. + + Module Impl_core_fmt_Display_for_halo2_proofs_dev_metadata_Gate. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Gate". + + (* + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "Gate {} ('{}')", self.index, self.name) + } + *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_fmt", [] |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Arguments", "new_v1", [] |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "Gate " |); + M.read (| Value.String " ('" |); + M.read (| Value.String "')" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Gate", + "index" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Gate", + "name" + |) + ] + |) + ] + |)) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Display" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Display_for_halo2_proofs_dev_metadata_Gate. + + Module Impl_core_convert_From_Tuple_usize_ref__str__for_halo2_proofs_dev_metadata_Gate. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Gate". + + (* + fn from((index, name): (usize, &'static str)) -> Self { + Gate { index, name } + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ β0 ] => + ltac:(M.monadic + (let β0 := M.alloc (| β0 |) in + M.match_operator (| + β0, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let index := M.copy (| γ0_0 |) in + let name := M.copy (| γ0_1 |) in + Value.StructRecord + "halo2_proofs::dev::metadata::Gate" + [ ("index", M.read (| index |)); ("name", M.read (| name |)) ])) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) + [ (* T *) Ty.tuple [ Ty.path "usize"; Ty.apply (Ty.path "&") [ Ty.path "str" ] ] ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_Tuple_usize_ref__str__for_halo2_proofs_dev_metadata_Gate. + + (* StructRecord + { + name := "Constraint"; + ty_params := []; + fields := + [ + ("gate", Ty.path "halo2_proofs::dev::metadata::Gate"); + ("index", Ty.path "usize"); + ("name", Ty.apply (Ty.path "&") [ Ty.path "str" ]) + ]; + } *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_dev_metadata_Constraint. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Constraint". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Constraint" |); + M.read (| Value.String "gate" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Constraint", + "gate" + |)); + M.read (| Value.String "index" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Constraint", + "index" + |)); + M.read (| Value.String "name" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Constraint", + "name" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_dev_metadata_Constraint. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_dev_metadata_Constraint. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Constraint". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_dev_metadata_Constraint. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_dev_metadata_Constraint. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Constraint". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + LogicalOp.and (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::dev::metadata::Gate", + [ Ty.path "halo2_proofs::dev::metadata::Gate" ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Constraint", + "gate" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::Constraint", + "gate" + |) + ] + |), + ltac:(M.monadic + (BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Constraint", + "index" + |) + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::Constraint", + "index" + |) + |)))) + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Constraint", + "name" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::Constraint", + "name" + |) + ] + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_dev_metadata_Constraint. + + Module Impl_core_fmt_Display_for_halo2_proofs_dev_metadata_Constraint. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Constraint". + + (* + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "Constraint {}{} in gate {} ('{}')", + self.index, + if self.name.is_empty() { + String::new() + } else { + format!(" ('{}')", self.name) + }, + self.gate.index, + self.gate.name, + ) + } + *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_fmt", [] |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Arguments", "new_v1", [] |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "Constraint " |); + M.read (| Value.String "" |); + M.read (| Value.String " in gate " |); + M.read (| Value.String " ('" |); + M.read (| Value.String "')" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Constraint", + "index" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "alloc::string::String" ] + |), + [ + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "str", + "is_empty", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Constraint", + "name" + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "alloc::string::String", + "new", + [] + |), + [] + |) + |))); + fun γ => + ltac:(M.monadic + (let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String " ('" |); + M.read (| Value.String "')" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Constraint", + "name" + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Constraint", + "gate" + |), + "halo2_proofs::dev::metadata::Gate", + "index" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Constraint", + "gate" + |), + "halo2_proofs::dev::metadata::Gate", + "name" + |) + ] + |) + ] + |)) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Display" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Display_for_halo2_proofs_dev_metadata_Constraint. + + Module Impl_core_convert_From_Tuple_halo2_proofs_dev_metadata_Gate_usize_ref__str__for_halo2_proofs_dev_metadata_Constraint. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Constraint". + + (* + fn from((gate, index, name): (Gate, usize, &'static str)) -> Self { + Constraint { gate, index, name } + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ β0 ] => + ltac:(M.monadic + (let β0 := M.alloc (| β0 |) in + M.match_operator (| + β0, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_2 := M.SubPointer.get_tuple_field (| γ, 2 |) in + let gate := M.copy (| γ0_0 |) in + let index := M.copy (| γ0_1 |) in + let name := M.copy (| γ0_2 |) in + Value.StructRecord + "halo2_proofs::dev::metadata::Constraint" + [ + ("gate", M.read (| gate |)); + ("index", M.read (| index |)); + ("name", M.read (| name |)) + ])) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) + [ + (* T *) + Ty.tuple + [ + Ty.path "halo2_proofs::dev::metadata::Gate"; + Ty.path "usize"; + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_Tuple_halo2_proofs_dev_metadata_Gate_usize_ref__str__for_halo2_proofs_dev_metadata_Constraint. + + (* StructRecord + { + name := "Region"; + ty_params := []; + fields := [ ("index", Ty.path "usize"); ("name", Ty.path "alloc::string::String") ]; + } *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_dev_metadata_Region. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Region". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Region" |); + M.read (| Value.String "index" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Region", + "index" + |)); + M.read (| Value.String "name" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Region", + "name" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_dev_metadata_Region. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_dev_metadata_Region. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Region". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_dev_metadata_Region. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_dev_metadata_Region. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Region". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + LogicalOp.and (| + BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Region", + "index" + |) + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::Region", + "index" + |) + |)), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "alloc::string::String", + [ Ty.path "alloc::string::String" ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Region", + "name" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::dev::metadata::Region", + "name" + |) + ] + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_dev_metadata_Region. + + Module Impl_core_fmt_Display_for_halo2_proofs_dev_metadata_Region. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Region". + + (* + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "Region {} ('{}')", self.index, self.name) + } + *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_fmt", [] |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Arguments", "new_v1", [] |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "Region " |); + M.read (| Value.String " ('" |); + M.read (| Value.String "')" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Region", + "index" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "alloc::string::String" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::dev::metadata::Region", + "name" + |) + ] + |) + ] + |)) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Display" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Display_for_halo2_proofs_dev_metadata_Region. + + Module Impl_core_convert_From_Tuple_usize_alloc_string_String__for_halo2_proofs_dev_metadata_Region. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Region". + + (* + fn from((index, name): (usize, String)) -> Self { + Region { index, name } + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ β0 ] => + ltac:(M.monadic + (let β0 := M.alloc (| β0 |) in + M.match_operator (| + β0, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let index := M.copy (| γ0_0 |) in + let name := M.copy (| γ0_1 |) in + Value.StructRecord + "halo2_proofs::dev::metadata::Region" + [ ("index", M.read (| index |)); ("name", M.read (| name |)) ])) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) + [ (* T *) Ty.tuple [ Ty.path "usize"; Ty.path "alloc::string::String" ] ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_Tuple_usize_alloc_string_String__for_halo2_proofs_dev_metadata_Region. + + Module Impl_core_convert_From_Tuple_usize_ref__str__for_halo2_proofs_dev_metadata_Region. + Definition Self : Ty.t := Ty.path "halo2_proofs::dev::metadata::Region". + + (* + fn from((index, name): (usize, &str)) -> Self { + Region { + index, + name: name.to_owned(), + } + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ β0 ] => + ltac:(M.monadic + (let β0 := M.alloc (| β0 |) in + M.match_operator (| + β0, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let index := M.copy (| γ0_0 |) in + let name := M.copy (| γ0_1 |) in + Value.StructRecord + "halo2_proofs::dev::metadata::Region" + [ + ("index", M.read (| index |)); + ("name", + M.call_closure (| + M.get_trait_method (| + "alloc::borrow::ToOwned", + Ty.path "str", + [], + "to_owned", + [] + |), + [ M.read (| name |) ] + |)) + ])) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) + [ (* T *) Ty.tuple [ Ty.path "usize"; Ty.apply (Ty.path "&") [ Ty.path "str" ] ] ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_Tuple_usize_ref__str__for_halo2_proofs_dev_metadata_Region. + End metadata. +End dev. diff --git a/CoqOfRust/halo2_proofs/dev/util.v b/CoqOfRust/halo2_proofs/dev/util.v new file mode 100644 index 000000000..71e334a31 --- /dev/null +++ b/CoqOfRust/halo2_proofs/dev/util.v @@ -0,0 +1,1275 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module dev. + Module util. + (* + pub(super) fn format_value(v: F) -> String { + if v.is_zero_vartime() { + "0".into() + } else if v == F::one() { + "1".into() + } else if v == -F::one() { + "-1".into() + } else { + // Format value as hex. + let s = format!("{:?}", v); + // Remove leading zeroes. + let s = s.strip_prefix("0x").unwrap(); + let s = s.trim_start_matches('0'); + format!("0x{}", s) + } + } + *) + Definition format_value (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ v ] => + ltac:(M.monadic + (let v := M.alloc (| v |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "is_zero_vartime", [] |), + [ v ] + |) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [ Ty.path "alloc::string::String" ], + "into", + [] + |), + [ M.read (| Value.String "0" |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + F, + [ F ], + "eq", + [] + |), + [ + v; + M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "one", [] |), + [] + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [ Ty.path "alloc::string::String" ], + "into", + [] + |), + [ M.read (| Value.String "1" |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + F, + [ F ], + "eq", + [] + |), + [ + v; + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Neg", + F, + [], + "neg", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [ Ty.path "alloc::string::String" ], + "into", + [] + |), + [ M.read (| Value.String "-1" |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let s := + M.copy (| + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array [ M.read (| Value.String "" |) ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ F ] + |), + [ v ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) in + let s := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "str", + "strip_prefix", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "alloc::string::String", + [], + "deref", + [] + |), + [ s ] + |); + M.read (| Value.String "0x" |) + ] + |) + ] + |) + |) in + let s := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "str", + "trim_start_matches", + [ Ty.path "char" ] + |), + [ M.read (| s |); Value.UnicodeChar 48 ] + |) + |) in + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array [ M.read (| Value.String "0x" |) ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ s ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)) + ] + |))) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + fn cell_value<'a, F: FieldExt>( + virtual_cells: &'a [VirtualCell], + column_type: Any, + load: impl Fn(usize, usize, Rotation) -> Value + 'a, + ) -> impl Fn(usize, usize, Rotation) -> BTreeMap + 'a { + move |query_index, column_index, rotation| { + virtual_cells + .iter() + .find(|c| { + c.column.column_type() == &column_type + && c.column.index() == column_index + && c.rotation == rotation + }) + // None indicates a selector, which we don't bother showing. + .map(|cell| { + ( + cell.clone().into(), + match load(query_index, column_index, rotation) { + Value::Real(v) => format_value(v), + Value::Poison => unreachable!(), + }, + ) + }) + .into_iter() + .collect() + } + } + *) + Definition cell_value (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F; impl_Fn_usize__usize__Rotation__arrow_Value_F___plus__'a ], + [ virtual_cells; column_type; load ] => + ltac:(M.monadic + (let virtual_cells := M.alloc (| virtual_cells |) in + let column_type := M.alloc (| column_type |) in + let load := M.alloc (| load |) in + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let query_index := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let column_index := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α2 |), + [ + fun γ => + ltac:(M.monadic + (let rotation := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String" + ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ], + "map", + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + (Ty.tuple + [ + Ty.path + "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ], + [], + "find", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ] + ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell" + ], + "iter", + [] + |), + [ M.read (| virtual_cells |) ] + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let c := + M.copy (| γ |) in + LogicalOp.and (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "eq", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "column_type", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + M.read (| + c + |) + |), + "halo2_proofs::plonk::circuit::VirtualCell", + "column" + |) + ] + |) + |); + M.alloc (| + column_type + |) + ] + |), + ltac:(M.monadic + (BinOp.Pure.eq + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + M.read (| + c + |) + |), + "halo2_proofs::plonk::circuit::VirtualCell", + "column" + |) + ] + |)) + (M.read (| + column_index + |)))) + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "halo2_proofs::poly::Rotation", + [ + Ty.path + "halo2_proofs::poly::Rotation" + ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + M.read (| c |) + |), + "halo2_proofs::plonk::circuit::VirtualCell", + "rotation" + |); + rotation + ] + |))) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let cell := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell", + [ + Ty.path + "halo2_proofs::dev::metadata::VirtualCell" + ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell", + [], + "clone", + [] + |), + [ M.read (| cell |) + ] + |) + ] + |); + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn_usize__usize__Rotation__arrow_Value_F___plus__'a, + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + "call", + [] + |), + [ + load; + Value.Tuple + [ + M.read (| + query_index + |); + M.read (| + column_index + |); + M.read (| + rotation + |) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::dev::Value::Real", + 0 + |) in + let v := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::dev::util::format_value", + [ F ] + |), + [ + M.read (| + v + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic", + [] + |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |))) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)))) + | _, _ => M.impossible + end. + + Module cell_value. + (* Error OpaqueTy *) + End cell_value. + + (* + pub(super) fn cell_values<'a, F: FieldExt>( + gate: &Gate, + poly: &Expression, + load_fixed: impl Fn(usize, usize, Rotation) -> Value + 'a, + load_advice: impl Fn(usize, usize, Rotation) -> Value + 'a, + load_instance: impl Fn(usize, usize, Rotation) -> Value + 'a, + ) -> Vec<(metadata::VirtualCell, String)> { + let virtual_cells = gate.queried_cells(); + let cell_values = poly.evaluate( + &|_| BTreeMap::default(), + &|_| panic!("virtual selectors are removed during optimization"), + &cell_value(virtual_cells, Any::Fixed, load_fixed), + &cell_value(virtual_cells, Any::Advice, load_advice), + &cell_value(virtual_cells, Any::Instance, load_instance), + &|a| a, + &|mut a, mut b| { + a.append(&mut b); + a + }, + &|a, b| { + let mut a = a(); + let mut b = b(); + a.append(&mut b); + a + }, + &|a, _| a, + ); + cell_values.into_iter().collect() + } + *) + Definition cell_values (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ + F; + impl_Fn_usize__usize__Rotation__arrow_Value_F___plus__'a; + impl_Fn_usize__usize__Rotation__arrow_Value_F___plus__'a'1; + impl_Fn_usize__usize__Rotation__arrow_Value_F___plus__'a'2 + ], + [ gate; poly; load_fixed; load_advice; load_instance ] => + ltac:(M.monadic + (let gate := M.alloc (| gate |) in + let poly := M.alloc (| poly |) in + let load_fixed := M.alloc (| load_fixed |) in + let load_advice := M.alloc (| load_advice |) in + let load_instance := M.alloc (| load_instance |) in + M.read (| + let virtual_cells := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ], + "queried_cells", + [] + |), + [ M.read (| gate |) ] + |) + |) in + let cell_values := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "evaluate", + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String"; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ Ty.tuple [ F ] ] + (Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String"; + Ty.path "alloc::alloc::Global" + ]); + Ty.function + [ Ty.tuple [ Ty.path "halo2_proofs::plonk::circuit::Selector" ] ] + (Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String"; + Ty.path "alloc::alloc::Global" + ]); + Ty.associated; + Ty.associated; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String"; + Ty.path "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String"; + Ty.path "alloc::alloc::Global" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String"; + Ty.path "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String"; + Ty.path "alloc::alloc::Global" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.dyn [ ("core::ops::function::Fn::Trait", []) ] ]; + Ty.apply + (Ty.path "&") + [ Ty.dyn [ ("core::ops::function::Fn::Trait", []) ] ] + ] + ] + (Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String"; + Ty.path "alloc::alloc::Global" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String"; + Ty.path "alloc::alloc::Global" + ]; + F + ] + ] + (Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String"; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| poly |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String"; + Ty.path "alloc::alloc::Global" + ], + [], + "default", + [] + |), + [] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.never_to_any (| + M.call_closure (| + M.get_function (| + "std::panicking::begin_panic", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + M.read (| + Value.String + "virtual selectors are removed during optimization" + |) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::dev::util::cell_value", + [ F; impl_Fn_usize__usize__Rotation__arrow_Value_F___plus__'a ] + |), + [ + M.read (| virtual_cells |); + Value.StructTuple "halo2_proofs::plonk::circuit::Any::Fixed" []; + M.read (| load_fixed |) + ] + |) + |); + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::dev::util::cell_value", + [ F; impl_Fn_usize__usize__Rotation__arrow_Value_F___plus__'a'1 ] + |), + [ + M.read (| virtual_cells |); + Value.StructTuple "halo2_proofs::plonk::circuit::Any::Advice" []; + M.read (| load_advice |) + ] + |) + |); + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::dev::util::cell_value", + [ F; impl_Fn_usize__usize__Rotation__arrow_Value_F___plus__'a'2 ] + |), + [ + M.read (| virtual_cells |); + Value.StructTuple "halo2_proofs::plonk::circuit::Any::Instance" []; + M.read (| load_instance |) + ] + |) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.read (| a |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let b := M.copy (| γ |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String"; + Ty.path "alloc::alloc::Global" + ], + "append", + [] + |), + [ a; b ] + |) + |) in + a + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let b := M.copy (| γ |) in + M.read (| + let a := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ ("core::ops::function::Fn::Trait", []) + ], + [ Ty.tuple [] ], + "call", + [] + |), + [ M.read (| a |); Value.Tuple [] ] + |) + |) in + let b := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ ("core::ops::function::Fn::Trait", []) + ], + [ Ty.tuple [] ], + "call", + [] + |), + [ M.read (| b |); Value.Tuple [] ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String"; + Ty.path "alloc::alloc::Global" + ], + "append", + [] + |), + [ a; b ] + |) + |) in + a + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ fun γ => ltac:(M.monadic (M.read (| a |))) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::IntoIter") + [ + Ty.path "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String"; + Ty.path "alloc::alloc::Global" + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::dev::metadata::VirtualCell"; + Ty.path "alloc::string::String"; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| cell_values |) ] + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + End util. +End dev. diff --git a/CoqOfRust/halo2_proofs/helpers.v b/CoqOfRust/halo2_proofs/helpers.v new file mode 100644 index 000000000..4ec32fead --- /dev/null +++ b/CoqOfRust/halo2_proofs/helpers.v @@ -0,0 +1,22659 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module helpers. + (* Trait *) + Module CurveRead. + Definition read (Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ R ], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let compressed := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.associated, + [], + "default", + [] + |), + [] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Read", R, [], "read_exact", [] |), + [ + M.read (| reader |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsMut", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_mut", + [] + |), + [ compressed ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Self; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Self ], + "ok_or_else", + [ + Ty.path "std::io::error::Error"; + Ty.function [ Ty.tuple [] ] (Ty.path "std::io::error::Error") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.apply (Ty.path "core::option::Option") [ Self ], + [ Ty.apply (Ty.path "subtle::CtOption") [ Self ] ], + "from", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "group::GroupEncoding", + Self, + [], + "from_bytes", + [] + |), + [ compressed ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.path "std::io::error::Error", + "new", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + Value.StructTuple "std::io::error::ErrorKind::Other" []; + M.read (| + Value.String "invalid point encoding in proof" + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_read : M.IsProvidedMethod "halo2_proofs::helpers::CurveRead" "read" read. + End CurveRead. + + Module Impl_halo2_proofs_helpers_CurveRead_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_C. + Definition Self (C : Ty.t) : Ty.t := C. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "halo2_proofs::helpers::CurveRead" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_halo2_proofs_helpers_CurveRead_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_C. + + (* Trait *) + (* Empty module 'Serializable' *) + + (* Trait *) + (* Empty module 'ParaSerializable' *) + + (* + pub(crate) fn read_u32(reader: &mut R) -> io::Result { + let mut r = [0u8; 4]; + reader.read(&mut r)?; + Ok(u32::from_le_bytes(r)) + } + *) + Definition read_u32 (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ R ], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let r := M.alloc (| repeat (Value.Integer 0) 4 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Read", R, [], "read", [] |), + [ M.read (| reader |); (* Unsize *) M.pointer_coercion r ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "from_le_bytes", [] |), + [ M.read (| r |) ] + |) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Module Impl_halo2_proofs_helpers_Serializable_for_u32. + Definition Self : Ty.t := Ty.path "u32". + + (* + fn fetch(reader: &mut R) -> io::Result { + let u = read_u32(reader)?; + Ok(u) + } + *) + Definition fetch (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ R ], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let u := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| u |) ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn store(&self, writer: &mut W) -> io::Result<()> { + writer.write(&mut ( *self).to_le_bytes())?; + Ok(()) + } + *) + Definition store (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ W ], [ self; writer ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ M.read (| M.read (| self |) |) ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "halo2_proofs::helpers::Serializable" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("fetch", InstanceField.Method fetch); ("store", InstanceField.Method store) ]. + End Impl_halo2_proofs_helpers_Serializable_for_u32. + + Module Impl_halo2_proofs_helpers_Serializable_for_alloc_string_String. + Definition Self : Ty.t := Ty.path "alloc::string::String". + + (* + fn fetch(reader: &mut R) -> io::Result { + let len = read_u32(reader)?; + let mut s = vec![0; len as usize]; + reader.read_exact(&mut s)?; + let u = String::from_utf8(s.to_vec()).unwrap(); + Ok(u) + } + *) + Definition fetch (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ R ], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let len := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "alloc::string::String"; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let s := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ Ty.path "u8" ] |), + [ Value.Integer 0; M.rust_cast (M.read (| len |)) ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Read", R, [], "read_exact", [] |), + [ + M.read (| reader |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ s ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "alloc::string::String"; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let u := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "alloc::string::String"; Ty.path "alloc::string::FromUtf8Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "alloc::string::String", + "from_utf8", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u8" ], + "to_vec", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ s ] + |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| u |) ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn store(&self, writer: &mut W) -> io::Result<()> { + let bytes = self.as_bytes(); + writer.write(&mut (bytes.len() as u32).to_le_bytes())?; + writer.write(bytes)?; + Ok(()) + } + *) + Definition store (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ W ], [ self; writer ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let bytes := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "alloc::string::String", + "as_bytes", + [] + |), + [ M.read (| self |) ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u8" ], + "len", + [] + |), + [ M.read (| bytes |) ] + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ M.read (| writer |); M.read (| bytes |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "halo2_proofs::helpers::Serializable" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("fetch", InstanceField.Method fetch); ("store", InstanceField.Method store) ]. + End Impl_halo2_proofs_helpers_Serializable_for_alloc_string_String. + + Module Impl_halo2_proofs_helpers_Serializable_for_Tuple_alloc_string_String_u32_. + Definition Self : Ty.t := Ty.tuple [ Ty.path "alloc::string::String"; Ty.path "u32" ]. + + (* + fn fetch(reader: &mut R) -> io::Result { + Ok((String::fetch(reader)?, u32::fetch(reader)?)) + } + *) + Definition fetch (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ R ], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + Value.Tuple + [ + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "alloc::string::String"; Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.path "alloc::string::String", + [], + "fetch", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ Ty.path "alloc::string::String"; Ty.path "u32" + ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |); + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.path "u32", + [], + "fetch", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ Ty.path "alloc::string::String"; Ty.path "u32" + ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) + ] + ])) + |))) + | _, _ => M.impossible + end. + + (* + fn store(&self, writer: &mut W) -> io::Result<()> { + self.0.store(writer)?; + self.1.store(writer)?; + Ok(()) + } + *) + Definition store (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ W ], [ self; writer ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.path "alloc::string::String", + [], + "store", + [ W ] + |), + [ + M.SubPointer.get_tuple_field (| M.read (| self |), 0 |); + M.read (| writer |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.path "u32", + [], + "store", + [ W ] + |), + [ + M.SubPointer.get_tuple_field (| M.read (| self |), 1 |); + M.read (| writer |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "halo2_proofs::helpers::Serializable" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("fetch", InstanceField.Method fetch); ("store", InstanceField.Method store) ]. + End Impl_halo2_proofs_helpers_Serializable_for_Tuple_alloc_string_String_u32_. + + Module Impl_halo2_proofs_helpers_ParaSerializable_for_alloc_vec_Vec_alloc_vec_Vec_Tuple_u32_u32__alloc_alloc_Global_alloc_alloc_Global. + Definition Self : Ty.t := + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]. + + (* + fn vec_fetch(fd: &mut File) -> io::Result { + let columns = read_u32(fd)?; + let mut offset = 0; + let mut offsets = vec![]; + for _ in 0..columns { + let l = read_u32(fd)?; + offsets.push((offset, l)); + offset = offset + l; + } + let position = fd.stream_position()?; + let res: Vec> = (0..columns) + .into_par_iter() + .map(|i| { + let mmap = unsafe { + MmapOptions::new() + .offset(position + (offsets[i as usize].0 as u64 * 8)) + .len(offsets[i as usize].1 as usize * 8) + .map(&fd) + .unwrap() + }; + let s: &[(u32, u32)] = unsafe { + std::slice::from_raw_parts( + mmap.as_ptr() as *const (u32, u32), + offsets[i as usize].1 as usize, + ) + }; + let mut s2 = vec![]; + s2.extend_from_slice(s); + s2 + }) + .collect(); + Ok(res) + } + *) + Definition vec_fetch (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ fd ] => + ltac:(M.monadic + (let fd := M.alloc (| fd |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let columns := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_u32", + [ Ty.path "std::fs::File" ] + |), + [ M.read (| fd |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let offset := M.alloc (| Value.Integer 0 |) in + let offsets := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| columns |)) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let l := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "u32"; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_u32", + [ Ty.path "std::fs::File" ] + |), + [ M.read (| fd |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + offsets; + Value.Tuple + [ M.read (| offset |); M.read (| l |) ] + ] + |) + |) in + let _ := + M.write (| + offset, + BinOp.Panic.add (| + Integer.U32, + M.read (| offset |), + M.read (| l |) + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let position := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u64"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "std::io::Seek", + Ty.path "std::fs::File", + [], + "stream_position", + [] + |), + [ M.read (| fd |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let res := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::map::Map") + [ + Ty.apply (Ty.path "rayon::range::Iter") [ Ty.path "u32" ]; + Ty.function + [ Ty.tuple [ Ty.path "u32" ] ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply (Ty.path "rayon::range::Iter") [ Ty.path "u32" ], + [], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "u32" ] ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "u32" ], + [], + "into_par_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| columns |)) ] + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let i := M.copy (| γ |) in + M.read (| + let mmap := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "memmap::Mmap"; + Ty.path "std::io::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "memmap::MmapOptions", + "map", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "memmap::MmapOptions", + "len", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "memmap::MmapOptions", + "offset", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "memmap::MmapOptions", + "new", + [] + |), + [] + |) + |); + BinOp.Panic.add (| + Integer.U64, + M.read (| position |), + BinOp.Panic.mul (| + Integer.U64, + M.rust_cast + (M.read (| + M.SubPointer.get_tuple_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path + "u32"; + Ty.path + "u32" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + offsets; + M.rust_cast + (M.read (| i |)) + ] + |), + 0 + |) + |)), + Value.Integer 8 + |) + |) + ] + |); + BinOp.Panic.mul (| + Integer.Usize, + M.rust_cast + (M.read (| + M.SubPointer.get_tuple_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + offsets; + M.rust_cast + (M.read (| i |)) + ] + |), + 1 + |) + |)), + Value.Integer 8 + |) + ] + |); + M.read (| fd |) + ] + |) + ] + |) + |) in + let s := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::slice::raw::from_raw_parts", + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] ] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "u8" ], + "as_ptr", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "memmap::Mmap", + [], + "deref", + [] + |), + [ mmap ] + |) + ] + |)); + M.rust_cast + (M.read (| + M.SubPointer.get_tuple_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" + ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + offsets; + M.rust_cast (M.read (| i |)) + ] + |), + 1 + |) + |)) + ] + |) + |) in + let s2 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + "extend_from_slice", + [] + |), + [ s2; M.read (| s |) ] + |) + |) in + s2 + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| res |) ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn vec_store(&self, fd: &mut File) -> io::Result<()> { + let u = self.len() as u32; + u.store(fd)?; + let mut offset = 0; + let mut offsets = vec![]; + for i in 0..u { + let l = self[i as usize].len(); + offsets.push((offset, l)); + offset = offset + l; + (l as u32).store(fd)?; + } + let position = fd.stream_position()?; + fd.set_len(position + (offset as u64 * 8)).unwrap(); + self.into_par_iter().enumerate().for_each(|(i, s2)| { + let mut mmap = unsafe { + MmapOptions::new() + .offset(position + (offsets[i as usize].0 as u64 * 8)) + .len(offsets[i as usize].1 as usize * 8) + .map_mut(&fd) + .unwrap() + }; + let s: &[u8] = unsafe { + std::slice::from_raw_parts( + s2.as_ptr() as *const u8, + offsets[i as usize].1 as usize * 8, + ) + }; + (&mut mmap).copy_from_slice(s); + }); + Ok(()) + } + *) + Definition vec_store (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; fd ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let fd := M.alloc (| fd |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let u := + M.alloc (| + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| self |) ] + |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.path "u32", + [], + "store", + [ Ty.path "std::fs::File" ] + |), + [ u; M.read (| fd |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let offset := M.alloc (| Value.Integer 0 |) in + let offsets := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "usize"; Ty.path "usize" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| u |)) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let l := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| self |); + M.rust_cast (M.read (| i |)) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "usize"; Ty.path "usize" ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + offsets; + Value.Tuple + [ M.read (| offset |); M.read (| l |) ] + ] + |) + |) in + let _ := + M.write (| + offset, + BinOp.Panic.add (| + Integer.Usize, + M.read (| offset |), + M.read (| l |) + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.path "u32", + [], + "store", + [ Ty.path "std::fs::File" ] + |), + [ + M.alloc (| M.rust_cast (M.read (| l |)) |); + M.read (| fd |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let position := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u64"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "std::io::Seek", + Ty.path "std::fs::File", + [], + "stream_position", + [] + |), + [ M.read (| fd |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| Ty.path "std::fs::File", "set_len", [] |), + [ + M.read (| fd |); + BinOp.Panic.add (| + Integer.U64, + M.read (| position |), + BinOp.Panic.mul (| + Integer.U64, + M.rust_cast (M.read (| offset |)), + Value.Integer 8 + |) + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IndexedParallelIterator", + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_par_iter", + [] + |), + [ M.read (| self |) ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let i := M.copy (| γ0_0 |) in + let s2 := M.copy (| γ0_1 |) in + M.read (| + let mmap := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "memmap::MmapMut"; + Ty.path "std::io::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "memmap::MmapOptions", + "map_mut", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "memmap::MmapOptions", + "len", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "memmap::MmapOptions", + "offset", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "memmap::MmapOptions", + "new", + [] + |), + [] + |) + |); + BinOp.Panic.add (| + Integer.U64, + M.read (| position |), + BinOp.Panic.mul (| + Integer.U64, + M.rust_cast + (M.read (| + M.SubPointer.get_tuple_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + offsets; + M.read (| M.use i |) + ] + |), + 0 + |) + |)), + Value.Integer 8 + |) + |) + ] + |); + BinOp.Panic.mul (| + Integer.Usize, + M.read (| + M.use + (M.SubPointer.get_tuple_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ offsets; M.read (| M.use i |) + ] + |), + 1 + |)) + |), + Value.Integer 8 + |) + ] + |); + M.read (| fd |) + ] + |) + ] + |) + |) in + let s := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::slice::raw::from_raw_parts", + [ Ty.path "u8" ] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + "as_ptr", + [] + |), + [ M.read (| s2 |) ] + |)); + BinOp.Panic.mul (| + Integer.Usize, + M.read (| + M.use + (M.SubPointer.get_tuple_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize" + ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ offsets; M.read (| M.use i |) ] + |), + 1 + |)) + |), + Value.Integer 8 + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u8" ], + "copy_from_slice", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.path "memmap::MmapMut", + [], + "deref_mut", + [] + |), + [ mmap ] + |); + M.read (| s |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "halo2_proofs::helpers::ParaSerializable" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ + ("vec_fetch", InstanceField.Method vec_fetch); + ("vec_store", InstanceField.Method vec_store) + ]. + End Impl_halo2_proofs_helpers_ParaSerializable_for_alloc_vec_Vec_alloc_vec_Vec_Tuple_u32_u32__alloc_alloc_Global_alloc_alloc_Global. + + Module Impl_halo2_proofs_helpers_Serializable_where_core_clone_Clone_B_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_halo2_proofs_poly_Polynomial_F_B. + Definition Self (B F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ]. + + (* + fn fetch(reader: &mut R) -> io::Result { + let u = read_u32(reader)?; + let mut buf = vec![0u8; u as usize * 32]; + reader.read_exact(&mut buf)?; + let s: &[F] = unsafe { std::slice::from_raw_parts(buf.as_ptr() as *const F, u as usize) }; + Ok(Polynomial::new(s.to_vec())) + } + *) + Definition fetch (B F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self B F in + match τ, α with + | [ R ], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let u := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ F; B ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let buf := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ Ty.path "u8" ] |), + [ + Value.Integer 0; + BinOp.Panic.mul (| + Integer.Usize, + M.rust_cast (M.read (| u |)), + Value.Integer 32 + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Read", R, [], "read_exact", [] |), + [ + M.read (| reader |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ buf ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ F; B ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let s := + M.alloc (| + M.call_closure (| + M.get_function (| "core::slice::raw::from_raw_parts", [ F ] |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ], + "as_ptr", + [] + |), + [ buf ] + |)); + M.rust_cast (M.read (| u |)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "to_vec", + [] + |), + [ M.read (| s |) ] + |) + ] + |) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn store(&self, writer: &mut W) -> io::Result<()> { + let u = self.values.len() as u32; + u.store(writer)?; + let s: &[u8] = unsafe { + std::slice::from_raw_parts(self.values.as_ptr() as *const u8, u as usize * 32) + }; + writer.write(s)?; + Ok(()) + } + *) + Definition store (B F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self B F in + match τ, α with + | [ W ], [ self; writer ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let u := + M.alloc (| + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.path "u32", + [], + "store", + [ W ] + |), + [ u; M.read (| writer |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let s := + M.alloc (| + M.call_closure (| + M.get_function (| "core::slice::raw::from_raw_parts", [ Ty.path "u8" ] |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + "as_ptr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |)); + BinOp.Panic.mul (| + Integer.Usize, + M.rust_cast (M.read (| u |)), + Value.Integer 32 + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ M.read (| writer |); M.read (| s |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (B F : Ty.t), + M.IsTraitInstance + "halo2_proofs::helpers::Serializable" + (Self B F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("fetch", InstanceField.Method (fetch B F)); ("store", InstanceField.Method (store B F)) + ]. + End Impl_halo2_proofs_helpers_Serializable_where_core_clone_Clone_B_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_halo2_proofs_poly_Polynomial_F_B. + + Module Impl_halo2_proofs_helpers_Serializable_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_plonk_VerifyingKey_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::VerifyingKey") [ C ]. + + (* + fn store(&self, writer: &mut W) -> io::Result<()> { + let j = (self.domain.get_quotient_poly_degree() + 1) as u32; // quotient_poly_degree is j-1 + let k = self.domain.k() as u32; + writer.write(&mut j.to_le_bytes())?; + writer.write(&mut k.to_le_bytes())?; + write_cs::(&self.cs, writer)?; + + self.write(writer)?; + + Ok(()) + } + *) + Definition store (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ W ], [ self; writer ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let j := + M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "get_quotient_poly_degree", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |), + Value.Integer 1 + |)) + |) in + let k := + M.copy (| + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "k", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |) + |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ M.read (| j |) ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ M.read (| k |) ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::write_cs", [ C; W ] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |); + M.read (| writer |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::VerifyingKey") [ C ], + "write", + [ W ] + |), + [ M.read (| self |); M.read (| writer |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn fetch(reader: &mut R) -> io::Result> { + let j = read_u32(reader)?; + let k = read_u32(reader)?; + let domain: EvaluationDomain = EvaluationDomain::new(j, k); + let cs = read_cs::(reader)?; + + let fixed_commitments: Vec<_> = (0..cs.num_fixed_columns) + .map(|_| C::read(reader)) + .collect::>()?; + + let permutation = permutation::VerifyingKey::read(reader, &cs.permutation)?; + + Ok(VerifyingKey { + domain, + cs, + fixed_commitments, + permutation, + }) + } + *) + Definition fetch (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ R ], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let j := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::VerifyingKey") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let k := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::VerifyingKey") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let domain := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "new", + [] + |), + [ M.read (| j |); M.read (| k |) ] + |) + |) in + let cs := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_cs", [ C; R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::VerifyingKey") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let fixed_commitments := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ]) + ] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.read (| + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_fixed_columns" + |) + |)) + ]; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::CurveRead", + C, + [], + "read", + [ R ] + |), + [ M.read (| reader |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::VerifyingKey") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let permutation := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::permutation::VerifyingKey") + [ C ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::permutation::VerifyingKey") + [ C ], + "read", + [ R ] + |), + [ + M.read (| reader |); + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::VerifyingKey") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::VerifyingKey" + [ + ("domain", M.read (| domain |)); + ("cs", M.read (| cs |)); + ("fixed_commitments", M.read (| fixed_commitments |)); + ("permutation", M.read (| permutation |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "halo2_proofs::helpers::Serializable" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("store", InstanceField.Method (store C)); ("fetch", InstanceField.Method (fetch C)) ]. + End Impl_halo2_proofs_helpers_Serializable_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_plonk_VerifyingKey_C. + + Module Impl_halo2_proofs_helpers_Serializable_where_halo2_proofs_helpers_Serializable_T_for_alloc_vec_Vec_T_alloc_alloc_Global. + Definition Self (T : Ty.t) : Ty.t := + Ty.apply (Ty.path "alloc::vec::Vec") [ T; Ty.path "alloc::alloc::Global" ]. + + (* + fn store(&self, writer: &mut W) -> io::Result<()> { + writer.write(&mut (self.len() as u32).to_le_bytes())?; + for c in self.iter() { + c.store(writer)?; + } + Ok(()) + } + *) + Definition store (T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self T in + match τ, α with + | [ W ], [ self; writer ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ T; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ M.read (| self |) ] + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ T ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ T ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ T; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ T ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let c := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + T, + [], + "store", + [ W ] + |), + [ M.read (| c |); M.read (| writer |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn fetch(reader: &mut R) -> io::Result> { + let len = read_u32(reader)?; + let mut v = vec![]; + for _ in 0..len { + v.push(T::fetch(reader)?); + } + Ok(v) + } + *) + Definition fetch (T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self T in + match τ, α with + | [ R ], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let len := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ T; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let v := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "alloc::vec::Vec") [ T; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| len |)) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ T; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + v; + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ T; Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + T, + [], + "fetch", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + T; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| v |) ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (T : Ty.t), + M.IsTraitInstance + "halo2_proofs::helpers::Serializable" + (Self T) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("store", InstanceField.Method (store T)); ("fetch", InstanceField.Method (fetch T)) ]. + End Impl_halo2_proofs_helpers_Serializable_where_halo2_proofs_helpers_Serializable_T_for_alloc_vec_Vec_T_alloc_alloc_Global. + + Module Impl_halo2_proofs_helpers_Serializable_for_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Any. + Definition Self : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]. + + (* + fn store(&self, writer: &mut W) -> std::io::Result<()> { + writer.write(&mut (self.index as u32).to_le_bytes())?; + writer.write(&mut ( *self.column_type() as u32).to_le_bytes())?; + Ok(()) + } + *) + Definition store (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ W ], [ self; writer ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Column", + "index" + |) + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ + M.rust_cast + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + "column_type", + [] + |), + [ M.read (| self |) ] + |) + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn fetch(reader: &mut R) -> std::io::Result { + let index = read_u32(reader)?; + let typ = read_u32(reader)?; + let typ = if typ == Any::Advice as u32 { + Any::Advice + } else if typ == Any::Instance as u32 { + Any::Instance + } else if typ == Any::Fixed as u32 { + Any::Fixed + } else { + unreachable!() + }; + Ok(Column { + index: index as usize, + column_type: typ, + }) + } + *) + Definition fetch (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ R ], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let index := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let typ := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let typ := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq (M.read (| typ |)) (M.rust_cast (Value.Integer 0)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + Value.StructTuple "halo2_proofs::plonk::circuit::Any::Advice" [] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| typ |)) + (M.rust_cast (Value.Integer 2)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::circuit::Any::Instance" + [] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| typ |)) + (M.rust_cast (Value.Integer 1)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::circuit::Any::Fixed" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))) + ] + |))) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::circuit::Column" + [ + ("index", M.rust_cast (M.read (| index |))); + ("column_type", M.read (| typ |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "halo2_proofs::helpers::Serializable" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("store", InstanceField.Method store); ("fetch", InstanceField.Method fetch) ]. + End Impl_halo2_proofs_helpers_Serializable_for_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Any. + + (* + fn write_arguments( + columns: &Vec>, + writer: &mut W, + ) -> std::io::Result<()> { + writer.write(&mut (columns.len() as u32).to_le_bytes())?; + for c in columns.iter() { + c.store(writer)? + } + Ok(()) + } + *) + Definition write_arguments (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ W ], [ columns; writer ] => + ltac:(M.monadic + (let columns := M.alloc (| columns |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "to_le_bytes", [] |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| columns |) ] + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| columns |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let c := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ], + [], + "store", + [ W ] + |), + [ M.read (| c |); M.read (| writer |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn read_arguments( + reader: &mut R, + ) -> std::io::Result { + let len = read_u32(reader)?; + let mut cols = vec![]; + for _ in 0..len { + cols.push(Column::::fetch(reader)?); + } + Ok(plonk::permutation::Argument { columns: cols }) + } + *) + Definition read_arguments (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ R ], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let len := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::plonk::permutation::Argument"; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let cols := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| len |)) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + cols; + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + [], + "fetch", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "halo2_proofs::plonk::permutation::Argument"; + Ty.path + "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::permutation::Argument" + [ ("columns", M.read (| cols |)) ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn write_column( + column: &Column, + writer: &mut W, + ) -> std::io::Result<()> { + writer.write(&mut (column.index as u32).to_le_bytes())?; + Ok(()) + } + *) + Definition write_column (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ T; W ], [ column; writer ] => + ltac:(M.monadic + (let column := M.alloc (| column |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "to_le_bytes", [] |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| column |), + "halo2_proofs::plonk::circuit::Column", + "index" + |) + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn read_column( + reader: &mut R, + t: T, + ) -> std::io::Result> { + let index = read_u32(reader)? as usize; + Ok(Column { + index, + column_type: t, + }) + } + *) + Definition read_column (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ T; R ], [ reader; t ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + let t := M.alloc (| t |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let index := + M.alloc (| + M.rust_cast + (M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ T ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |)) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::circuit::Column" + [ ("index", M.read (| index |)); ("column_type", M.read (| t |)) ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn write_queries( + columns: &Vec<(Column, Rotation)>, + writer: &mut W, + ) -> std::io::Result<()> { + writer.write(&mut (columns.len() as u32).to_le_bytes())?; + for (c, rotation) in columns.iter() { + write_column(c, writer)?; + writer.write(&mut (rotation.0 as u32).to_le_bytes())?; + } + Ok(()) + } + *) + Definition write_queries (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ T; W ], [ columns; writer ] => + ltac:(M.monadic + (let columns := M.alloc (| columns |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "to_le_bytes", [] |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ T ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| columns |) ] + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Column") [ T ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ T ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ T ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| columns |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ T ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ2_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let c := M.alloc (| γ2_0 |) in + let rotation := M.alloc (| γ2_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::write_column", + [ T; W ] + |), + [ M.read (| c |); M.read (| writer |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "usize"; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "std::io::Write", + W, + [], + "write", + [] + |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| rotation |), + "halo2_proofs::poly::Rotation", + 0 + |) + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn write_virtual_cells( + columns: &Vec, + writer: &mut W, + ) -> std::io::Result<()> { + writer.write(&mut (columns.len() as u32).to_le_bytes())?; + for cell in columns.iter() { + cell.column.store(writer)?; + writer.write(&mut (cell.rotation.0 as u32).to_le_bytes())?; + } + Ok(()) + } + *) + Definition write_virtual_cells (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ W ], [ columns; writer ] => + ltac:(M.monadic + (let columns := M.alloc (| columns |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "to_le_bytes", [] |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::VirtualCell"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| columns |) ] + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::VirtualCell"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| columns |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let cell := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + [], + "store", + [ W ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| cell |), + "halo2_proofs::plonk::circuit::VirtualCell", + "column" + |); + M.read (| writer |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "usize"; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "std::io::Write", + W, + [], + "write", + [] + |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_tuple_field (| + M.SubPointer.get_struct_record_field (| + M.read (| cell |), + "halo2_proofs::plonk::circuit::VirtualCell", + "rotation" + |), + "halo2_proofs::poly::Rotation", + 0 + |) + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn read_queries( + reader: &mut R, + t: T, + ) -> std::io::Result, Rotation)>> { + let mut queries = vec![]; + let len = read_u32(reader)?; + for _ in 0..len { + let column = read_column(reader, t)?; + let rotation = read_u32(reader)?; + let rotation = Rotation(rotation as i32); //u32 to i32?? + queries.push((column, rotation)) + } + Ok(queries) + } + *) + Definition read_queries (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ T; R ], [ reader; t ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + let t := M.alloc (| t |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let queries := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Column") [ T ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let len := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ T ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| len |)) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let column := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ T ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_column", + [ T; R ] + |), + [ M.read (| reader |); M.read (| t |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ T ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let rotation := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "u32"; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_u32", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ T ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let rotation := + M.alloc (| + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ M.rust_cast (M.read (| rotation |)) ] + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ T ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + queries; + Value.Tuple + [ M.read (| column |); M.read (| rotation |) ] + ] + |) + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| queries |) ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn read_virtual_cells(reader: &mut R) -> std::io::Result> { + let mut vcells = vec![]; + let len = read_u32(reader)?; + for _ in 0..len { + let column = Column::::fetch(reader)?; + let rotation = read_u32(reader)?; + let rotation = Rotation(rotation as i32); //u32 to i32?? + vcells.push(VirtualCell { column, rotation }) + } + Ok(vcells) + } + *) + Definition read_virtual_cells (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ R ], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let vcells := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::VirtualCell"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let len := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::VirtualCell"; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| len |)) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let column := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + [], + "fetch", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell"; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let rotation := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "u32"; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_u32", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell"; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let rotation := + M.alloc (| + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ M.rust_cast (M.read (| rotation |)) ] + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + vcells; + Value.StructRecord + "halo2_proofs::plonk::circuit::VirtualCell" + [ + ("column", M.read (| column |)); + ("rotation", M.read (| rotation |)) + ] + ] + |) + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| vcells |) ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn write_fixed_column( + column: &Column, + writer: &mut W, + ) -> std::io::Result<()> { + writer.write(&mut (column.index as u32).to_le_bytes())?; + Ok(()) + } + *) + Definition write_fixed_column (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ W ], [ column; writer ] => + ltac:(M.monadic + (let column := M.alloc (| column |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "to_le_bytes", [] |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| column |), + "halo2_proofs::plonk::circuit::Column", + "index" + |) + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn read_fixed_column(reader: &mut R) -> std::io::Result> { + let index = read_u32(reader)?; + Ok(Column::::new(index as usize, Fixed)) + } + *) + Definition read_fixed_column (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ R ], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let index := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + "new", + [] + |), + [ + M.rust_cast (M.read (| index |)); + Value.StructTuple "halo2_proofs::plonk::circuit::Fixed" [] + ] + |) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn write_fixed_columns( + columns: &Vec>, + writer: &mut W, + ) -> std::io::Result<()> { + writer.write(&mut (columns.len() as u32).to_le_bytes())?; + for c in columns.iter() { + write_fixed_column(c, writer)?; + } + Ok(()) + } + *) + Definition write_fixed_columns (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ W ], [ columns; writer ] => + ltac:(M.monadic + (let columns := M.alloc (| columns |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "to_le_bytes", [] |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| columns |) ] + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| columns |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let c := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::write_fixed_column", + [ W ] + |), + [ M.read (| c |); M.read (| writer |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn read_fixed_columns(reader: &mut R) -> std::io::Result>> { + let len = read_u32(reader)?; + let mut columns = vec![]; + for _ in 0..len { + columns.push(read_fixed_column(reader)?); + } + Ok(columns) + } + *) + Definition read_fixed_columns (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ R ], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let len := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let columns := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| len |)) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + columns; + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_fixed_column", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| columns |) ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + pub(crate) fn write_cs( + cs: &ConstraintSystem, + writer: &mut W, + ) -> io::Result<()> { + writer.write(&mut (cs.num_advice_columns as u32).to_le_bytes())?; + writer.write(&mut (cs.num_instance_columns as u32).to_le_bytes())?; + writer.write(&mut (cs.num_selectors as u32).to_le_bytes())?; + writer.write(&mut (cs.num_fixed_columns as u32).to_le_bytes())?; + writer.write(&mut (cs.num_advice_queries.len() as u32).to_le_bytes())?; + for n in cs.num_advice_queries.iter() { + writer.write(&mut ( *n as u32).to_le_bytes())?; + } + write_fixed_columns(&cs.selector_map, writer)?; + write_fixed_columns(&cs.constants, writer)?; + write_queries::(&cs.advice_queries, writer)?; + write_queries::(&cs.instance_queries, writer)?; + write_queries::(&cs.fixed_queries, writer)?; + write_arguments(&cs.permutation.columns, writer)?; + writer.write(&(cs.lookups.len() as u32).to_le_bytes())?; + for p in cs.lookups.iter() { + p.input_expressions.store(writer)?; + p.table_expressions.store(writer)?; + } + cs.named_advices.store(writer)?; + write_gates::(&cs.gates, writer)?; + Ok(()) + } + *) + Definition write_cs (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; W ], [ cs; writer ] => + ltac:(M.monadic + (let cs := M.alloc (| cs |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "to_le_bytes", [] |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| cs |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_columns" + |) + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "to_le_bytes", [] |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| cs |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_instance_columns" + |) + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "to_le_bytes", [] |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| cs |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_selectors" + |) + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "to_le_bytes", [] |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| cs |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_fixed_columns" + |) + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "to_le_bytes", [] |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| cs |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_queries" + |) + ] + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "usize" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| cs |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_queries" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let n := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "usize"; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "std::io::Write", + W, + [], + "write", + [] + |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ + M.rust_cast + (M.read (| M.read (| n |) |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::write_fixed_columns", [ W ] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| cs |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "selector_map" + |); + M.read (| writer |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::write_fixed_columns", [ W ] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| cs |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "constants" + |); + M.read (| writer |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::write_queries", + [ Ty.path "halo2_proofs::plonk::circuit::Advice"; W ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| cs |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "advice_queries" + |); + M.read (| writer |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::write_queries", + [ Ty.path "halo2_proofs::plonk::circuit::Instance"; W ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| cs |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "instance_queries" + |); + M.read (| writer |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::write_queries", + [ Ty.path "halo2_proofs::plonk::circuit::Fixed"; W ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| cs |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "fixed_queries" + |); + M.read (| writer |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::write_arguments", [ W ] |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| cs |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |), + "halo2_proofs::plonk::permutation::Argument", + "columns" + |); + M.read (| writer |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "to_le_bytes", [] |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| cs |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "lookups" + |) + ] + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| cs |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "lookups" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let p := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "store", + [ W ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| p |), + "halo2_proofs::plonk::lookup::Argument", + "input_expressions" + |); + M.read (| writer |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "store", + [ W ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| p |), + "halo2_proofs::plonk::lookup::Argument", + "table_expressions" + |); + M.read (| writer |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "alloc::string::String"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "store", + [ W ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| cs |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "named_advices" + |); + M.read (| writer |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::write_gates", [ C; W ] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| cs |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "gates" + |); + M.read (| writer |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + pub(crate) fn read_cs( + reader: &mut R, + ) -> io::Result> { + let num_advice_columns = read_u32(reader)? as usize; + let num_instance_columns = read_u32(reader)? as usize; + let num_selectors = read_u32(reader)? as usize; + let num_fixed_columns = read_u32(reader)? as usize; + + let num_advice_queries_len = read_u32(reader)?; + let mut num_advice_queries = vec![]; + for _ in 0..num_advice_queries_len { + num_advice_queries.push(read_u32(reader)? as usize); + } + + let selector_map = read_fixed_columns(reader)?; + let constants = read_fixed_columns(reader)?; + + let advice_queries = read_queries::(reader, Advice)?; + let instance_queries = read_queries::(reader, Instance)?; + let fixed_queries = read_queries::(reader, Fixed)?; + let permutation = read_arguments(reader)?; + + let mut lookups = vec![]; + let nb_lookup = read_u32(reader)?; + for _ in 0..nb_lookup { + let input_expressions = Vec::>::fetch(reader)?; + let table_expressions = Vec::>::fetch(reader)?; + lookups.push(plonk::lookup::Argument { + name: "", + input_expressions, + table_expressions, + }); + } + let named_advices = Vec::fetch(reader)?; + let gates = read_gates::(reader)?; + Ok(ConstraintSystem { + num_fixed_columns, + num_advice_columns, + num_instance_columns, + num_selectors, + selector_map, + gates, + advice_queries, + num_advice_queries, + instance_queries, + fixed_queries, + named_advices, + permutation, + lookups, + constants, + minimum_degree: None, + }) + } + *) + Definition read_cs (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; R ], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let num_advice_columns := + M.alloc (| + M.rust_cast + (M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |)) + |) in + let num_instance_columns := + M.alloc (| + M.rust_cast + (M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |)) + |) in + let num_selectors := + M.alloc (| + M.rust_cast + (M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |)) + |) in + let num_fixed_columns := + M.alloc (| + M.rust_cast + (M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |)) + |) in + let num_advice_queries_len := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let num_advice_queries := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", M.read (| num_advice_queries_len |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + num_advice_queries; + M.rust_cast + (M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "u32"; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_u32", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ]; + Ty.path + "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let selector_map := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_fixed_columns", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let constants := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_fixed_columns", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let advice_queries := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_queries", + [ Ty.path "halo2_proofs::plonk::circuit::Advice"; R ] + |), + [ + M.read (| reader |); + Value.StructTuple "halo2_proofs::plonk::circuit::Advice" [] + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let instance_queries := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_queries", + [ Ty.path "halo2_proofs::plonk::circuit::Instance"; R ] + |), + [ + M.read (| reader |); + Value.StructTuple "halo2_proofs::plonk::circuit::Instance" [] + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let fixed_queries := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_queries", + [ Ty.path "halo2_proofs::plonk::circuit::Fixed"; R ] + |), + [ + M.read (| reader |); + Value.StructTuple "halo2_proofs::plonk::circuit::Fixed" [] + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let permutation := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::plonk::permutation::Argument"; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_arguments", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let lookups := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let nb_lookup := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| nb_lookup |)) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let input_expressions := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "fetch", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let table_expressions := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "fetch", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + lookups; + Value.StructRecord + "halo2_proofs::plonk::lookup::Argument" + [ + ("name", M.read (| Value.String "" |)); + ("input_expressions", + M.read (| input_expressions |)); + ("table_expressions", + M.read (| table_expressions |)) + ] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let named_advices := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "alloc::string::String"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "alloc::string::String"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "fetch", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let gates := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_gates", [ C; R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::circuit::ConstraintSystem" + [ + ("num_fixed_columns", M.read (| num_fixed_columns |)); + ("num_advice_columns", M.read (| num_advice_columns |)); + ("num_instance_columns", M.read (| num_instance_columns |)); + ("num_selectors", M.read (| num_selectors |)); + ("selector_map", M.read (| selector_map |)); + ("gates", M.read (| gates |)); + ("advice_queries", M.read (| advice_queries |)); + ("num_advice_queries", M.read (| num_advice_queries |)); + ("instance_queries", M.read (| instance_queries |)); + ("fixed_queries", M.read (| fixed_queries |)); + ("named_advices", M.read (| named_advices |)); + ("permutation", M.read (| permutation |)); + ("lookups", M.read (| lookups |)); + ("constants", M.read (| constants |)); + ("minimum_degree", Value.StructTuple "core::option::Option::None" []) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn write_gates( + gates: &Vec>, + writer: &mut W, + ) -> std::io::Result<()> { + writer.write(&mut (gates.len() as u32).to_le_bytes())?; + for gate in gates.iter() { + gate.polys.store(writer)?; + write_virtual_cells(&gate.queried_cells, writer)?; + } + Ok(()) + } + *) + Definition write_gates (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; W ], [ gates; writer ] => + ltac:(M.monadic + (let gates := M.alloc (| gates |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "to_le_bytes", [] |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| gates |) ] + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| gates |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let gate := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "store", + [ W ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| gate |), + "halo2_proofs::plonk::circuit::Gate", + "polys" + |); + M.read (| writer |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::write_virtual_cells", + [ W ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| gate |), + "halo2_proofs::plonk::circuit::Gate", + "queried_cells" + |); + M.read (| writer |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn read_gates( + reader: &mut R, + ) -> std::io::Result>> { + let nb_gates = read_u32(reader)?; + let mut gates = vec![]; + for _ in 0..nb_gates { + gates.push(Gate::new_with_polys_and_queries( + Vec::>::fetch(reader)?, + read_virtual_cells(reader)?, + )); + } + Ok(gates) + } + *) + Definition read_gates (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; R ], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let nb_gates := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let gates := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| nb_gates |)) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + gates; + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ], + "new_with_polys_and_queries", + [] + |), + [ + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "fetch", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |); + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::circuit::VirtualCell"; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_virtual_cells", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| gates |) ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + Enum ExpressionCode + { + ty_params := []; + variants := + [ + { + name := "Constant"; + item := StructTuple []; + discriminant := Some 0; + }; + { + name := "Fixed"; + item := StructTuple []; + discriminant := None; + }; + { + name := "Advice"; + item := StructTuple []; + discriminant := None; + }; + { + name := "Instance"; + item := StructTuple []; + discriminant := None; + }; + { + name := "Negated"; + item := StructTuple []; + discriminant := None; + }; + { + name := "Sum"; + item := StructTuple []; + discriminant := None; + }; + { + name := "Product"; + item := StructTuple []; + discriminant := None; + }; + { + name := "Scaled"; + item := StructTuple []; + discriminant := None; + } + ]; + } + *) + + Definition _IMPL_NUM_FromPrimitive_FOR_ExpressionCode : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Tuple [] |))). + + Module _IMPL_NUM_FromPrimitive_FOR_ExpressionCode. + Module Impl_num_traits_cast_FromPrimitive_for_halo2_proofs_helpers_ExpressionCode. + Definition Self : Ty.t := Ty.path "halo2_proofs::helpers::ExpressionCode". + + (* FromPrimitive *) + Definition from_i64 (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ n ] => + ltac:(M.monadic + (let n := M.alloc (| n |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| n |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "halo2_proofs::helpers::ExpressionCode::Constant_discriminant" + |), + Value.Integer 0 + |))) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ Value.StructTuple "halo2_proofs::helpers::ExpressionCode::Constant" [] ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| n |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "halo2_proofs::helpers::ExpressionCode::Constant_discriminant" + |), + Value.Integer 1 + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::helpers::ExpressionCode::Fixed" + [] + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| n |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "halo2_proofs::helpers::ExpressionCode::Constant_discriminant" + |), + Value.Integer 2 + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::helpers::ExpressionCode::Advice" + [] + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| n |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "halo2_proofs::helpers::ExpressionCode::Constant_discriminant" + |), + Value.Integer 3 + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::helpers::ExpressionCode::Instance" + [] + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| n |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "halo2_proofs::helpers::ExpressionCode::Constant_discriminant" + |), + Value.Integer 4 + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::helpers::ExpressionCode::Negated" + [] + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| n |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "halo2_proofs::helpers::ExpressionCode::Constant_discriminant" + |), + Value.Integer 5 + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::helpers::ExpressionCode::Sum" + [] + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| n |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "halo2_proofs::helpers::ExpressionCode::Constant_discriminant" + |), + Value.Integer 6 + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::helpers::ExpressionCode::Product" + [] + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| + n + |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "halo2_proofs::helpers::ExpressionCode::Constant_discriminant" + |), + Value.Integer + 7 + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::helpers::ExpressionCode::Scaled" + [] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* FromPrimitive *) + Definition from_u64 (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ n ] => + ltac:(M.monadic + (let n := M.alloc (| n |) in + M.call_closure (| + M.get_trait_method (| + "num_traits::cast::FromPrimitive", + Ty.path "halo2_proofs::helpers::ExpressionCode", + [], + "from_i64", + [] + |), + [ M.rust_cast (M.read (| n |)) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "num_traits::cast::FromPrimitive" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("from_i64", InstanceField.Method from_i64); ("from_u64", InstanceField.Method from_u64) + ]. + End Impl_num_traits_cast_FromPrimitive_for_halo2_proofs_helpers_ExpressionCode. + End _IMPL_NUM_FromPrimitive_FOR_ExpressionCode. + + (* + fn expression_code(e: &Expression) -> ExpressionCode { + match e { + Expression::Constant(_) => ExpressionCode::Constant, + Expression::Fixed { + query_index: _, + column_index: _, + rotation: _, + } => ExpressionCode::Fixed, + Expression::Advice { + query_index: _, + column_index: _, + rotation: _, + } => ExpressionCode::Advice, + Expression::Instance { + query_index: _, + column_index: _, + rotation: _, + } => ExpressionCode::Instance, + Expression::Negated(_) => ExpressionCode::Negated, + Expression::Sum(_, _) => ExpressionCode::Sum, + Expression::Product(_, _) => ExpressionCode::Product, + Expression::Scaled(_, _) => ExpressionCode::Scaled, + Expression::Selector(_) => unreachable!(), + } + } + *) + Definition expression_code (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ e ] => + ltac:(M.monadic + (let e := M.alloc (| e |) in + M.read (| + M.match_operator (| + e, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Constant", + 0 + |) in + M.alloc (| + Value.StructTuple "halo2_proofs::helpers::ExpressionCode::Constant" [] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "rotation" + |) in + M.alloc (| + Value.StructTuple "halo2_proofs::helpers::ExpressionCode::Fixed" [] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "rotation" + |) in + M.alloc (| + Value.StructTuple "halo2_proofs::helpers::ExpressionCode::Advice" [] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "rotation" + |) in + M.alloc (| + Value.StructTuple "halo2_proofs::helpers::ExpressionCode::Instance" [] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Negated", + 0 + |) in + M.alloc (| + Value.StructTuple "halo2_proofs::helpers::ExpressionCode::Negated" [] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 1 + |) in + M.alloc (| Value.StructTuple "halo2_proofs::helpers::ExpressionCode::Sum" [] |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 1 + |) in + M.alloc (| + Value.StructTuple "halo2_proofs::helpers::ExpressionCode::Product" [] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 1 + |) in + M.alloc (| + Value.StructTuple "halo2_proofs::helpers::ExpressionCode::Scaled" [] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Selector", + 0 + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "internal error: entered unreachable code" |) ] + |) + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Module Impl_halo2_proofs_helpers_Serializable_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_halo2_proofs_plonk_circuit_Expression_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]. + + (* + fn fetch(reader: &mut R) -> io::Result> { + let code = read_u32(reader)?; + match num::FromPrimitive::from_u32(code).unwrap() { + ExpressionCode::Constant => { + let scalar = F::read(reader)?; + Ok(Expression::Constant(scalar)) + } + ExpressionCode::Fixed => { + let query_index = read_u32(reader)? as usize; + let column_index = read_u32(reader)? as usize; + let rotation = Rotation(read_u32(reader)? as i32); + Ok(Expression::Fixed { + query_index, + column_index, + rotation, + }) + } + ExpressionCode::Advice => { + let query_index = read_u32(reader)? as usize; + let column_index = read_u32(reader)? as usize; + let rotation = Rotation(read_u32(reader)? as i32); + Ok(Expression::Advice { + query_index, + column_index, + rotation, + }) + } + ExpressionCode::Instance => { + let query_index = read_u32(reader)? as usize; + let column_index = read_u32(reader)? as usize; + let rotation = Rotation(read_u32(reader)? as i32); + Ok(Expression::Instance { + query_index, + column_index, + rotation, + }) + } + ExpressionCode::Negated => Ok(Expression::Negated(Box::new(Self::fetch(reader)?))), + + ExpressionCode::Sum => { + let a = Self::fetch(reader)?; + let b = Self::fetch(reader)?; + Ok(Expression::Sum(Box::new(a), Box::new(b))) + } + + ExpressionCode::Product => { + let a = Self::fetch(reader)?; + let b = Self::fetch(reader)?; + Ok(Expression::Product(Box::new(a), Box::new(b))) + } + + ExpressionCode::Scaled => { + let a = Self::fetch(reader)?; + let f = F::read(reader)?; + Ok(Expression::Scaled(Box::new(a), f)) + } + } + } + *) + Definition fetch (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ R ], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let code := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::helpers::ExpressionCode" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "num_traits::cast::FromPrimitive", + Ty.path "halo2_proofs::helpers::ExpressionCode", + [], + "from_u32", + [] + |), + [ M.read (| code |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let scalar := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::fields::BaseExt", + F, + [], + "read", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ M.read (| scalar |) ] + ] + |))); + fun γ => + ltac:(M.monadic + (let query_index := + M.alloc (| + M.rust_cast + (M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_u32", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |)) + |) in + let column_index := + M.alloc (| + M.rust_cast + (M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_u32", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |)) + |) in + let rotation := + M.alloc (| + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + M.rust_cast + (M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_u32", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::circuit::Expression::Fixed" + [ + ("query_index", M.read (| query_index |)); + ("column_index", M.read (| column_index |)); + ("rotation", M.read (| rotation |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (let query_index := + M.alloc (| + M.rust_cast + (M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_u32", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |)) + |) in + let column_index := + M.alloc (| + M.rust_cast + (M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_u32", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |)) + |) in + let rotation := + M.alloc (| + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + M.rust_cast + (M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_u32", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::circuit::Expression::Advice" + [ + ("query_index", M.read (| query_index |)); + ("column_index", M.read (| column_index |)); + ("rotation", M.read (| rotation |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (let query_index := + M.alloc (| + M.rust_cast + (M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_u32", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |)) + |) in + let column_index := + M.alloc (| + M.rust_cast + (M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_u32", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |)) + |) in + let rotation := + M.alloc (| + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + M.rust_cast + (M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_u32", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::circuit::Expression::Instance" + [ + ("query_index", M.read (| query_index |)); + ("column_index", M.read (| column_index |)); + ("rotation", M.read (| rotation |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Negated" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "fetch", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) + ] + |) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (let a := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "fetch", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let b := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "fetch", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Sum" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| a |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| b |) ] + |) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (let a := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "fetch", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let b := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "fetch", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Product" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| a |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| b |) ] + |) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (let a := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "fetch", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let f := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::fields::BaseExt", + F, + [], + "read", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Scaled" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| a |) ] + |); + M.read (| f |) + ] + ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn store(&self, writer: &mut W) -> io::Result<()> { + writer.write(&mut (expression_code(self) as u32).to_le_bytes())?; + match self { + Expression::Constant(scalar) => { + writer.write(&mut scalar.to_repr().as_ref())?; + Ok(()) + } + Expression::Fixed { + query_index, + column_index, + rotation, + } => { + writer.write(&( *query_index as u32).to_le_bytes())?; + writer.write(&( *column_index as u32).to_le_bytes())?; + writer.write(&(rotation.0 as u32).to_le_bytes())?; + Ok(()) + } + Expression::Advice { + query_index, + column_index, + rotation, + } => { + writer.write(&( *query_index as u32).to_le_bytes())?; + writer.write(&( *column_index as u32).to_le_bytes())?; + writer.write(&(rotation.0 as u32).to_le_bytes())?; + Ok(()) + } + Expression::Instance { + query_index, + column_index, + rotation, + } => { + writer.write(&( *query_index as u32).to_le_bytes())?; + writer.write(&( *column_index as u32).to_le_bytes())?; + writer.write(&(rotation.0 as u32).to_le_bytes())?; + Ok(()) + } + Expression::Negated(a) => a.store(writer), + Expression::Sum(a, b) => { + a.store(writer)?; + b.store(writer)?; + Ok(()) + } + Expression::Product(a, b) => { + a.store(writer)?; + b.store(writer)?; + Ok(()) + } + Expression::Scaled(a, f) => { + a.store(writer)?; + writer.write(&mut f.to_repr().as_ref())?; + Ok(()) + } + Expression::Selector(_) => unreachable!(), + } + } + *) + Definition store (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ W ], [ self; writer ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::expression_code", + [ F ] + |), + [ M.read (| self |) ] + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Constant", + 0 + |) in + let scalar := M.alloc (| γ1_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::PrimeField", + F, + [], + "to_repr", + [] + |), + [ M.read (| scalar |) ] + |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "rotation" + |) in + let query_index := M.alloc (| γ1_0 |) in + let column_index := M.alloc (| γ1_1 |) in + let rotation := M.alloc (| γ1_2 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ M.rust_cast (M.read (| M.read (| query_index |) |)) ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ M.rust_cast (M.read (| M.read (| column_index |) |)) ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| rotation |), + "halo2_proofs::poly::Rotation", + 0 + |) + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "rotation" + |) in + let query_index := M.alloc (| γ1_0 |) in + let column_index := M.alloc (| γ1_1 |) in + let rotation := M.alloc (| γ1_2 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ M.rust_cast (M.read (| M.read (| query_index |) |)) ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ M.rust_cast (M.read (| M.read (| column_index |) |)) ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| rotation |), + "halo2_proofs::poly::Rotation", + 0 + |) + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "rotation" + |) in + let query_index := M.alloc (| γ1_0 |) in + let column_index := M.alloc (| γ1_1 |) in + let rotation := M.alloc (| γ1_2 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ M.rust_cast (M.read (| M.read (| query_index |) |)) ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ M.rust_cast (M.read (| M.read (| column_index |) |)) ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| rotation |), + "halo2_proofs::poly::Rotation", + 0 + |) + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Negated", + 0 + |) in + let a := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [], + "store", + [ W ] + |), + [ M.read (| M.read (| a |) |); M.read (| writer |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let b := M.alloc (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "store", + [ W ] + |), + [ M.read (| M.read (| a |) |); M.read (| writer |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "store", + [ W ] + |), + [ M.read (| M.read (| b |) |); M.read (| writer |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let b := M.alloc (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "store", + [ W ] + |), + [ M.read (| M.read (| a |) |); M.read (| writer |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "store", + [ W ] + |), + [ M.read (| M.read (| b |) |); M.read (| writer |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let f := M.alloc (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "store", + [ W ] + |), + [ M.read (| M.read (| a |) |); M.read (| writer |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::PrimeField", + F, + [], + "to_repr", + [] + |), + [ M.read (| f |) ] + |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Selector", + 0 + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "internal error: entered unreachable code" |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "halo2_proofs::helpers::Serializable" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("fetch", InstanceField.Method (fetch F)); ("store", InstanceField.Method (store F)) ]. + End Impl_halo2_proofs_helpers_Serializable_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_halo2_proofs_plonk_circuit_Expression_F. + + (* StructRecord + { + name := "AssignWitnessCollection"; + ty_params := [ "C" ]; + fields := + [ + ("k", Ty.path "u32"); + ("advice", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ]); + ("instances", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] ] + ]); + ("usable_rows", Ty.apply (Ty.path "core::ops::range::RangeTo") [ Ty.path "usize" ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_helpers_AssignWitnessCollection_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::helpers::AssignWitnessCollection") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field4_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AssignWitnessCollection" |); + M.read (| Value.String "k" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::helpers::AssignWitnessCollection", + "k" + |)); + M.read (| Value.String "advice" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::helpers::AssignWitnessCollection", + "advice" + |)); + M.read (| Value.String "instances" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::helpers::AssignWitnessCollection", + "instances" + |)); + M.read (| Value.String "usable_rows" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::helpers::AssignWitnessCollection", + "usable_rows" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_helpers_AssignWitnessCollection_C. + + (* StructRecord + { + name := "AssignWitnessCollectionAssigner"; + ty_params := [ "C" ]; + fields := + [ + ("k", Ty.path "u32"); + ("advice", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]); + ("instances", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] ] + ]); + ("usable_rows", Ty.apply (Ty.path "core::ops::range::RangeTo") [ Ty.path "usize" ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_for_halo2_proofs_helpers_AssignWitnessCollectionAssigner_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::helpers::AssignWitnessCollectionAssigner") [ C ]. + + (* Clone *) + Definition clone (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::helpers::AssignWitnessCollectionAssigner" + [ + ("k", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::helpers::AssignWitnessCollectionAssigner", + "k" + |) + ] + |)); + ("advice", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::helpers::AssignWitnessCollectionAssigner", + "advice" + |) + ] + |)); + ("instances", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] + ] + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::helpers::AssignWitnessCollectionAssigner", + "instances" + |) + ] + |)); + ("usable_rows", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::ops::range::RangeTo") [ Ty.path "usize" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::helpers::AssignWitnessCollectionAssigner", + "usable_rows" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone C)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_for_halo2_proofs_helpers_AssignWitnessCollectionAssigner_C. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_helpers_AssignWitnessCollectionAssigner_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::helpers::AssignWitnessCollectionAssigner") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field4_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AssignWitnessCollectionAssigner" |); + M.read (| Value.String "k" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::helpers::AssignWitnessCollectionAssigner", + "k" + |)); + M.read (| Value.String "advice" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::helpers::AssignWitnessCollectionAssigner", + "advice" + |)); + M.read (| Value.String "instances" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::helpers::AssignWitnessCollectionAssigner", + "instances" + |)); + M.read (| Value.String "usable_rows" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::helpers::AssignWitnessCollectionAssigner", + "usable_rows" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_helpers_AssignWitnessCollectionAssigner_C. + + Module Impl_core_convert_Into_where_pairing_bn256_arithmetic_curves_CurveAffine_C_halo2_proofs_helpers_AssignWitnessCollection_C_for_halo2_proofs_helpers_AssignWitnessCollectionAssigner_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::helpers::AssignWitnessCollectionAssigner") [ C ]. + + (* + fn into(self) -> AssignWitnessCollection<'a, C> { + AssignWitnessCollection { + k: self.k, + advice: Arc::try_unwrap(self.advice).unwrap().into_inner().unwrap(), + instances: self.instances, + usable_rows: self.usable_rows, + } + } + *) + Definition into (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::helpers::AssignWitnessCollection" + [ + ("k", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::helpers::AssignWitnessCollectionAssigner", + "k" + |) + |)); + ("advice", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "into_inner", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "try_unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::helpers::AssignWitnessCollectionAssigner", + "advice" + |) + |) + ] + |) + ] + |) + ] + |) + ] + |)); + ("instances", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::helpers::AssignWitnessCollectionAssigner", + "instances" + |) + |)); + ("usable_rows", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::helpers::AssignWitnessCollectionAssigner", + "usable_rows" + |) + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::convert::Into" + (Self C) + (* Trait polymorphic types *) + [ (* T *) Ty.apply (Ty.path "halo2_proofs::helpers::AssignWitnessCollection") [ C ] ] + (* Instance *) [ ("into", InstanceField.Method (into C)) ]. + End Impl_core_convert_Into_where_pairing_bn256_arithmetic_curves_CurveAffine_C_halo2_proofs_helpers_AssignWitnessCollection_C_for_halo2_proofs_helpers_AssignWitnessCollectionAssigner_C. + + Module Impl_halo2_proofs_plonk_circuit_Assignment_where_pairing_bn256_arithmetic_curves_CurveAffine_C_associated_type_for_halo2_proofs_helpers_AssignWitnessCollectionAssigner_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::helpers::AssignWitnessCollectionAssigner") [ C ]. + + (* + fn is_in_prove_mode(&self) -> bool { + true + } + *) + Definition is_in_prove_mode (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.Bool true)) + | _, _ => M.impossible + end. + + (* + fn enter_region(&self, _: N) + where + NR: Into, + N: FnOnce() -> NR, + { + // Do nothing; we don't care about regions in this context. + } + *) + Definition enter_region (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ NR; N ], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Tuple [])) ] |))) + | _, _ => M.impossible + end. + + (* + fn exit_region(&self) { + // Do nothing; we don't care about regions in this context. + } + *) + Definition exit_region (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.Tuple [])) + | _, _ => M.impossible + end. + + (* + fn enable_selector(&self, _: A, _: &Selector, _: usize) -> Result<(), Error> + where + A: FnOnce() -> AR, + AR: Into, + { + // We only care about advice columns here + + Ok(()) + } + *) + Definition enable_selector (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ A; AR ], [ self; β1; β2; β3 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let β2 := M.alloc (| β2 |) in + let β3 := M.alloc (| β3 |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β2, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β3, + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ])) + ] + |))) + ] + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn query_instance( + &self, + column: Column, + row: usize, + ) -> Result, Error> { + if !self.usable_rows.contains(&row) { + return Err(Error::not_enough_rows_available(self.k)); + } + + self.instances + .get(column.index()) + .and_then(|column| column.get(row)) + .map(|v| Some( *v)) + .ok_or(Error::BoundsFailure) + } + *) + Definition query_instance (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; column; row ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + let row := M.alloc (| row |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::RangeTo") + [ Ty.path "usize" ], + "contains", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::helpers::AssignWitnessCollectionAssigner", + "usable_rows" + |); + row + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::error::Error", + "not_enough_rows_available", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::helpers::AssignWitnessCollectionAssigner", + "k" + |) + |) + ] + |) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.associated ] ], + "ok_or", + [ Ty.path "halo2_proofs::plonk::error::Error" ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "map", + [ + Ty.apply (Ty.path "core::option::Option") [ Ty.associated ]; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.associated ] ] ] + (Ty.apply (Ty.path "core::option::Option") [ Ty.associated ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] + ] + ], + "and_then", + [ + Ty.apply (Ty.path "&") [ Ty.associated ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.associated ] ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] + ], + "get", + [ Ty.path "usize" ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::helpers::AssignWitnessCollectionAssigner", + "instances" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ], + "index", + [] + |), + [ column ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let column := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "get", + [ Ty.path "usize" ] + |), + [ M.read (| M.read (| column |) |); M.read (| row |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let v := M.copy (| γ |) in + Value.StructTuple + "core::option::Option::Some" + [ M.read (| M.read (| v |) |) ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + Value.StructTuple "halo2_proofs::plonk::error::Error::BoundsFailure" [] + ] + |) + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn assign_advice( + &self, + _: A, + column: Column, + row: usize, + to: V, + ) -> Result<(), Error> + where + V: FnOnce() -> Result, + VR: Into>, + A: FnOnce() -> AR, + AR: Into, + { + if !self.usable_rows.contains(&row) { + return Err(Error::not_enough_rows_available(self.k)); + } + + let mut advice = self.advice.lock().unwrap(); + + *advice + .get_mut(column.index()) + .and_then(|v| v.get_mut(row)) + .ok_or(Error::BoundsFailure)? = to()?.into(); + + Ok(()) + } + *) + Definition assign_advice (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ V; VR; A; AR ], [ self; β1; column; row; to ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let column := M.alloc (| column |) in + let row := M.alloc (| row |) in + let to := M.alloc (| to |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::RangeTo") + [ Ty.path "usize" ], + "contains", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::helpers::AssignWitnessCollectionAssigner", + "usable_rows" + |); + row + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::error::Error", + "not_enough_rows_available", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::helpers::AssignWitnessCollectionAssigner", + "k" + |) + |) + ] + |) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let advice := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::helpers::AssignWitnessCollectionAssigner", + "advice" + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.write (| + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ] + ] + ], + "ok_or", + [ Ty.path "halo2_proofs::plonk::error::Error" ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ], + "and_then", + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ] + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ], + "get_mut", + [ Ty.path "usize" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref_mut", + [] + |), + [ advice ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ], + "index", + [] + |), + [ column ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let v := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ] + ], + "get_mut", + [ Ty.path "usize" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [], + "deref_mut", + [] + |), + [ M.read (| v |) ] + |); + M.read (| row |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::error::Error::BoundsFailure" + [] + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |), + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + VR, + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ] + ], + "into", + [] + |), + [ + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ VR; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + V, + [ Ty.tuple [] ], + "call_once", + [] + |), + [ M.read (| to |); Value.Tuple [] ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |) + |))) + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign_fixed( + &self, + _: A, + _: Column, + _: usize, + _: V, + ) -> Result<(), Error> + where + V: FnOnce() -> Result, + VR: Into>, + A: FnOnce() -> AR, + AR: Into, + { + // We only care about advice columns here + + Ok(()) + } + *) + Definition assign_fixed (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ V; VR; A; AR ], [ self; β1; β2; β3; β4 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let β2 := M.alloc (| β2 |) in + let β3 := M.alloc (| β3 |) in + let β4 := M.alloc (| β4 |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β2, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β3, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β4, + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ])) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn copy(&self, _: Column, _: usize, _: Column, _: usize) -> Result<(), Error> { + // We only care about advice columns here + + Ok(()) + } + *) + Definition copy (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; β1; β2; β3; β4 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let β2 := M.alloc (| β2 |) in + let β3 := M.alloc (| β3 |) in + let β4 := M.alloc (| β4 |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β2, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β3, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β4, + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ])) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn fill_from_row( + &self, + _: Column, + _: usize, + _: Option>, + ) -> Result<(), Error> { + Ok(()) + } + *) + Definition fill_from_row (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; β1; β2; β3 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let β2 := M.alloc (| β2 |) in + let β3 := M.alloc (| β3 |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β2, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β3, + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ])) + ] + |))) + ] + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn push_namespace(&self, _: N) + where + NR: Into, + N: FnOnce() -> NR, + { + // Do nothing; we don't care about namespaces in this context. + } + *) + Definition push_namespace (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ NR; N ], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Tuple [])) ] |))) + | _, _ => M.impossible + end. + + (* + fn pop_namespace(&self, _: Option) { + // Do nothing; we don't care about namespaces in this context. + } + *) + Definition pop_namespace (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Tuple [])) ] |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "halo2_proofs::plonk::circuit::Assignment" + (Self C) + (* Trait polymorphic types *) [ (* F *) Ty.associated ] + (* Instance *) + [ + ("is_in_prove_mode", InstanceField.Method (is_in_prove_mode C)); + ("enter_region", InstanceField.Method (enter_region C)); + ("exit_region", InstanceField.Method (exit_region C)); + ("enable_selector", InstanceField.Method (enable_selector C)); + ("query_instance", InstanceField.Method (query_instance C)); + ("assign_advice", InstanceField.Method (assign_advice C)); + ("assign_fixed", InstanceField.Method (assign_fixed C)); + ("copy", InstanceField.Method (copy C)); + ("fill_from_row", InstanceField.Method (fill_from_row C)); + ("push_namespace", InstanceField.Method (push_namespace C)); + ("pop_namespace", InstanceField.Method (pop_namespace C)) + ]. + End Impl_halo2_proofs_plonk_circuit_Assignment_where_pairing_bn256_arithmetic_curves_CurveAffine_C_associated_type_for_halo2_proofs_helpers_AssignWitnessCollectionAssigner_C. + + Module Impl_halo2_proofs_helpers_Serializable_where_core_clone_Clone_B_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_halo2_proofs_poly_Polynomial_halo2_proofs_plonk_assigned_Assigned_F_B. + Definition Self (B F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]; B ]. + + (* + fn fetch(reader: &mut R) -> io::Result { + Ok(Polynomial::new(Vec::>::fetch(reader)?)) + } + *) + Definition fetch (B F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self B F in + match τ, α with + | [ R ], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]; B ], + "new", + [] + |), + [ + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "fetch", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + B + ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) + ] + |) + ])) + |))) + | _, _ => M.impossible + end. + + (* + fn store(&self, writer: &mut W) -> io::Result<()> { + self.values.store(writer)?; + Ok(()) + } + *) + Definition store (B F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self B F in + match τ, α with + | [ W ], [ self; writer ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "store", + [ W ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "values" + |); + M.read (| writer |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (B F : Ty.t), + M.IsTraitInstance + "halo2_proofs::helpers::Serializable" + (Self B F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("fetch", InstanceField.Method (fetch B F)); ("store", InstanceField.Method (store B F)) + ]. + End Impl_halo2_proofs_helpers_Serializable_where_core_clone_Clone_B_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_halo2_proofs_poly_Polynomial_halo2_proofs_plonk_assigned_Assigned_F_B. + + Module Impl_halo2_proofs_helpers_ParaSerializable_for_halo2_proofs_plonk_permutation_keygen_Assembly. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::permutation::keygen::Assembly". + + (* + fn vec_fetch(fd: &mut File) -> io::Result { + let assembly = Assembly { + mapping: Vec::>::vec_fetch(fd)?, + }; + Ok(assembly) + } + *) + Definition vec_fetch (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ fd ] => + ltac:(M.monadic + (let fd := M.alloc (| fd |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let assembly := + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::permutation::keygen::Assembly" + [ + ("mapping", + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::ParaSerializable", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "vec_fetch", + [] + |), + [ M.read (| fd |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "halo2_proofs::plonk::permutation::keygen::Assembly"; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| assembly |) ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn vec_store(&self, fd: &mut File) -> io::Result<()> { + //self.columns.store(writer)?; + self.mapping.vec_store(fd)?; + + Ok(()) + } + *) + Definition vec_store (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; fd ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let fd := M.alloc (| fd |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::ParaSerializable", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "vec_store", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::keygen::Assembly", + "mapping" + |); + M.read (| fd |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "halo2_proofs::helpers::ParaSerializable" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ + ("vec_fetch", InstanceField.Method vec_fetch); + ("vec_store", InstanceField.Method vec_store) + ]. + End Impl_halo2_proofs_helpers_ParaSerializable_for_halo2_proofs_plonk_permutation_keygen_Assembly. + + Module Impl_halo2_proofs_helpers_AssignWitnessCollection_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::helpers::AssignWitnessCollection") [ C ]. + + (* + pub fn store_witness>( + params: &Params, + pk: &ProvingKey, + instances: &[&[C::Scalar]], + unusable_rows_start: usize, + circuit: &ConcreteCircuit, + fd: &mut File, + ) -> Result<(), Error> { + use std::io::prelude::*; + let mut meta = ConstraintSystem::default(); + let config = ConcreteCircuit::configure(&mut meta); + + let domain = &pk.get_vk().domain; + let meta = &pk.get_vk().cs; + let mut witness = AssignWitnessCollectionAssigner:: { + k: params.k, + advice: Arc::new(Mutex::new(vec![ + domain.empty_lagrange_assigned(); + meta.num_advice_columns + ])), + instances, + // The prover will not be allowed to assign values to advice + // cells that exist within inactive rows, which include some + // number of blinding factors and an extra row for use in the + // permutation argument. + usable_rows: ..unusable_rows_start, + }; + + // Synthesize the circuit to obtain the witness and other information. + ConcreteCircuit::FloorPlanner::synthesize( + &mut witness, + circuit, + config.clone(), + meta.constants.clone(), + )?; + + let witness: AssignWitnessCollection<_> = witness.into(); + + let bundlesize = params.k + 5; + let advice = batch_invert_assigned(witness.advice); + fd.set_len(4 + (1u64 << bundlesize)).unwrap(); + fd.write(&(advice.len() as u32).to_le_bytes())?; + fd.set_len(4 + ((advice.len() as u64) << bundlesize)) + .unwrap(); + { + advice.into_par_iter().enumerate().for_each(|(i, s2)| { + let mut mmap = unsafe { + MmapOptions::new() + .offset(4 + ((i as u64) << bundlesize)) + .len(1 << bundlesize) + .map_mut(&fd) + .unwrap() + }; + let s: &[u8] = unsafe { + std::slice::from_raw_parts( + s2.as_ptr() as *const C::Scalar as *const u8, + 1 << bundlesize, + ) + }; + (&mut mmap).copy_from_slice(s); + }); + } + println!("witness stored!"); + + //witness.advice.store(writer)?; + Ok(()) + } + *) + Definition store_witness (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ ConcreteCircuit ], [ params; pk; instances; unusable_rows_start; circuit; fd ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let pk := M.alloc (| pk |) in + let instances := M.alloc (| instances |) in + let unusable_rows_start := M.alloc (| unusable_rows_start |) in + let circuit := M.alloc (| circuit |) in + let fd := M.alloc (| fd |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let meta := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + [], + "default", + [] + |), + [] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Circuit", + ConcreteCircuit, + [ Ty.associated ], + "configure", + [] + |), + [ meta ] + |) + |) in + let domain := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::ProvingKey") [ C ], + "get_vk", + [] + |), + [ M.read (| pk |) ] + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + |) in + let meta := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::ProvingKey") [ C ], + "get_vk", + [] + |), + [ M.read (| pk |) ] + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + |) in + let witness := + M.alloc (| + Value.StructRecord + "halo2_proofs::helpers::AssignWitnessCollectionAssigner" + [ + ("k", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "k" + |) + |)); + ("advice", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "empty_lagrange_assigned", + [] + |), + [ M.read (| domain |) ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| meta |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_columns" + |) + |) + ] + |) + ] + |) + ] + |)); + ("instances", M.read (| instances |)); + ("usable_rows", + Value.StructRecord + "core::ops::range::RangeTo" + [ ("end_", M.read (| unusable_rows_start |)) ]) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::FloorPlanner", + Ty.associated, + [], + "synthesize", + [ + Ty.associated; + Ty.apply + (Ty.path "halo2_proofs::helpers::AssignWitnessCollectionAssigner") + [ C ]; + ConcreteCircuit + ] + |), + [ + witness; + M.read (| circuit |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.associated, + [], + "clone", + [] + |), + [ config ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| meta |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "constants" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let witness := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::helpers::AssignWitnessCollectionAssigner") + [ C ], + [ Ty.apply (Ty.path "halo2_proofs::helpers::AssignWitnessCollection") [ C ] + ], + "into", + [] + |), + [ M.read (| witness |) ] + |) + |) in + let bundlesize := + M.alloc (| + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "k" + |) + |), + Value.Integer 5 + |) + |) in + let advice := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::poly::batch_invert_assigned", + [ Ty.associated ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + witness, + "halo2_proofs::helpers::AssignWitnessCollection", + "advice" + |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| Ty.path "std::fs::File", "set_len", [] |), + [ + M.read (| fd |); + BinOp.Panic.add (| + Integer.U64, + Value.Integer 4, + BinOp.Panic.shl (| Value.Integer 1, M.read (| bundlesize |) |) + |) + ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "std::io::Write", + Ty.path "std::fs::File", + [], + "write", + [] + |), + [ + M.read (| fd |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ advice ] + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| Ty.path "std::fs::File", "set_len", [] |), + [ + M.read (| fd |); + BinOp.Panic.add (| + Integer.U64, + Value.Integer 4, + BinOp.Panic.shl (| + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ advice ] + |)), + M.read (| bundlesize |) + |) + |) + ] + |) + ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "rayon::vec::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ] + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IndexedParallelIterator", + Ty.apply + (Ty.path "rayon::vec::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_par_iter", + [] + |), + [ M.read (| advice |) ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let i := M.copy (| γ0_0 |) in + let s2 := M.copy (| γ0_1 |) in + M.read (| + let mmap := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "memmap::MmapMut"; + Ty.path "std::io::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "memmap::MmapOptions", + "map_mut", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "memmap::MmapOptions", + "len", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "memmap::MmapOptions", + "offset", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "memmap::MmapOptions", + "new", + [] + |), + [] + |) + |); + BinOp.Panic.add (| + Integer.U64, + Value.Integer 4, + BinOp.Panic.shl (| + M.rust_cast (M.read (| i |)), + M.read (| bundlesize |) + |) + |) + ] + |); + BinOp.Panic.shl (| + Value.Integer 1, + M.read (| bundlesize |) + |) + ] + |); + M.read (| fd |) + ] + |) + ] + |) + |) in + let s := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::slice::raw::from_raw_parts", + [ Ty.path "u8" ] + |), + [ + M.rust_cast + (M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "as_ptr", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [], + "deref", + [] + |), + [ s2 ] + |) + ] + |))); + BinOp.Panic.shl (| + Value.Integer 1, + M.read (| bundlesize |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u8" ], + "copy_from_slice", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.path "memmap::MmapMut", + [], + "deref_mut", + [] + |), + [ mmap ] + |); + M.read (| s |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| "std::io::stdio::_print", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array [ M.read (| Value.String "witness stored! +" |) ] + |)) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_store_witness : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "store_witness" (store_witness C). + + (* + pub fn fetch_witness( + params: &Params, + fd: &mut File, + ) -> Result>, Error> { + let len = read_u32(fd)?; + let bundlesize = params.k + 5; + let advice: Vec> = (0..len) + .into_par_iter() + .map(|i| { + let mmap = unsafe { + MmapOptions::new() + .offset(4 + ((i as u64) << bundlesize)) + .len(1 << bundlesize) + .map(&fd) + .unwrap() + }; + let s: &[C::Scalar] = unsafe { + std::slice::from_raw_parts(mmap.as_ptr() as *const C::Scalar, 1 << params.k) + }; + let mut s2 = vec![]; + s2.extend_from_slice(s); + Polynomial::new(s2) + }) + .collect(); + + Ok(advice) + } + *) + Definition fetch_witness (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ params; fd ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let fd := M.alloc (| fd |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let len := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_u32", + [ Ty.path "std::fs::File" ] + |), + [ M.read (| fd |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let bundlesize := + M.alloc (| + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "k" + |) + |), + Value.Integer 5 + |) + |) in + let advice := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::map::Map") + [ + Ty.apply (Ty.path "rayon::range::Iter") [ Ty.path "u32" ]; + Ty.function + [ Ty.tuple [ Ty.path "u32" ] ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply (Ty.path "rayon::range::Iter") [ Ty.path "u32" ], + [], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "u32" ] ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]); + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "u32" ], + [], + "into_par_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| len |)) ] + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let i := M.copy (| γ |) in + M.read (| + let mmap := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "memmap::Mmap"; + Ty.path "std::io::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "memmap::MmapOptions", + "map", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "memmap::MmapOptions", + "len", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "memmap::MmapOptions", + "offset", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "memmap::MmapOptions", + "new", + [] + |), + [] + |) + |); + BinOp.Panic.add (| + Integer.U64, + Value.Integer 4, + BinOp.Panic.shl (| + M.rust_cast (M.read (| i |)), + M.read (| bundlesize |) + |) + |) + ] + |); + BinOp.Panic.shl (| + Value.Integer 1, + M.read (| bundlesize |) + |) + ] + |); + M.read (| fd |) + ] + |) + ] + |) + |) in + let s := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::slice::raw::from_raw_parts", + [ Ty.associated ] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "u8" ], + "as_ptr", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "memmap::Mmap", + [], + "deref", + [] + |), + [ mmap ] + |) + ] + |)); + BinOp.Panic.shl (| + Value.Integer 1, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "k" + |) + |) + |) + ] + |) + |) in + let s2 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + "extend_from_slice", + [] + |), + [ s2; M.read (| s |) ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ], + "new", + [] + |), + [ M.read (| s2 |) ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| advice |) ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_fetch_witness : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "fetch_witness" (fetch_witness C). + End Impl_halo2_proofs_helpers_AssignWitnessCollection_C. + + (* + Enum AssignedCode + { + ty_params := []; + variants := + [ + { + name := "Zero"; + item := StructTuple []; + discriminant := Some 0; + }; + { + name := "Trivial"; + item := StructTuple []; + discriminant := None; + }; + { + name := "Rational"; + item := StructTuple []; + discriminant := None; + } + ]; + } + *) + + Definition _IMPL_NUM_FromPrimitive_FOR_AssignedCode : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Tuple [] |))). + + Module _IMPL_NUM_FromPrimitive_FOR_AssignedCode. + Module Impl_num_traits_cast_FromPrimitive_for_halo2_proofs_helpers_AssignedCode. + Definition Self : Ty.t := Ty.path "halo2_proofs::helpers::AssignedCode". + + (* FromPrimitive *) + Definition from_i64 (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ n ] => + ltac:(M.monadic + (let n := M.alloc (| n |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| n |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "halo2_proofs::helpers::AssignedCode::Zero_discriminant" + |), + Value.Integer 0 + |))) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ Value.StructTuple "halo2_proofs::helpers::AssignedCode::Zero" [] ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| n |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "halo2_proofs::helpers::AssignedCode::Zero_discriminant" + |), + Value.Integer 1 + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::helpers::AssignedCode::Trivial" + [] + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| n |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "halo2_proofs::helpers::AssignedCode::Zero_discriminant" + |), + Value.Integer 2 + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::helpers::AssignedCode::Rational" + [] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple "core::option::Option::None" [] + |))) + ] + |))) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* FromPrimitive *) + Definition from_u64 (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ n ] => + ltac:(M.monadic + (let n := M.alloc (| n |) in + M.call_closure (| + M.get_trait_method (| + "num_traits::cast::FromPrimitive", + Ty.path "halo2_proofs::helpers::AssignedCode", + [], + "from_i64", + [] + |), + [ M.rust_cast (M.read (| n |)) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "num_traits::cast::FromPrimitive" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("from_i64", InstanceField.Method from_i64); ("from_u64", InstanceField.Method from_u64) + ]. + End Impl_num_traits_cast_FromPrimitive_for_halo2_proofs_helpers_AssignedCode. + End _IMPL_NUM_FromPrimitive_FOR_AssignedCode. + + (* + fn assigned_code(e: &Assigned) -> AssignedCode { + match e { + Assigned::Zero => AssignedCode::Zero, + Assigned::Trivial(_) => AssignedCode::Trivial, + Assigned::Rational(_, _) => AssignedCode::Rational, + } + } + *) + Definition assigned_code (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ e ] => + ltac:(M.monadic + (let e := M.alloc (| e |) in + M.read (| + M.match_operator (| + e, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| Value.StructTuple "halo2_proofs::helpers::AssignedCode::Zero" [] |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Trivial", + 0 + |) in + M.alloc (| + Value.StructTuple "halo2_proofs::helpers::AssignedCode::Trivial" [] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 1 + |) in + M.alloc (| + Value.StructTuple "halo2_proofs::helpers::AssignedCode::Rational" [] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Module Impl_halo2_proofs_helpers_Serializable_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_halo2_proofs_plonk_assigned_Assigned_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* + fn fetch(reader: &mut R) -> io::Result> { + let code = read_u32(reader)?; + match num::FromPrimitive::from_u32(code).unwrap() { + AssignedCode::Zero => Ok(Assigned::Zero), + AssignedCode::Trivial => { + let scalar = F::read(reader)?; + Ok(Assigned::Trivial(scalar)) + } + AssignedCode::Rational => { + let p = F::read(reader)?; + let q = F::read(reader)?; + Ok(Assigned::Rational(p, q)) + } + } + } + *) + Definition fetch (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ R ], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let code := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::helpers::read_u32", [ R ] |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::helpers::AssignedCode" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "num_traits::cast::FromPrimitive", + Ty.path "halo2_proofs::helpers::AssignedCode", + [], + "from_u32", + [] + |), + [ M.read (| code |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.StructTuple "halo2_proofs::plonk::assigned::Assigned::Zero" [] ] + |))); + fun γ => + ltac:(M.monadic + (let scalar := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::fields::BaseExt", + F, + [], + "read", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructTuple + "halo2_proofs::plonk::assigned::Assigned::Trivial" + [ M.read (| scalar |) ] + ] + |))); + fun γ => + ltac:(M.monadic + (let p := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::fields::BaseExt", + F, + [], + "read", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let q := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::fields::BaseExt", + F, + [], + "read", + [ R ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructTuple + "halo2_proofs::plonk::assigned::Assigned::Rational" + [ M.read (| p |); M.read (| q |) ] + ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn store(&self, writer: &mut W) -> io::Result<()> { + writer.write(&mut (assigned_code(self) as u32).to_le_bytes())?; + match self { + Assigned::Zero => Ok(()), + Assigned::Trivial(f) => { + writer.write(&mut f.to_repr().as_ref())?; + Ok(()) + } + Assigned::Rational(p, q) => { + writer.write(&mut p.to_repr().as_ref())?; + writer.write(&mut q.to_repr().as_ref())?; + Ok(()) + } + } + } + *) + Definition store (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ W ], [ self; writer ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::assigned_code", + [ F ] + |), + [ M.read (| self |) ] + |)) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Trivial", + 0 + |) in + let f := M.alloc (| γ1_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::PrimeField", + F, + [], + "to_repr", + [] + |), + [ M.read (| f |) ] + |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 1 + |) in + let p := M.alloc (| γ1_0 |) in + let q := M.alloc (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::PrimeField", + F, + [], + "to_repr", + [] + |), + [ M.read (| p |) ] + |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write", [] |), + [ + M.read (| writer |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::PrimeField", + F, + [], + "to_repr", + [] + |), + [ M.read (| q |) ] + |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "halo2_proofs::helpers::Serializable" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("fetch", InstanceField.Method (fetch F)); ("store", InstanceField.Method (store F)) ]. + End Impl_halo2_proofs_helpers_Serializable_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_halo2_proofs_plonk_assigned_Assigned_F. + + (* + pub fn store_pk_info( + params: &Params, + vk: &VerifyingKey, + circuit: &ConcreteCircuit, + //writer: &mut W, + fd: &mut File, + ) -> io::Result<()> + where + ConcreteCircuit: Circuit, + { + use ark_std::{end_timer, start_timer}; + let timer = start_timer!(|| "test generate_pk_info ..."); + let (fixed, permutation) = generate_pk_info(params, vk, circuit).unwrap(); + end_timer!(timer); + let timer = start_timer!(|| "test store fixed ..."); + fixed.store(fd)?; + end_timer!(timer); + let timer = start_timer!(|| "test store permutation ..."); + permutation.vec_store(fd)?; + end_timer!(timer); + Ok(()) + } + *) + Definition store_pk_info (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; ConcreteCircuit ], [ params; vk; circuit; fd ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let vk := M.alloc (| vk |) in + let circuit := M.alloc (| circuit |) in + let fd := M.alloc (| fd |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let timer := + M.alloc (| Value.StructTuple "ark_std::perf_trace::inner::TimerInfo" [] |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::permutation::keygen::Assembly" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::keygen::generate_pk_info", + [ C; ConcreteCircuit ] + |), + [ M.read (| params |); M.read (| vk |); M.read (| circuit |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let fixed := M.copy (| γ0_0 |) in + let permutation := M.copy (| γ0_1 |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple "ark_std::perf_trace::inner::TimerInfo" [] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "store", + [ Ty.path "std::fs::File" ] + |), + [ fixed; M.read (| fd |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::ParaSerializable", + Ty.path + "halo2_proofs::plonk::permutation::keygen::Assembly", + [], + "vec_store", + [] + |), + [ permutation; M.read (| fd |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + pub fn fetch_pk_info( + params: &Params, + vk: &VerifyingKey, + reader: &mut File, + ) -> io::Result> { + use ark_std::{end_timer, start_timer}; + let timer = start_timer!(|| "test fetch fixed..."); + let fixed = Vec::fetch(reader)?; + end_timer!(timer); + let timer = start_timer!(|| "test fetch permutation ..."); + let permutation = Assembly::vec_fetch(reader)?; + end_timer!(timer); + let pkey = keygen_pk_from_info(params, vk, fixed, permutation).unwrap(); + Ok(pkey) + } + *) + Definition fetch_pk_info (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C ], [ params; vk; reader ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let vk := M.alloc (| vk |) in + let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let timer := + M.alloc (| Value.StructTuple "ark_std::perf_trace::inner::TimerInfo" [] |) in + let fixed := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "fetch", + [ Ty.path "std::fs::File" ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::ProvingKey") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple "ark_std::perf_trace::inner::TimerInfo" [] + |) in + let permutation := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::plonk::permutation::keygen::Assembly"; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::ParaSerializable", + Ty.path "halo2_proofs::plonk::permutation::keygen::Assembly", + [], + "vec_fetch", + [] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::ProvingKey") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let pkey := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::ProvingKey") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::keygen::keygen_pk_from_info", + [ C ] + |), + [ + M.read (| params |); + M.read (| vk |); + M.read (| fixed |); + M.read (| permutation |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ M.read (| pkey |) ] + |))) + ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. +End helpers. diff --git a/CoqOfRust/halo2_proofs/parallel.v b/CoqOfRust/halo2_proofs/parallel.v new file mode 100644 index 000000000..9b2f8b819 --- /dev/null +++ b/CoqOfRust/halo2_proofs/parallel.v @@ -0,0 +1,285 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module parallel. + (* StructTuple + { + name := "Parallel"; + ty_params := [ "T" ]; + fields := + [ + Ty.apply + (Ty.path "alloc::sync::Arc") + [ Ty.apply (Ty.path "std::sync::mutex::Mutex") [ T ]; Ty.path "alloc::alloc::Global" ] + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_T_where_core_fmt_Debug_T_for_halo2_proofs_parallel_Parallel_T. + Definition Self (T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::parallel::Parallel") [ T ]. + + (* Debug *) + Definition fmt (T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self T in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Parallel" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::parallel::Parallel", + 0 + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (T : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self T) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt T)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_T_where_core_fmt_Debug_T_for_halo2_proofs_parallel_Parallel_T. + + Module Impl_core_clone_Clone_where_core_fmt_Debug_T_for_halo2_proofs_parallel_Parallel_T. + Definition Self (T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::parallel::Parallel") [ T ]. + + (* + fn clone(&self) -> Self { + Self(self.0.clone()) + } + *) + Definition clone (T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self T in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructTuple + "halo2_proofs::parallel::Parallel" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply (Ty.path "std::sync::mutex::Mutex") [ T ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::parallel::Parallel", + 0 + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (T : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self T) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone T)) ]. + End Impl_core_clone_Clone_where_core_fmt_Debug_T_for_halo2_proofs_parallel_Parallel_T. + + Module Impl_halo2_proofs_parallel_Parallel_T. + Definition Self (T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::parallel::Parallel") [ T ]. + + (* + pub(crate) fn new(v: T) -> Self { + Parallel(Arc::new(Mutex::new(v))) + } + *) + Definition new (T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self T in + match τ, α with + | [], [ v ] => + ltac:(M.monadic + (let v := M.alloc (| v |) in + Value.StructTuple + "halo2_proofs::parallel::Parallel" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply (Ty.path "std::sync::mutex::Mutex") [ T ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "std::sync::mutex::Mutex") [ T ], + "new", + [] + |), + [ M.read (| v |) ] + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : forall (T : Ty.t), M.IsAssociatedFunction (Self T) "new" (new T). + + (* + pub(crate) fn into_inner(self) -> T { + Arc::try_unwrap(self.0).unwrap().into_inner().unwrap() + } + *) + Definition into_inner (T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self T in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ T; Ty.apply (Ty.path "std::sync::poison::PoisonError") [ T ] ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "std::sync::mutex::Mutex") [ T ], + "into_inner", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "std::sync::mutex::Mutex") [ T ]; + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply (Ty.path "std::sync::mutex::Mutex") [ T ]; + Ty.path "alloc::alloc::Global" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply (Ty.path "std::sync::mutex::Mutex") [ T ]; + Ty.path "alloc::alloc::Global" + ], + "try_unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + self, + "halo2_proofs::parallel::Parallel", + 0 + |) + |) + ] + |) + ] + |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_into_inner : + forall (T : Ty.t), + M.IsAssociatedFunction (Self T) "into_inner" (into_inner T). + + (* + pub(crate) fn lock(&self) -> Result, PoisonError>> { + self.0.lock() + } + *) + Definition lock (T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self T in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "std::sync::mutex::Mutex") [ T ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply (Ty.path "std::sync::mutex::Mutex") [ T ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::parallel::Parallel", + 0 + |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_lock : + forall (T : Ty.t), + M.IsAssociatedFunction (Self T) "lock" (lock T). + End Impl_halo2_proofs_parallel_Parallel_T. +End parallel. diff --git a/CoqOfRust/halo2_proofs/plonk.v b/CoqOfRust/halo2_proofs/plonk.v new file mode 100644 index 000000000..2b42b13f5 --- /dev/null +++ b/CoqOfRust/halo2_proofs/plonk.v @@ -0,0 +1,3678 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module plonk. + (* StructRecord + { + name := "VerifyingKey"; + ty_params := [ "C" ]; + fields := + [ + ("domain", + Ty.apply (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") [ Ty.associated ]); + ("fixed_commitments", + Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ]); + ("permutation", + Ty.apply (Ty.path "halo2_proofs::plonk::permutation::VerifyingKey") [ C ]); + ("cs", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ Ty.associated ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_VerifyingKey_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::VerifyingKey") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field4_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "VerifyingKey" |); + M.read (| Value.String "domain" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |)); + M.read (| Value.String "fixed_commitments" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::VerifyingKey", + "fixed_commitments" + |)); + M.read (| Value.String "permutation" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::VerifyingKey", + "permutation" + |)); + M.read (| Value.String "cs" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_VerifyingKey_C. + + Module Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_for_halo2_proofs_plonk_VerifyingKey_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::VerifyingKey") [ C ]. + + (* Clone *) + Definition clone (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::plonk::VerifyingKey" + [ + ("domain", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |)); + ("fixed_commitments", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::VerifyingKey", + "fixed_commitments" + |) + ] + |)); + ("permutation", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "halo2_proofs::plonk::permutation::VerifyingKey") [ C ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::VerifyingKey", + "permutation" + |) + ] + |)); + ("cs", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone C)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_for_halo2_proofs_plonk_VerifyingKey_C. + + Module Impl_halo2_proofs_plonk_VerifyingKey_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::VerifyingKey") [ C ]. + + (* + pub fn write(&self, writer: &mut W) -> io::Result<()> { + for commitment in &self.fixed_commitments { + writer.write_all(commitment.to_bytes().as_ref())?; + } + self.permutation.write(writer)?; + + Ok(()) + } + *) + Definition write (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ W ], [ self; writer ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ] + ], + [], + "into_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::VerifyingKey", + "fixed_commitments" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ C ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let commitment := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "std::io::Write", + W, + [], + "write_all", + [] + |), + [ + M.read (| writer |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ + Ty.apply + (Ty.path "slice") + [ Ty.path "u8" ] + ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::GroupEncoding", + C, + [], + "to_bytes", + [] + |), + [ M.read (| commitment |) ] + |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::permutation::VerifyingKey") + [ C ], + "write", + [ W ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::VerifyingKey", + "permutation" + |); + M.read (| writer |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_write : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "write" (write C). + + (* + pub fn read>( + reader: &mut R, + params: &Params, + ) -> io::Result { + let (domain, cs, _) = keygen::create_domain::(params); + + let fixed_commitments: Vec<_> = (0..cs.num_fixed_columns) + .map(|_| C::read(reader)) + .collect::>()?; + + let permutation = permutation::VerifyingKey::read(reader, &cs.permutation)?; + + Ok(VerifyingKey { + domain, + fixed_commitments, + permutation, + cs, + }) + } + *) + Definition read (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ R; ConcreteCircuit ], [ reader; params ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + let params := M.alloc (| params |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::keygen::create_domain", + [ C; ConcreteCircuit ] + |), + [ M.read (| params |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_2 := M.SubPointer.get_tuple_field (| γ, 2 |) in + let domain := M.copy (| γ0_0 |) in + let cs := M.copy (| γ0_1 |) in + let fixed_commitments := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ]) + ] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.read (| + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_fixed_columns" + |) + |)) + ]; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::CurveRead", + C, + [], + "read", + [ R ] + |), + [ M.read (| reader |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::VerifyingKey") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let permutation := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::permutation::VerifyingKey") + [ C ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::permutation::VerifyingKey") + [ C ], + "read", + [ R ] + |), + [ + M.read (| reader |); + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::VerifyingKey") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::VerifyingKey" + [ + ("domain", M.read (| domain |)); + ("fixed_commitments", M.read (| fixed_commitments |)); + ("permutation", M.read (| permutation |)); + ("cs", M.read (| cs |)) + ] + ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_read : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "read" (read C). + + (* + pub fn hash_into, T: Transcript>( + &self, + transcript: &mut T, + ) -> io::Result<()> { + let mut hasher = Blake2bParams::new() + .hash_length(64) + .personal(b"Halo2-Verify-Key") + .to_state(); + + let s = format!("{:?}", self.pinned()); + + hasher.update(&(s.len() as u64).to_le_bytes()); + hasher.update(s.as_bytes()); + + // Hash in final Blake2bState + transcript.common_scalar(C::Scalar::from_bytes_wide(hasher.finalize().as_array()))?; + + Ok(()) + } + *) + Definition hash_into (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ E; T ], [ self; transcript ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let transcript := M.alloc (| transcript |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let hasher := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "blake2b_simd::Params", + "to_state", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "blake2b_simd::Params", + "personal", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "blake2b_simd::Params", + "hash_length", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "blake2b_simd::Params", + "new", + [] + |), + [] + |) + |); + Value.Integer 64 + ] + |); + (* Unsize *) M.pointer_coercion (M.read (| UnsupportedLiteral |)) + ] + |) + ] + |) + |) in + let s := + M.copy (| + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| Value.Array [ M.read (| Value.String "" |) ] |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::PinnedVerificationKey") + [ C ] + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::VerifyingKey") + [ C ], + "pinned", + [] + |), + [ M.read (| self |) ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "blake2b_simd::State", "update", [] |), + [ + hasher; + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u64", "to_le_bytes", [] |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path "alloc::string::String", + "len", + [] + |), + [ s ] + |)) + ] + |) + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "blake2b_simd::State", "update", [] |), + [ + hasher; + M.call_closure (| + M.get_associated_function (| + Ty.path "alloc::string::String", + "as_bytes", + [] + |), + [ s ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ C; E ], + "common_scalar", + [] + |), + [ + M.read (| transcript |); + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::fields::BaseExt", + Ty.associated, + [], + "from_bytes_wide", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "blake2b_simd::Hash", + "as_array", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "blake2b_simd::State", + "finalize", + [] + |), + [ hasher ] + |) + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_hash_into : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "hash_into" (hash_into C). + + (* + pub fn pinned(&self) -> PinnedVerificationKey<'_, C> { + PinnedVerificationKey { + base_modulus: C::Base::MODULUS, + scalar_modulus: C::Scalar::MODULUS, + domain: self.domain.pinned(), + fixed_commitments: &self.fixed_commitments, + permutation: &self.permutation, + cs: self.cs.pinned(), + } + } + *) + Definition pinned (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::plonk::PinnedVerificationKey" + [ + ("base_modulus", + M.read (| + M.get_constant (| "pairing_bn256::arithmetic::fields::BaseExt::MODULUS" |) + |)); + ("scalar_modulus", + M.read (| + M.get_constant (| "pairing_bn256::arithmetic::fields::BaseExt::MODULUS" |) + |)); + ("domain", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "pinned", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |)); + ("fixed_commitments", + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::VerifyingKey", + "fixed_commitments" + |)); + ("permutation", + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::VerifyingKey", + "permutation" + |)); + ("cs", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "pinned", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_pinned : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "pinned" (pinned C). + (* + pub fn get_domain(&self) -> &EvaluationDomain { + &self.domain + } + *) + Definition get_domain (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get_domain : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "get_domain" (get_domain C). + End Impl_halo2_proofs_plonk_VerifyingKey_C. + + (* StructRecord + { + name := "CircuitData"; + ty_params := [ "C" ]; + fields := + [ + ("vkey", Ty.apply (Ty.path "halo2_proofs::plonk::VerifyingKey") [ C ]); + ("fixed", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]; + Ty.path "alloc::alloc::Global" + ]); + ("permutation", Ty.path "halo2_proofs::plonk::permutation::keygen::Assembly") + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_CircuitData_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::CircuitData") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "CircuitData" |); + M.read (| Value.String "vkey" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::CircuitData", + "vkey" + |)); + M.read (| Value.String "fixed" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::CircuitData", + "fixed" + |)); + M.read (| Value.String "permutation" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::CircuitData", + "permutation" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_CircuitData_C. + + Module Impl_halo2_proofs_plonk_CircuitData_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::CircuitData") [ C ]. + + (* + pub fn new>( + params: &Params, + vkey: VerifyingKey, + circuit: &ConcreteCircuit, + ) -> io::Result { + let (fixed, permutation) = generate_pk_info(params, &vkey, circuit).unwrap(); + + Ok(CircuitData { + vkey, + fixed, + permutation, + }) + } + *) + Definition new (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ ConcreteCircuit ], [ params; vkey; circuit ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let vkey := M.alloc (| vkey |) in + let circuit := M.alloc (| circuit |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::permutation::keygen::Assembly" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::keygen::generate_pk_info", + [ C; ConcreteCircuit ] + |), + [ M.read (| params |); vkey; M.read (| circuit |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let fixed := M.copy (| γ0_0 |) in + let permutation := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::CircuitData" + [ + ("vkey", M.read (| vkey |)); + ("fixed", M.read (| fixed |)); + ("permutation", M.read (| permutation |)) + ] + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : forall (C : Ty.t), M.IsAssociatedFunction (Self C) "new" (new C). + + (* + pub fn read_vkey(reader: &mut File) -> io::Result> { + let j = read_u32(reader)?; + let k = read_u32(reader)?; + let domain: EvaluationDomain = EvaluationDomain::new(j, k); + let cs = read_cs::(reader)?; + + let fixed_commitments: Vec<_> = (0..cs.num_fixed_columns) + .map(|_| C::read(reader)) + .collect::>()?; + + let permutation = permutation::VerifyingKey::read(reader, &cs.permutation)?; + + Ok(VerifyingKey { + domain, + cs, + fixed_commitments, + permutation, + }) + } + *) + Definition read_vkey (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let j := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_u32", + [ Ty.path "std::fs::File" ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::VerifyingKey") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let k := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_u32", + [ Ty.path "std::fs::File" ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::VerifyingKey") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let domain := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "new", + [] + |), + [ M.read (| j |); M.read (| k |) ] + |) + |) in + let cs := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::read_cs", + [ C; Ty.path "std::fs::File" ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::VerifyingKey") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let fixed_commitments := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ]) + ] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.read (| + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_fixed_columns" + |) + |)) + ]; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::CurveRead", + C, + [], + "read", + [ Ty.path "std::fs::File" ] + |), + [ M.read (| reader |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::VerifyingKey") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let permutation := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::permutation::VerifyingKey") + [ C ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::permutation::VerifyingKey") + [ C ], + "read", + [ Ty.path "std::fs::File" ] + |), + [ + M.read (| reader |); + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::VerifyingKey") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::VerifyingKey" + [ + ("domain", M.read (| domain |)); + ("cs", M.read (| cs |)); + ("fixed_commitments", M.read (| fixed_commitments |)); + ("permutation", M.read (| permutation |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_read_vkey : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "read_vkey" (read_vkey C). + + (* + pub fn read(reader: &mut File) -> io::Result { + let vkey = Self::read_vkey(reader)?; + + let fixed = Vec::fetch(reader)?; + let permutation = Assembly::vec_fetch(reader)?; + + Ok(CircuitData { + vkey, + fixed, + permutation, + }) + } + *) + Definition read (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let vkey := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::VerifyingKey") [ C ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::CircuitData") [ C ], + "read_vkey", + [] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::CircuitData") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let fixed := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "fetch", + [ Ty.path "std::fs::File" ] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::CircuitData") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let permutation := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::plonk::permutation::keygen::Assembly"; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::ParaSerializable", + Ty.path "halo2_proofs::plonk::permutation::keygen::Assembly", + [], + "vec_fetch", + [] + |), + [ M.read (| reader |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::CircuitData") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::CircuitData" + [ + ("vkey", M.read (| vkey |)); + ("fixed", M.read (| fixed |)); + ("permutation", M.read (| permutation |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_read : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "read" (read C). + + (* + pub fn write(&self, fd: &mut File) -> io::Result<()> { + use std::io::Write; + + let j = (self.vkey.domain.get_quotient_poly_degree() + 1) as u32; // quotient_poly_degree is j-1 + let k = self.vkey.domain.k() as u32; + fd.write(&mut j.to_le_bytes())?; + fd.write(&mut k.to_le_bytes())?; + write_cs::(&self.vkey.cs, fd)?; + + self.vkey.write(fd)?; + + self.fixed.store(fd)?; + self.permutation.vec_store(fd)?; + + Ok(()) + } + *) + Definition write (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; fd ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let fd := M.alloc (| fd |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let j := + M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "get_quotient_poly_degree", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::CircuitData", + "vkey" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |), + Value.Integer 1 + |)) + |) in + let k := + M.copy (| + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "k", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::CircuitData", + "vkey" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |) + |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "std::io::Write", + Ty.path "std::fs::File", + [], + "write", + [] + |), + [ + M.read (| fd |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ M.read (| j |) ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "std::io::Write", + Ty.path "std::fs::File", + [], + "write", + [] + |), + [ + M.read (| fd |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ M.read (| k |) ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::helpers::write_cs", + [ C; Ty.path "std::fs::File" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::CircuitData", + "vkey" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |); + M.read (| fd |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::VerifyingKey") [ C ], + "write", + [ Ty.path "std::fs::File" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::CircuitData", + "vkey" + |); + M.read (| fd |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::Serializable", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "store", + [ Ty.path "std::fs::File" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::CircuitData", + "fixed" + |); + M.read (| fd |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::ParaSerializable", + Ty.path "halo2_proofs::plonk::permutation::keygen::Assembly", + [], + "vec_store", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::CircuitData", + "permutation" + |); + M.read (| fd |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_write : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "write" (write C). + + (* + pub fn into_proving_key(self, params: &Params) -> ProvingKey { + keygen_pk_from_info(params, &self.vkey, self.fixed, self.permutation).unwrap() + } + *) + Definition into_proving_key (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; params ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let params := M.alloc (| params |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::ProvingKey") [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::plonk::keygen::keygen_pk_from_info", [ C ] |), + [ + M.read (| params |); + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::CircuitData", + "vkey" + |); + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::CircuitData", + "fixed" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::CircuitData", + "permutation" + |) + |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_into_proving_key : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "into_proving_key" (into_proving_key C). + + (* + pub fn get_vkey(&self) -> &VerifyingKey { + &self.vkey + } + *) + Definition get_vkey (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::CircuitData", + "vkey" + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get_vkey : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "get_vkey" (get_vkey C). + End Impl_halo2_proofs_plonk_CircuitData_C. + + (* StructRecord + { + name := "PinnedVerificationKey"; + ty_params := [ "C" ]; + fields := + [ + ("base_modulus", Ty.apply (Ty.path "&") [ Ty.path "str" ]); + ("scalar_modulus", Ty.apply (Ty.path "&") [ Ty.path "str" ]); + ("domain", + Ty.apply + (Ty.path "halo2_proofs::poly::domain::PinnedEvaluationDomain") + [ Ty.associated ]); + ("cs", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::PinnedConstraintSystem") + [ Ty.associated ]); + ("fixed_commitments", + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ] ]); + ("permutation", + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "halo2_proofs::plonk::permutation::VerifyingKey") [ C ] ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_PinnedVerificationKey_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::PinnedVerificationKey") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let names := + M.alloc (| + M.alloc (| + Value.Array + [ + M.read (| Value.String "base_modulus" |); + M.read (| Value.String "scalar_modulus" |); + M.read (| Value.String "domain" |); + M.read (| Value.String "cs" |); + M.read (| Value.String "fixed_commitments" |); + M.read (| Value.String "permutation" |) + ] + |) + |) in + let values := + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::PinnedVerificationKey", + "base_modulus" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::PinnedVerificationKey", + "scalar_modulus" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::PinnedVerificationKey", + "domain" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::PinnedVerificationKey", + "cs" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::PinnedVerificationKey", + "fixed_commitments" + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::PinnedVerificationKey", + "permutation" + |) + |)) + ] + |)) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_fields_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "PinnedVerificationKey" |); + (* Unsize *) M.pointer_coercion (M.read (| names |)); + M.read (| values |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_PinnedVerificationKey_C. + + (* StructRecord + { + name := "ProvingKey"; + ty_params := [ "C" ]; + fields := + [ + ("vk", Ty.apply (Ty.path "halo2_proofs::plonk::VerifyingKey") [ C ]); + ("l_active_row", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::ExtendedLagrangeCoeff" ]); + ("l0", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::ExtendedLagrangeCoeff" ]); + ("l_last", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::ExtendedLagrangeCoeff" ]); + ("fixed_values", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]; + Ty.path "alloc::alloc::Global" + ]); + ("fixed_polys", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]; + Ty.path "alloc::alloc::Global" + ]); + ("fixed_cosets", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::ExtendedLagrangeCoeff" ]; + Ty.path "alloc::alloc::Global" + ]); + ("permutation", Ty.apply (Ty.path "halo2_proofs::plonk::permutation::ProvingKey") [ C ]); + ("ev", Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") [ C ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_ProvingKey_C. + Definition Self (C : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::plonk::ProvingKey") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let names := + M.alloc (| + M.alloc (| + Value.Array + [ + M.read (| Value.String "vk" |); + M.read (| Value.String "l_active_row" |); + M.read (| Value.String "l0" |); + M.read (| Value.String "l_last" |); + M.read (| Value.String "fixed_values" |); + M.read (| Value.String "fixed_polys" |); + M.read (| Value.String "fixed_cosets" |); + M.read (| Value.String "permutation" |); + M.read (| Value.String "ev" |) + ] + |) + |) in + let values := + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::ProvingKey", + "l_active_row" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::ProvingKey", + "l0" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::ProvingKey", + "l_last" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::ProvingKey", + "fixed_values" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::ProvingKey", + "fixed_polys" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::ProvingKey", + "fixed_cosets" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::ProvingKey", + "permutation" + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::ProvingKey", + "ev" + |) + |)) + ] + |)) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_fields_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "ProvingKey" |); + (* Unsize *) M.pointer_coercion (M.read (| names |)); + M.read (| values |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_ProvingKey_C. + + Module Impl_halo2_proofs_plonk_ProvingKey_C. + Definition Self (C : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::plonk::ProvingKey") [ C ]. + + (* + pub fn get_vk(&self) -> &VerifyingKey { + &self.vk + } + *) + Definition get_vk (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get_vk : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "get_vk" (get_vk C). + End Impl_halo2_proofs_plonk_ProvingKey_C. + + + (* StructTuple + { + name := "Theta"; + ty_params := []; + fields := []; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_plonk_Theta. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::Theta". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| M.read (| self |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_plonk_Theta. + + Module Impl_core_marker_Copy_for_halo2_proofs_plonk_Theta. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::Theta". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_plonk_Theta. + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_Theta. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::Theta". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ M.read (| f |); M.read (| Value.String "Theta" |) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_Theta. + + Axiom ChallengeTheta : + forall (F : Ty.t), + (Ty.apply (Ty.path "halo2_proofs::plonk::ChallengeTheta") [ F ]) = + (Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ F; Ty.path "halo2_proofs::plonk::Theta" ]). + + (* StructTuple + { + name := "Beta"; + ty_params := []; + fields := []; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_plonk_Beta. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::Beta". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| M.read (| self |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_plonk_Beta. + + Module Impl_core_marker_Copy_for_halo2_proofs_plonk_Beta. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::Beta". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_plonk_Beta. + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_Beta. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::Beta". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ M.read (| f |); M.read (| Value.String "Beta" |) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_Beta. + + Axiom ChallengeBeta : + forall (F : Ty.t), + (Ty.apply (Ty.path "halo2_proofs::plonk::ChallengeBeta") [ F ]) = + (Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ F; Ty.path "halo2_proofs::plonk::Beta" ]). + + (* StructTuple + { + name := "Gamma"; + ty_params := []; + fields := []; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_plonk_Gamma. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::Gamma". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| M.read (| self |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_plonk_Gamma. + + Module Impl_core_marker_Copy_for_halo2_proofs_plonk_Gamma. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::Gamma". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_plonk_Gamma. + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_Gamma. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::Gamma". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ M.read (| f |); M.read (| Value.String "Gamma" |) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_Gamma. + + Axiom ChallengeGamma : + forall (F : Ty.t), + (Ty.apply (Ty.path "halo2_proofs::plonk::ChallengeGamma") [ F ]) = + (Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ F; Ty.path "halo2_proofs::plonk::Gamma" ]). + + (* StructTuple + { + name := "Y"; + ty_params := []; + fields := []; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_plonk_Y. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::Y". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| M.read (| self |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_plonk_Y. + + Module Impl_core_marker_Copy_for_halo2_proofs_plonk_Y. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::Y". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_plonk_Y. + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_Y. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::Y". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ M.read (| f |); M.read (| Value.String "Y" |) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_Y. + + Axiom ChallengeY : + forall (F : Ty.t), + (Ty.apply (Ty.path "halo2_proofs::plonk::ChallengeY") [ F ]) = + (Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ F; Ty.path "halo2_proofs::plonk::Y" ]). + + (* StructTuple + { + name := "X"; + ty_params := []; + fields := []; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_plonk_X. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::X". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| M.read (| self |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_plonk_X. + + Module Impl_core_marker_Copy_for_halo2_proofs_plonk_X. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::X". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_plonk_X. + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_X. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::X". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ M.read (| f |); M.read (| Value.String "X" |) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_X. + + Axiom ChallengeX : + forall (F : Ty.t), + (Ty.apply (Ty.path "halo2_proofs::plonk::ChallengeX") [ F ]) = + (Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ F; Ty.path "halo2_proofs::plonk::X" ]). +End plonk. diff --git a/CoqOfRust/halo2_proofs/plonk/assigned.v b/CoqOfRust/halo2_proofs/plonk/assigned.v new file mode 100644 index 000000000..38cf34be5 --- /dev/null +++ b/CoqOfRust/halo2_proofs/plonk/assigned.v @@ -0,0 +1,1555 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module plonk. + Module assigned. + (* + Enum Assigned + { + ty_params := [ "F" ]; + variants := + [ + { + name := "Zero"; + item := StructTuple []; + discriminant := None; + }; + { + name := "Trivial"; + item := StructTuple [ F ]; + discriminant := None; + }; + { + name := "Rational"; + item := StructTuple [ F; F ]; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_for_halo2_proofs_plonk_assigned_Assigned_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + Value.StructTuple "halo2_proofs::plonk::assigned::Assigned::Zero" [] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Trivial", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::assigned::Assigned::Trivial" + [ + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", F, [], "clone", [] |), + [ M.read (| __self_0 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::assigned::Assigned::Rational" + [ + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", F, [], "clone", [] |), + [ M.read (| __self_0 |) ] + |); + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", F, [], "clone", [] |), + [ M.read (| __self_1 |) ] + |) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_for_halo2_proofs_plonk_assigned_Assigned_F. + + Module Impl_core_marker_Copy_where_core_marker_Copy_F_for_halo2_proofs_plonk_assigned_Assigned_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_F_for_halo2_proofs_plonk_assigned_Assigned_F. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_for_halo2_proofs_plonk_assigned_Assigned_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_str", + [] + |), + [ M.read (| f |); M.read (| Value.String "Zero" |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Trivial", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Trivial" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Rational" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + (* Unsize *) M.pointer_coercion __self_1 + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_for_halo2_proofs_plonk_assigned_Assigned_F. + + Module Impl_core_convert_From_where_ff_Field_F_ref__F_for_halo2_proofs_plonk_assigned_Assigned_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* + fn from(numerator: &F) -> Self { + Assigned::Trivial( *numerator) + } + *) + Definition from (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ numerator ] => + ltac:(M.monadic + (let numerator := M.alloc (| numerator |) in + Value.StructTuple + "halo2_proofs::plonk::assigned::Assigned::Trivial" + [ M.read (| M.read (| numerator |) |) ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::convert::From" + (Self F) + (* Trait polymorphic types *) [ (* T *) Ty.apply (Ty.path "&") [ F ] ] + (* Instance *) [ ("from", InstanceField.Method (from F)) ]. + End Impl_core_convert_From_where_ff_Field_F_ref__F_for_halo2_proofs_plonk_assigned_Assigned_F. + + Module Impl_core_convert_From_where_ff_Field_F_F_for_halo2_proofs_plonk_assigned_Assigned_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* + fn from(numerator: F) -> Self { + Assigned::Trivial(numerator) + } + *) + Definition from (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ numerator ] => + ltac:(M.monadic + (let numerator := M.alloc (| numerator |) in + Value.StructTuple + "halo2_proofs::plonk::assigned::Assigned::Trivial" + [ M.read (| numerator |) ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::convert::From" + (Self F) + (* Trait polymorphic types *) [ (* T *) F ] + (* Instance *) [ ("from", InstanceField.Method (from F)) ]. + End Impl_core_convert_From_where_ff_Field_F_F_for_halo2_proofs_plonk_assigned_Assigned_F. + + Module Impl_core_convert_From_where_ff_Field_F_Tuple_F_F__for_halo2_proofs_plonk_assigned_Assigned_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* + fn from((numerator, denominator): (F, F)) -> Self { + Assigned::Rational(numerator, denominator) + } + *) + Definition from (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ β0 ] => + ltac:(M.monadic + (let β0 := M.alloc (| β0 |) in + M.match_operator (| + β0, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let numerator := M.copy (| γ0_0 |) in + let denominator := M.copy (| γ0_1 |) in + Value.StructTuple + "halo2_proofs::plonk::assigned::Assigned::Rational" + [ M.read (| numerator |); M.read (| denominator |) ])) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::convert::From" + (Self F) + (* Trait polymorphic types *) [ (* T *) Ty.tuple [ F; F ] ] + (* Instance *) [ ("from", InstanceField.Method (from F)) ]. + End Impl_core_convert_From_where_ff_Field_F_Tuple_F_F__for_halo2_proofs_plonk_assigned_Assigned_F. + + Module Impl_core_ops_arith_Neg_where_ff_Field_F_for_halo2_proofs_plonk_assigned_Assigned_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* type Output = Assigned; *) + Definition _Output (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* + fn neg(self) -> Self::Output { + match self { + Self::Zero => Self::Zero, + Self::Trivial(numerator) => Self::Trivial(-numerator), + Self::Rational(numerator, denominator) => Self::Rational(-numerator, denominator), + } + } + *) + Definition neg (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple "halo2_proofs::plonk::assigned::Assigned::Zero" [] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Trivial", + 0 + |) in + let numerator := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::assigned::Assigned::Trivial" + [ + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Neg", F, [], "neg", [] |), + [ M.read (| numerator |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 0 + |) in + let γ0_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 1 + |) in + let numerator := M.copy (| γ0_0 |) in + let denominator := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::assigned::Assigned::Rational" + [ + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Neg", F, [], "neg", [] |), + [ M.read (| numerator |) ] + |); + M.read (| denominator |) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::Neg" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F)); ("neg", InstanceField.Method (neg F)) ]. + End Impl_core_ops_arith_Neg_where_ff_Field_F_for_halo2_proofs_plonk_assigned_Assigned_F. + + Module Impl_core_ops_arith_Add_where_ff_Field_F_for_halo2_proofs_plonk_assigned_Assigned_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* type Output = Assigned; *) + Definition _Output (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* + fn add(self, rhs: Assigned) -> Assigned { + match (self, rhs) { + // One side is directly zero. + (Self::Zero, _) => rhs, + (_, Self::Zero) => self, + + // One side is x/0 which maps to zero. + (Self::Rational(_, denominator), other) | (other, Self::Rational(_, denominator)) + if denominator.is_zero_vartime() => + { + other + } + + // Okay, we need to do some actual math... + (Self::Trivial(lhs), Self::Trivial(rhs)) => Self::Trivial(lhs + rhs), + (Self::Rational(numerator, denominator), Self::Trivial(other)) + | (Self::Trivial(other), Self::Rational(numerator, denominator)) => { + Self::Rational(numerator + denominator * other, denominator) + } + ( + Self::Rational(lhs_numerator, lhs_denominator), + Self::Rational(rhs_numerator, rhs_denominator), + ) => Self::Rational( + lhs_numerator * rhs_denominator + lhs_denominator * rhs_numerator, + lhs_denominator * rhs_denominator, + ), + } + } + *) + Definition add (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| rhs |) ] |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + rhs)); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + self)); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 1 + |) in + let denominator := M.copy (| γ1_1 |) in + let other := M.copy (| γ0_1 |) in + Value.Tuple [ denominator; other ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let other := M.copy (| γ0_0 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 1 + |) in + let denominator := M.copy (| γ1_1 |) in + Value.Tuple [ denominator; other ])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ denominator; other ] => + let γ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "is_zero_vartime", + [] + |), + [ denominator ] + |) + |) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + other + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::assigned::Assigned::Trivial", + 0 + |) in + let lhs := M.copy (| γ1_0 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::assigned::Assigned::Trivial", + 0 + |) in + let rhs := M.copy (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::assigned::Assigned::Trivial" + [ + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Add", F, [ F ], "add", [] |), + [ M.read (| lhs |); M.read (| rhs |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 1 + |) in + let numerator := M.copy (| γ1_0 |) in + let denominator := M.copy (| γ1_1 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::assigned::Assigned::Trivial", + 0 + |) in + let other := M.copy (| γ1_0 |) in + Value.Tuple [ numerator; denominator; other ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::assigned::Assigned::Trivial", + 0 + |) in + let other := M.copy (| γ1_0 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 1 + |) in + let numerator := M.copy (| γ1_0 |) in + let denominator := M.copy (| γ1_1 |) in + Value.Tuple [ numerator; denominator; other ])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ numerator; denominator; other ] => + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::assigned::Assigned::Rational" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + F, + [ F ], + "add", + [] + |), + [ + M.read (| numerator |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ F ], + "mul", + [] + |), + [ M.read (| denominator |); M.read (| other |) ] + |) + ] + |); + M.read (| denominator |) + ] + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 1 + |) in + let lhs_numerator := M.copy (| γ1_0 |) in + let lhs_denominator := M.copy (| γ1_1 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 1 + |) in + let rhs_numerator := M.copy (| γ1_0 |) in + let rhs_denominator := M.copy (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::assigned::Assigned::Rational" + [ + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Add", F, [ F ], "add", [] |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ F ], + "mul", + [] + |), + [ M.read (| lhs_numerator |); M.read (| rhs_denominator |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ F ], + "mul", + [] + |), + [ M.read (| lhs_denominator |); M.read (| rhs_numerator |) ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Mul", F, [ F ], "mul", [] |), + [ M.read (| lhs_denominator |); M.read (| rhs_denominator |) ] + |) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::Add" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F)); ("add", InstanceField.Method (add F)) ]. + End Impl_core_ops_arith_Add_where_ff_Field_F_for_halo2_proofs_plonk_assigned_Assigned_F. + + Module Impl_core_ops_arith_Add_where_ff_Field_F_F_for_halo2_proofs_plonk_assigned_Assigned_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* type Output = Assigned; *) + Definition _Output (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* + fn add(self, rhs: F) -> Assigned { + self + Self::Trivial(rhs) + } + *) + Definition add (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ] ], + "add", + [] + |), + [ + M.read (| self |); + Value.StructTuple + "halo2_proofs::plonk::assigned::Assigned::Trivial" + [ M.read (| rhs |) ] + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::Add" + (Self F) + (* Trait polymorphic types *) [ (* Rhs *) F ] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F)); ("add", InstanceField.Method (add F)) ]. + End Impl_core_ops_arith_Add_where_ff_Field_F_F_for_halo2_proofs_plonk_assigned_Assigned_F. + + Module Impl_core_ops_arith_Sub_where_ff_Field_F_for_halo2_proofs_plonk_assigned_Assigned_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* type Output = Assigned; *) + Definition _Output (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* + fn sub(self, rhs: Assigned) -> Assigned { + self + (-rhs) + } + *) + Definition sub (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ] ], + "add", + [] + |), + [ + M.read (| self |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Neg", + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ], + [], + "neg", + [] + |), + [ M.read (| rhs |) ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::Sub" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F)); ("sub", InstanceField.Method (sub F)) ]. + End Impl_core_ops_arith_Sub_where_ff_Field_F_for_halo2_proofs_plonk_assigned_Assigned_F. + + Module Impl_core_ops_arith_Sub_where_ff_Field_F_F_for_halo2_proofs_plonk_assigned_Assigned_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* type Output = Assigned; *) + Definition _Output (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* + fn sub(self, rhs: F) -> Assigned { + self + (-rhs) + } + *) + Definition sub (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ], + [ F ], + "add", + [] + |), + [ + M.read (| self |); + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Neg", F, [], "neg", [] |), + [ M.read (| rhs |) ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::Sub" + (Self F) + (* Trait polymorphic types *) [ (* Rhs *) F ] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F)); ("sub", InstanceField.Method (sub F)) ]. + End Impl_core_ops_arith_Sub_where_ff_Field_F_F_for_halo2_proofs_plonk_assigned_Assigned_F. + + Module Impl_core_ops_arith_Mul_where_ff_Field_F_for_halo2_proofs_plonk_assigned_Assigned_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* type Output = Assigned; *) + Definition _Output (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* + fn mul(self, rhs: Assigned) -> Assigned { + match (self, rhs) { + (Self::Zero, _) | (_, Self::Zero) => Self::Zero, + (Self::Trivial(lhs), Self::Trivial(rhs)) => Self::Trivial(lhs * rhs), + (Self::Rational(numerator, denominator), Self::Trivial(other)) + | (Self::Trivial(other), Self::Rational(numerator, denominator)) => { + Self::Rational(numerator * other, denominator) + } + ( + Self::Rational(lhs_numerator, lhs_denominator), + Self::Rational(rhs_numerator, rhs_denominator), + ) => Self::Rational( + lhs_numerator * rhs_numerator, + lhs_denominator * rhs_denominator, + ), + } + } + *) + Definition mul (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| rhs |) ] |), + [ + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + Value.Tuple [])); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + Value.Tuple [])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [] => + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::assigned::Assigned::Zero" + [] + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::assigned::Assigned::Trivial", + 0 + |) in + let lhs := M.copy (| γ1_0 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::assigned::Assigned::Trivial", + 0 + |) in + let rhs := M.copy (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::assigned::Assigned::Trivial" + [ + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Mul", F, [ F ], "mul", [] |), + [ M.read (| lhs |); M.read (| rhs |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 1 + |) in + let numerator := M.copy (| γ1_0 |) in + let denominator := M.copy (| γ1_1 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::assigned::Assigned::Trivial", + 0 + |) in + let other := M.copy (| γ1_0 |) in + Value.Tuple [ numerator; denominator; other ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::assigned::Assigned::Trivial", + 0 + |) in + let other := M.copy (| γ1_0 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 1 + |) in + let numerator := M.copy (| γ1_0 |) in + let denominator := M.copy (| γ1_1 |) in + Value.Tuple [ numerator; denominator; other ])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ numerator; denominator; other ] => + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::assigned::Assigned::Rational" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ F ], + "mul", + [] + |), + [ M.read (| numerator |); M.read (| other |) ] + |); + M.read (| denominator |) + ] + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 1 + |) in + let lhs_numerator := M.copy (| γ1_0 |) in + let lhs_denominator := M.copy (| γ1_1 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 1 + |) in + let rhs_numerator := M.copy (| γ1_0 |) in + let rhs_denominator := M.copy (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::assigned::Assigned::Rational" + [ + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Mul", F, [ F ], "mul", [] |), + [ M.read (| lhs_numerator |); M.read (| rhs_numerator |) ] + |); + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Mul", F, [ F ], "mul", [] |), + [ M.read (| lhs_denominator |); M.read (| rhs_denominator |) ] + |) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::Mul" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F)); ("mul", InstanceField.Method (mul F)) ]. + End Impl_core_ops_arith_Mul_where_ff_Field_F_for_halo2_proofs_plonk_assigned_Assigned_F. + + Module Impl_core_ops_arith_Mul_where_ff_Field_F_F_for_halo2_proofs_plonk_assigned_Assigned_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* type Output = Assigned; *) + Definition _Output (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* + fn mul(self, rhs: F) -> Assigned { + self * Self::Trivial(rhs) + } + *) + Definition mul (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ] ], + "mul", + [] + |), + [ + M.read (| self |); + Value.StructTuple + "halo2_proofs::plonk::assigned::Assigned::Trivial" + [ M.read (| rhs |) ] + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::Mul" + (Self F) + (* Trait polymorphic types *) [ (* Rhs *) F ] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F)); ("mul", InstanceField.Method (mul F)) ]. + End Impl_core_ops_arith_Mul_where_ff_Field_F_F_for_halo2_proofs_plonk_assigned_Assigned_F. + + Module Impl_halo2_proofs_plonk_assigned_Assigned_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]. + + (* + pub fn numerator(&self) -> F { + match self { + Self::Zero => F::zero(), + Self::Trivial(x) => *x, + Self::Rational(numerator, _) => *numerator, + } + } + *) + Definition numerator (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "zero", [] |), + [] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Trivial", + 0 + |) in + let x := M.alloc (| γ1_0 |) in + M.read (| x |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 1 + |) in + let numerator := M.alloc (| γ1_0 |) in + M.read (| numerator |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_numerator : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "numerator" (numerator F). + + (* + pub fn denominator(&self) -> Option { + match self { + Self::Zero => None, + Self::Trivial(_) => None, + Self::Rational(_, denominator) => Some( *denominator), + } + } + *) + Definition denominator (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| Value.StructTuple "core::option::Option::None" [] |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Trivial", + 0 + |) in + M.alloc (| Value.StructTuple "core::option::Option::None" [] |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 1 + |) in + let denominator := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ M.read (| M.read (| denominator |) |) ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_denominator : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "denominator" (denominator F). + + (* + pub fn invert(&self) -> Self { + match self { + Self::Zero => Self::Zero, + Self::Trivial(x) => Self::Rational(F::one(), *x), + Self::Rational(numerator, denominator) => Self::Rational( *denominator, *numerator), + } + } + *) + Definition invert (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + Value.StructTuple "halo2_proofs::plonk::assigned::Assigned::Zero" [] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Trivial", + 0 + |) in + let x := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::assigned::Assigned::Rational" + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "one", [] |), + [] + |); + M.read (| M.read (| x |) |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 1 + |) in + let numerator := M.alloc (| γ1_0 |) in + let denominator := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::assigned::Assigned::Rational" + [ + M.read (| M.read (| denominator |) |); + M.read (| M.read (| numerator |) |) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_invert : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "invert" (invert F). + + (* + pub fn evaluate(self) -> F { + match self { + Self::Zero => F::zero(), + Self::Trivial(x) => x, + Self::Rational(numerator, denominator) => { + if denominator == F::one() { + numerator + } else { + numerator * denominator.invert().unwrap_or(F::zero()) + } + } + } + } + *) + Definition evaluate (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "zero", [] |), + [] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Trivial", + 0 + |) in + let x := M.copy (| γ0_0 |) in + x)); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 0 + |) in + let γ0_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::assigned::Assigned::Rational", + 1 + |) in + let numerator := M.copy (| γ0_0 |) in + let denominator := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + F, + [ F ], + "eq", + [] + |), + [ + denominator; + M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "one", [] |), + [] + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + numerator)); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ F ], + "mul", + [] + |), + [ + M.read (| numerator |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "subtle::CtOption") [ F ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "invert", [] |), + [ denominator ] + |); + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "zero", [] |), + [] + |) + ] + |) + ] + |) + |))) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_evaluate : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "evaluate" (evaluate F). + End Impl_halo2_proofs_plonk_assigned_Assigned_F. + End assigned. +End plonk. diff --git a/CoqOfRust/halo2_proofs/plonk/circuit.v b/CoqOfRust/halo2_proofs/plonk/circuit.v new file mode 100644 index 000000000..4f3c02b00 --- /dev/null +++ b/CoqOfRust/halo2_proofs/plonk/circuit.v @@ -0,0 +1,18718 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module plonk. + Module circuit. + (* Trait *) + (* Empty module 'ColumnType' *) + + (* StructRecord + { + name := "Column"; + ty_params := [ "C" ]; + fields := [ ("index", Ty.path "usize"); ("column_type", C) ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_C_where_halo2_proofs_plonk_circuit_ColumnType_C_for_halo2_proofs_plonk_circuit_Column_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Column") [ C ]. + + (* Clone *) + Definition clone (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::plonk::circuit::Column" + [ + ("index", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "usize", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Column", + "index" + |) + ] + |)); + ("column_type", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", C, [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Column", + "column_type" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone C)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_C_where_halo2_proofs_plonk_circuit_ColumnType_C_for_halo2_proofs_plonk_circuit_Column_C. + + Module Impl_core_marker_Copy_where_core_marker_Copy_C_where_halo2_proofs_plonk_circuit_ColumnType_C_for_halo2_proofs_plonk_circuit_Column_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Column") [ C ]. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_C_where_halo2_proofs_plonk_circuit_ColumnType_C_for_halo2_proofs_plonk_circuit_Column_C. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_halo2_proofs_plonk_circuit_ColumnType_C_for_halo2_proofs_plonk_circuit_Column_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Column") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Column" |); + M.read (| Value.String "index" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Column", + "index" + |)); + M.read (| Value.String "column_type" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Column", + "column_type" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_halo2_proofs_plonk_circuit_ColumnType_C_for_halo2_proofs_plonk_circuit_Column_C. + + Module Impl_core_marker_StructuralEq_where_halo2_proofs_plonk_circuit_ColumnType_C_for_halo2_proofs_plonk_circuit_Column_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Column") [ C ]. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::marker::StructuralEq" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralEq_where_halo2_proofs_plonk_circuit_ColumnType_C_for_halo2_proofs_plonk_circuit_Column_C. + + Module Impl_core_cmp_Eq_where_core_cmp_Eq_C_where_halo2_proofs_plonk_circuit_ColumnType_C_for_halo2_proofs_plonk_circuit_Column_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Column") [ C ]. + + (* Eq *) + Definition assert_receiver_is_total_eq (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::cmp::Eq" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("assert_receiver_is_total_eq", InstanceField.Method (assert_receiver_is_total_eq C)) ]. + End Impl_core_cmp_Eq_where_core_cmp_Eq_C_where_halo2_proofs_plonk_circuit_ColumnType_C_for_halo2_proofs_plonk_circuit_Column_C. + + Module Impl_core_marker_StructuralPartialEq_where_halo2_proofs_plonk_circuit_ColumnType_C_for_halo2_proofs_plonk_circuit_Column_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Column") [ C ]. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::marker::StructuralPartialEq" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_where_halo2_proofs_plonk_circuit_ColumnType_C_for_halo2_proofs_plonk_circuit_Column_C. + + Module Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_C_where_halo2_proofs_plonk_circuit_ColumnType_C_for_halo2_proofs_plonk_circuit_Column_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Column") [ C ]. + + (* PartialEq *) + Definition eq (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + LogicalOp.and (| + BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Column", + "index" + |) + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::plonk::circuit::Column", + "index" + |) + |)), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| "core::cmp::PartialEq", C, [ C ], "eq", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Column", + "column_type" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::plonk::circuit::Column", + "column_type" + |) + ] + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::cmp::PartialEq" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method (eq C)) ]. + End Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_C_where_halo2_proofs_plonk_circuit_ColumnType_C_for_halo2_proofs_plonk_circuit_Column_C. + + Module Impl_core_hash_Hash_where_core_hash_Hash_C_where_halo2_proofs_plonk_circuit_ColumnType_C_for_halo2_proofs_plonk_circuit_Column_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Column") [ C ]. + + (* Hash *) + Definition hash (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ __H ], [ self; state ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let state := M.alloc (| state |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::hash::Hash", + Ty.path "usize", + [], + "hash", + [ __H ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Column", + "index" + |); + M.read (| state |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::hash::Hash", C, [], "hash", [ __H ] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Column", + "column_type" + |); + M.read (| state |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::hash::Hash" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("hash", InstanceField.Method (hash C)) ]. + End Impl_core_hash_Hash_where_core_hash_Hash_C_where_halo2_proofs_plonk_circuit_ColumnType_C_for_halo2_proofs_plonk_circuit_Column_C. + + Module Impl_halo2_proofs_plonk_circuit_Column_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Column") [ C ]. + + (* + pub fn new(index: usize, column_type: C) -> Self { + Column { index, column_type } + } + *) + Definition new (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ index; column_type ] => + ltac:(M.monadic + (let index := M.alloc (| index |) in + let column_type := M.alloc (| column_type |) in + Value.StructRecord + "halo2_proofs::plonk::circuit::Column" + [ ("index", M.read (| index |)); ("column_type", M.read (| column_type |)) ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "new" (new C). + + (* + pub fn index(&self) -> usize { + self.index + } + *) + Definition index (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Column", + "index" + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_index : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "index" (index C). + + (* + pub fn column_type(&self) -> &C { + &self.column_type + } + *) + Definition column_type (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Column", + "column_type" + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_column_type : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "column_type" (column_type C). + End Impl_halo2_proofs_plonk_circuit_Column_C. + + Module Impl_core_cmp_Ord_where_halo2_proofs_plonk_circuit_ColumnType_C_for_halo2_proofs_plonk_circuit_Column_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Column") [ C ]. + + (* + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + // This ordering is consensus-critical! The layouters rely on deterministic column + // orderings. + match self.column_type.into().cmp(&other.column_type.into()) { + // Indices are assigned within column types. + std::cmp::Ordering::Equal => self.index.cmp(&other.index), + order => order, + } + } + *) + Definition cmp (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path "halo2_proofs::plonk::circuit::Any", + [], + "cmp", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + C, + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Column", + "column_type" + |) + |) + ] + |) + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + C, + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::plonk::circuit::Column", + "column_type" + |) + |) + ] + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::cmp::Ord", Ty.path "usize", [], "cmp", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Column", + "index" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::plonk::circuit::Column", + "index" + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let order := M.copy (| γ |) in + order)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::cmp::Ord" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("cmp", InstanceField.Method (cmp C)) ]. + End Impl_core_cmp_Ord_where_halo2_proofs_plonk_circuit_ColumnType_C_for_halo2_proofs_plonk_circuit_Column_C. + + Module Impl_core_cmp_PartialOrd_where_halo2_proofs_plonk_circuit_ColumnType_C_for_halo2_proofs_plonk_circuit_Column_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Column") [ C ]. + + (* + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } + *) + Definition partial_cmp (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Column") [ C ], + [], + "cmp", + [] + |), + [ M.read (| self |); M.read (| other |) ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::cmp::PartialOrd" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("partial_cmp", InstanceField.Method (partial_cmp C)) ]. + End Impl_core_cmp_PartialOrd_where_halo2_proofs_plonk_circuit_ColumnType_C_for_halo2_proofs_plonk_circuit_Column_C. + + (* StructTuple + { + name := "Advice"; + ty_params := []; + fields := []; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_plonk_circuit_Advice. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Advice". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| M.read (| self |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_plonk_circuit_Advice. + + Module Impl_core_marker_Copy_for_halo2_proofs_plonk_circuit_Advice. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Advice". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_plonk_circuit_Advice. + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_circuit_Advice. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Advice". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ M.read (| f |); M.read (| Value.String "Advice" |) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_circuit_Advice. + + Module Impl_core_marker_StructuralEq_for_halo2_proofs_plonk_circuit_Advice. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Advice". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralEq_for_halo2_proofs_plonk_circuit_Advice. + + Module Impl_core_cmp_Eq_for_halo2_proofs_plonk_circuit_Advice. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Advice". + + (* Eq *) + Definition assert_receiver_is_total_eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.Tuple [])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Eq" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("assert_receiver_is_total_eq", InstanceField.Method assert_receiver_is_total_eq) ]. + End Impl_core_cmp_Eq_for_halo2_proofs_plonk_circuit_Advice. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_plonk_circuit_Advice. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Advice". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_plonk_circuit_Advice. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_plonk_circuit_Advice. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Advice". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + Value.Bool true)) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_plonk_circuit_Advice. + + Module Impl_core_hash_Hash_for_halo2_proofs_plonk_circuit_Advice. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Advice". + + (* Hash *) + Definition hash (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ __H ], [ self; state ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let state := M.alloc (| state |) in + Value.Tuple [])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::hash::Hash" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("hash", InstanceField.Method hash) ]. + End Impl_core_hash_Hash_for_halo2_proofs_plonk_circuit_Advice. + + (* StructTuple + { + name := "Fixed"; + ty_params := []; + fields := []; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_plonk_circuit_Fixed. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Fixed". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| M.read (| self |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_plonk_circuit_Fixed. + + Module Impl_core_marker_Copy_for_halo2_proofs_plonk_circuit_Fixed. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Fixed". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_plonk_circuit_Fixed. + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_circuit_Fixed. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Fixed". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ M.read (| f |); M.read (| Value.String "Fixed" |) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_circuit_Fixed. + + Module Impl_core_marker_StructuralEq_for_halo2_proofs_plonk_circuit_Fixed. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Fixed". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralEq_for_halo2_proofs_plonk_circuit_Fixed. + + Module Impl_core_cmp_Eq_for_halo2_proofs_plonk_circuit_Fixed. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Fixed". + + (* Eq *) + Definition assert_receiver_is_total_eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.Tuple [])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Eq" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("assert_receiver_is_total_eq", InstanceField.Method assert_receiver_is_total_eq) ]. + End Impl_core_cmp_Eq_for_halo2_proofs_plonk_circuit_Fixed. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_plonk_circuit_Fixed. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Fixed". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_plonk_circuit_Fixed. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_plonk_circuit_Fixed. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Fixed". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + Value.Bool true)) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_plonk_circuit_Fixed. + + Module Impl_core_hash_Hash_for_halo2_proofs_plonk_circuit_Fixed. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Fixed". + + (* Hash *) + Definition hash (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ __H ], [ self; state ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let state := M.alloc (| state |) in + Value.Tuple [])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::hash::Hash" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("hash", InstanceField.Method hash) ]. + End Impl_core_hash_Hash_for_halo2_proofs_plonk_circuit_Fixed. + + (* StructTuple + { + name := "Instance"; + ty_params := []; + fields := []; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_plonk_circuit_Instance. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Instance". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| M.read (| self |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_plonk_circuit_Instance. + + Module Impl_core_marker_Copy_for_halo2_proofs_plonk_circuit_Instance. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Instance". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_plonk_circuit_Instance. + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_circuit_Instance. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Instance". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ M.read (| f |); M.read (| Value.String "Instance" |) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_circuit_Instance. + + Module Impl_core_marker_StructuralEq_for_halo2_proofs_plonk_circuit_Instance. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Instance". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralEq_for_halo2_proofs_plonk_circuit_Instance. + + Module Impl_core_cmp_Eq_for_halo2_proofs_plonk_circuit_Instance. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Instance". + + (* Eq *) + Definition assert_receiver_is_total_eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.Tuple [])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Eq" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("assert_receiver_is_total_eq", InstanceField.Method assert_receiver_is_total_eq) ]. + End Impl_core_cmp_Eq_for_halo2_proofs_plonk_circuit_Instance. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_plonk_circuit_Instance. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Instance". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_plonk_circuit_Instance. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_plonk_circuit_Instance. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Instance". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + Value.Bool true)) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_plonk_circuit_Instance. + + Module Impl_core_hash_Hash_for_halo2_proofs_plonk_circuit_Instance. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Instance". + + (* Hash *) + Definition hash (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ __H ], [ self; state ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let state := M.alloc (| state |) in + Value.Tuple [])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::hash::Hash" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("hash", InstanceField.Method hash) ]. + End Impl_core_hash_Hash_for_halo2_proofs_plonk_circuit_Instance. + + (* + Enum Any + { + ty_params := []; + variants := + [ + { + name := "Advice"; + item := StructTuple []; + discriminant := None; + }; + { + name := "Fixed"; + item := StructTuple []; + discriminant := None; + }; + { + name := "Instance"; + item := StructTuple []; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_clone_Clone_for_halo2_proofs_plonk_circuit_Any. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Any". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| M.read (| self |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_plonk_circuit_Any. + + Module Impl_core_marker_Copy_for_halo2_proofs_plonk_circuit_Any. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Any". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_plonk_circuit_Any. + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_circuit_Any. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Any". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ + M.read (| f |); + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| M.read (| Value.String "Advice" |) |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| M.read (| Value.String "Fixed" |) |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| M.read (| Value.String "Instance" |) |))) + ] + |) + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_circuit_Any. + + Module Impl_core_marker_StructuralEq_for_halo2_proofs_plonk_circuit_Any. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Any". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralEq_for_halo2_proofs_plonk_circuit_Any. + + Module Impl_core_cmp_Eq_for_halo2_proofs_plonk_circuit_Any. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Any". + + (* Eq *) + Definition assert_receiver_is_total_eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.Tuple [])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Eq" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("assert_receiver_is_total_eq", InstanceField.Method assert_receiver_is_total_eq) ]. + End Impl_core_cmp_Eq_for_halo2_proofs_plonk_circuit_Any. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_plonk_circuit_Any. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Any". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_plonk_circuit_Any. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_plonk_circuit_Any. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Any". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + |), + [ M.read (| other |) ] + |) + |) in + M.alloc (| BinOp.Pure.eq (M.read (| __self_tag |)) (M.read (| __arg1_tag |)) |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_plonk_circuit_Any. + + Module Impl_core_hash_Hash_for_halo2_proofs_plonk_circuit_Any. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Any". + + (* Hash *) + Definition hash (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ __H ], [ self; state ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let state := M.alloc (| state |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + |), + [ M.read (| self |) ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::hash::Hash", Ty.path "isize", [], "hash", [ __H ] |), + [ __self_tag; M.read (| state |) ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::hash::Hash" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("hash", InstanceField.Method hash) ]. + End Impl_core_hash_Hash_for_halo2_proofs_plonk_circuit_Any. + + Module Impl_core_cmp_Ord_for_halo2_proofs_plonk_circuit_Any. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Any". + + (* + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + // This ordering is consensus-critical! The layouters rely on deterministic column + // orderings. + match (self, other) { + (Any::Instance, Any::Instance) + | (Any::Advice, Any::Advice) + | (Any::Fixed, Any::Fixed) => std::cmp::Ordering::Equal, + // Across column types, sort Instance < Advice < Fixed. + (Any::Instance, Any::Advice) + | (Any::Advice, Any::Fixed) + | (Any::Instance, Any::Fixed) => std::cmp::Ordering::Less, + (Any::Fixed, Any::Instance) + | (Any::Fixed, Any::Advice) + | (Any::Advice, Any::Instance) => std::cmp::Ordering::Greater, + } + } + *) + Definition cmp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| other |) ] |), + [ + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + Value.Tuple [])); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + Value.Tuple [])); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + Value.Tuple [])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [] => + M.alloc (| Value.StructTuple "core::cmp::Ordering::Equal" [] |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + Value.Tuple [])); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + Value.Tuple [])); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + Value.Tuple [])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [] => M.alloc (| Value.StructTuple "core::cmp::Ordering::Less" [] |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + Value.Tuple [])); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + Value.Tuple [])); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + Value.Tuple [])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [] => + M.alloc (| Value.StructTuple "core::cmp::Ordering::Greater" [] |) + | _ => M.impossible (||) + end)) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Ord" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("cmp", InstanceField.Method cmp) ]. + End Impl_core_cmp_Ord_for_halo2_proofs_plonk_circuit_Any. + + Module Impl_core_cmp_PartialOrd_for_halo2_proofs_plonk_circuit_Any. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Any". + + (* + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } + *) + Definition partial_cmp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path "halo2_proofs::plonk::circuit::Any", + [], + "cmp", + [] + |), + [ M.read (| self |); M.read (| other |) ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialOrd" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("partial_cmp", InstanceField.Method partial_cmp) ]. + End Impl_core_cmp_PartialOrd_for_halo2_proofs_plonk_circuit_Any. + + Module Impl_halo2_proofs_plonk_circuit_ColumnType_for_halo2_proofs_plonk_circuit_Advice. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Advice". + + Axiom Implements : + M.IsTraitInstance + "halo2_proofs::plonk::circuit::ColumnType" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_halo2_proofs_plonk_circuit_ColumnType_for_halo2_proofs_plonk_circuit_Advice. + + Module Impl_halo2_proofs_plonk_circuit_ColumnType_for_halo2_proofs_plonk_circuit_Fixed. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Fixed". + + Axiom Implements : + M.IsTraitInstance + "halo2_proofs::plonk::circuit::ColumnType" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_halo2_proofs_plonk_circuit_ColumnType_for_halo2_proofs_plonk_circuit_Fixed. + + Module Impl_halo2_proofs_plonk_circuit_ColumnType_for_halo2_proofs_plonk_circuit_Instance. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Instance". + + Axiom Implements : + M.IsTraitInstance + "halo2_proofs::plonk::circuit::ColumnType" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_halo2_proofs_plonk_circuit_ColumnType_for_halo2_proofs_plonk_circuit_Instance. + + Module Impl_halo2_proofs_plonk_circuit_ColumnType_for_halo2_proofs_plonk_circuit_Any. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Any". + + Axiom Implements : + M.IsTraitInstance + "halo2_proofs::plonk::circuit::ColumnType" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_halo2_proofs_plonk_circuit_ColumnType_for_halo2_proofs_plonk_circuit_Any. + + Module Impl_core_convert_From_halo2_proofs_plonk_circuit_Advice_for_halo2_proofs_plonk_circuit_Any. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Any". + + (* + fn from(_: Advice) -> Any { + Any::Advice + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ β0 ] => + ltac:(M.monadic + (let β0 := M.alloc (| β0 |) in + M.match_operator (| + β0, + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple "halo2_proofs::plonk::circuit::Any::Advice" [])) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) [ (* T *) Ty.path "halo2_proofs::plonk::circuit::Advice" ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_halo2_proofs_plonk_circuit_Advice_for_halo2_proofs_plonk_circuit_Any. + + Module Impl_core_convert_From_halo2_proofs_plonk_circuit_Fixed_for_halo2_proofs_plonk_circuit_Any. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Any". + + (* + fn from(_: Fixed) -> Any { + Any::Fixed + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ β0 ] => + ltac:(M.monadic + (let β0 := M.alloc (| β0 |) in + M.match_operator (| + β0, + [ + fun γ => + ltac:(M.monadic (Value.StructTuple "halo2_proofs::plonk::circuit::Any::Fixed" [])) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) [ (* T *) Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_halo2_proofs_plonk_circuit_Fixed_for_halo2_proofs_plonk_circuit_Any. + + Module Impl_core_convert_From_halo2_proofs_plonk_circuit_Instance_for_halo2_proofs_plonk_circuit_Any. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Any". + + (* + fn from(_: Instance) -> Any { + Any::Instance + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ β0 ] => + ltac:(M.monadic + (let β0 := M.alloc (| β0 |) in + M.match_operator (| + β0, + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple "halo2_proofs::plonk::circuit::Any::Instance" [])) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) [ (* T *) Ty.path "halo2_proofs::plonk::circuit::Instance" ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_halo2_proofs_plonk_circuit_Instance_for_halo2_proofs_plonk_circuit_Any. + + Module Impl_core_convert_From_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Advice_for_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Any. + Definition Self : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]. + + (* + fn from(advice: Column) -> Column { + Column { + index: advice.index(), + column_type: Any::Advice, + } + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ advice ] => + ltac:(M.monadic + (let advice := M.alloc (| advice |) in + Value.StructRecord + "halo2_proofs::plonk::circuit::Column" + [ + ("index", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + "index", + [] + |), + [ advice ] + |)); + ("column_type", Value.StructTuple "halo2_proofs::plonk::circuit::Any::Advice" []) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) + [ + (* T *) + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Advice_for_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Any. + + Module Impl_core_convert_From_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Fixed_for_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Any. + Definition Self : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]. + + (* + fn from(advice: Column) -> Column { + Column { + index: advice.index(), + column_type: Any::Fixed, + } + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ advice ] => + ltac:(M.monadic + (let advice := M.alloc (| advice |) in + Value.StructRecord + "halo2_proofs::plonk::circuit::Column" + [ + ("index", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + "index", + [] + |), + [ advice ] + |)); + ("column_type", Value.StructTuple "halo2_proofs::plonk::circuit::Any::Fixed" []) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) + [ + (* T *) + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Fixed_for_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Any. + + Module Impl_core_convert_From_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Instance_for_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Any. + Definition Self : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]. + + (* + fn from(advice: Column) -> Column { + Column { + index: advice.index(), + column_type: Any::Instance, + } + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ advice ] => + ltac:(M.monadic + (let advice := M.alloc (| advice |) in + Value.StructRecord + "halo2_proofs::plonk::circuit::Column" + [ + ("index", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ], + "index", + [] + |), + [ advice ] + |)); + ("column_type", Value.StructTuple "halo2_proofs::plonk::circuit::Any::Instance" []) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) + [ + (* T *) + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ] + ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Instance_for_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Any. + + Module Impl_core_convert_TryFrom_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Any_for_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Advice. + Definition Self : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]. + + (* type Error = &'static str; *) + Definition _Error : Ty.t := Ty.apply (Ty.path "&") [ Ty.path "str" ]. + + (* + fn try_from(any: Column) -> Result { + match any.column_type() { + Any::Advice => Ok(Column { + index: any.index(), + column_type: Advice, + }), + _ => Err("Cannot convert into Column"), + } + } + *) + Definition try_from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ any ] => + ltac:(M.monadic + (let any := M.alloc (| any |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + "column_type", + [] + |), + [ any ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::circuit::Column" + [ + ("index", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + "index", + [] + |), + [ any ] + |)); + ("column_type", + Value.StructTuple "halo2_proofs::plonk::circuit::Advice" []) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::result::Result::Err" + [ M.read (| Value.String "Cannot convert into Column" |) ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::TryFrom" + Self + (* Trait polymorphic types *) + [ + (* T *) + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ] + (* Instance *) + [ ("Error", InstanceField.Ty _Error); ("try_from", InstanceField.Method try_from) ]. + End Impl_core_convert_TryFrom_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Any_for_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Advice. + + Module Impl_core_convert_TryFrom_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Any_for_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Fixed. + Definition Self : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]. + + (* type Error = &'static str; *) + Definition _Error : Ty.t := Ty.apply (Ty.path "&") [ Ty.path "str" ]. + + (* + fn try_from(any: Column) -> Result { + match any.column_type() { + Any::Fixed => Ok(Column { + index: any.index(), + column_type: Fixed, + }), + _ => Err("Cannot convert into Column"), + } + } + *) + Definition try_from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ any ] => + ltac:(M.monadic + (let any := M.alloc (| any |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + "column_type", + [] + |), + [ any ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::circuit::Column" + [ + ("index", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + "index", + [] + |), + [ any ] + |)); + ("column_type", + Value.StructTuple "halo2_proofs::plonk::circuit::Fixed" []) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::result::Result::Err" + [ M.read (| Value.String "Cannot convert into Column" |) ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::TryFrom" + Self + (* Trait polymorphic types *) + [ + (* T *) + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ] + (* Instance *) + [ ("Error", InstanceField.Ty _Error); ("try_from", InstanceField.Method try_from) ]. + End Impl_core_convert_TryFrom_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Any_for_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Fixed. + + Module Impl_core_convert_TryFrom_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Any_for_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Instance. + Definition Self : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ]. + + (* type Error = &'static str; *) + Definition _Error : Ty.t := Ty.apply (Ty.path "&") [ Ty.path "str" ]. + + (* + fn try_from(any: Column) -> Result { + match any.column_type() { + Any::Instance => Ok(Column { + index: any.index(), + column_type: Instance, + }), + _ => Err("Cannot convert into Column"), + } + } + *) + Definition try_from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ any ] => + ltac:(M.monadic + (let any := M.alloc (| any |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + "column_type", + [] + |), + [ any ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::circuit::Column" + [ + ("index", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + "index", + [] + |), + [ any ] + |)); + ("column_type", + Value.StructTuple "halo2_proofs::plonk::circuit::Instance" []) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::result::Result::Err" + [ M.read (| Value.String "Cannot convert into Column" |) ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::TryFrom" + Self + (* Trait polymorphic types *) + [ + (* T *) + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ] + (* Instance *) + [ ("Error", InstanceField.Ty _Error); ("try_from", InstanceField.Method try_from) ]. + End Impl_core_convert_TryFrom_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Any_for_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Instance. + + (* StructTuple + { + name := "Selector"; + ty_params := []; + fields := [ Ty.path "usize"; Ty.path "bool" ]; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_plonk_circuit_Selector. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Selector". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.read (| self |))) ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_plonk_circuit_Selector. + + Module Impl_core_marker_Copy_for_halo2_proofs_plonk_circuit_Selector. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Selector". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_plonk_circuit_Selector. + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_circuit_Selector. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Selector". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Selector" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Selector", + 0 + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Selector", + 1 + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_circuit_Selector. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_plonk_circuit_Selector. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Selector". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_plonk_circuit_Selector. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_plonk_circuit_Selector. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Selector". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + LogicalOp.and (| + BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Selector", + 0 + |) + |)) + (M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| other |), + "halo2_proofs::plonk::circuit::Selector", + 0 + |) + |)), + ltac:(M.monadic + (BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Selector", + 1 + |) + |)) + (M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| other |), + "halo2_proofs::plonk::circuit::Selector", + 1 + |) + |)))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_plonk_circuit_Selector. + + Module Impl_core_marker_StructuralEq_for_halo2_proofs_plonk_circuit_Selector. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Selector". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralEq_for_halo2_proofs_plonk_circuit_Selector. + + Module Impl_core_cmp_Eq_for_halo2_proofs_plonk_circuit_Selector. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Selector". + + (* Eq *) + Definition assert_receiver_is_total_eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Eq" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("assert_receiver_is_total_eq", InstanceField.Method assert_receiver_is_total_eq) ]. + End Impl_core_cmp_Eq_for_halo2_proofs_plonk_circuit_Selector. + + Module Impl_core_hash_Hash_for_halo2_proofs_plonk_circuit_Selector. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Selector". + + (* Hash *) + Definition hash (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ __H ], [ self; state ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let state := M.alloc (| state |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::hash::Hash", + Ty.path "usize", + [], + "hash", + [ __H ] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Selector", + 0 + |); + M.read (| state |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::hash::Hash", Ty.path "bool", [], "hash", [ __H ] |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Selector", + 1 + |); + M.read (| state |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::hash::Hash" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("hash", InstanceField.Method hash) ]. + End Impl_core_hash_Hash_for_halo2_proofs_plonk_circuit_Selector. + + Module Impl_halo2_proofs_plonk_circuit_Selector. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::Selector". + + (* + pub fn enable(&self, region: &Region, offset: usize) -> Result<(), Error> { + region.enable_selector(|| "", self, offset) + } + *) + Definition enable (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ self; region; offset ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let region := M.alloc (| region |) in + let offset := M.alloc (| offset |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "enable_selector", + [ + Ty.function [ Ty.tuple [] ] (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| region |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ fun γ => ltac:(M.monadic (M.read (| Value.String "" |))) ] + |) + | _ => M.impossible (||) + end)); + M.read (| self |); + M.read (| offset |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_enable : M.IsAssociatedFunction Self "enable" enable. + + (* + pub fn is_simple(&self) -> bool { + self.1 + } + *) + Definition is_simple (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Selector", + 1 + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_is_simple : M.IsAssociatedFunction Self "is_simple" is_simple. + End Impl_halo2_proofs_plonk_circuit_Selector. + + (* StructRecord + { + name := "TableColumn"; + ty_params := []; + fields := + [ + ("inner", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]) + ]; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_plonk_circuit_TableColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::TableColumn". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.read (| self |))) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_plonk_circuit_TableColumn. + + Module Impl_core_marker_Copy_for_halo2_proofs_plonk_circuit_TableColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::TableColumn". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_plonk_circuit_TableColumn. + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_circuit_TableColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::TableColumn". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "TableColumn" |); + M.read (| Value.String "inner" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::TableColumn", + "inner" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_circuit_TableColumn. + + Module Impl_core_marker_StructuralEq_for_halo2_proofs_plonk_circuit_TableColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::TableColumn". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralEq_for_halo2_proofs_plonk_circuit_TableColumn. + + Module Impl_core_cmp_Eq_for_halo2_proofs_plonk_circuit_TableColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::TableColumn". + + (* Eq *) + Definition assert_receiver_is_total_eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Eq" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("assert_receiver_is_total_eq", InstanceField.Method assert_receiver_is_total_eq) ]. + End Impl_core_cmp_Eq_for_halo2_proofs_plonk_circuit_TableColumn. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_plonk_circuit_TableColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::TableColumn". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_plonk_circuit_TableColumn. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_plonk_circuit_TableColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::TableColumn". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::TableColumn", + "inner" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::plonk::circuit::TableColumn", + "inner" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_plonk_circuit_TableColumn. + + Module Impl_core_hash_Hash_for_halo2_proofs_plonk_circuit_TableColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::TableColumn". + + (* Hash *) + Definition hash (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ __H ], [ self; state ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let state := M.alloc (| state |) in + M.call_closure (| + M.get_trait_method (| + "core::hash::Hash", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [], + "hash", + [ __H ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::TableColumn", + "inner" + |); + M.read (| state |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::hash::Hash" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("hash", InstanceField.Method hash) ]. + End Impl_core_hash_Hash_for_halo2_proofs_plonk_circuit_TableColumn. + + Module Impl_halo2_proofs_plonk_circuit_TableColumn. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::TableColumn". + + (* + pub(crate) fn inner(&self) -> Column { + self.inner + } + *) + Definition inner (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::TableColumn", + "inner" + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_inner : M.IsAssociatedFunction Self "inner" inner. + End Impl_halo2_proofs_plonk_circuit_TableColumn. + + (* Trait *) + (* Empty module 'Assignment' *) + + (* Trait *) + (* Empty module 'FloorPlanner' *) + + (* Trait *) + (* Empty module 'Circuit' *) + + (* + Enum Expression + { + ty_params := [ "F" ]; + variants := + [ + { + name := "Constant"; + item := StructTuple [ F ]; + discriminant := None; + }; + { + name := "Selector"; + item := StructTuple [ Ty.path "halo2_proofs::plonk::circuit::Selector" ]; + discriminant := None; + }; + { + name := "Fixed"; + item := + StructRecord + [ + ("query_index", Ty.path "usize"); + ("column_index", Ty.path "usize"); + ("rotation", Ty.path "halo2_proofs::poly::Rotation") + ]; + discriminant := None; + }; + { + name := "Advice"; + item := + StructRecord + [ + ("query_index", Ty.path "usize"); + ("column_index", Ty.path "usize"); + ("rotation", Ty.path "halo2_proofs::poly::Rotation") + ]; + discriminant := None; + }; + { + name := "Instance"; + item := + StructRecord + [ + ("query_index", Ty.path "usize"); + ("column_index", Ty.path "usize"); + ("rotation", Ty.path "halo2_proofs::poly::Rotation") + ]; + discriminant := None; + }; + { + name := "Negated"; + item := + StructTuple + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ] + ]; + discriminant := None; + }; + { + name := "Sum"; + item := + StructTuple + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ] + ]; + discriminant := None; + }; + { + name := "Product"; + item := + StructTuple + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ] + ]; + discriminant := None; + }; + { + name := "Scaled"; + item := + StructTuple + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + F + ]; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_for_halo2_proofs_plonk_circuit_Expression_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Constant", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", F, [], "clone", [] |), + [ M.read (| __self_0 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Selector", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Selector" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::circuit::Selector", + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "rotation" + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + let __self_2 := M.alloc (| γ1_2 |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::circuit::Expression::Fixed" + [ + ("query_index", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "usize", + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |)); + ("column_index", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "usize", + [], + "clone", + [] + |), + [ M.read (| __self_1 |) ] + |)); + ("rotation", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::poly::Rotation", + [], + "clone", + [] + |), + [ M.read (| __self_2 |) ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "rotation" + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + let __self_2 := M.alloc (| γ1_2 |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::circuit::Expression::Advice" + [ + ("query_index", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "usize", + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |)); + ("column_index", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "usize", + [], + "clone", + [] + |), + [ M.read (| __self_1 |) ] + |)); + ("rotation", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::poly::Rotation", + [], + "clone", + [] + |), + [ M.read (| __self_2 |) ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "rotation" + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + let __self_2 := M.alloc (| γ1_2 |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::circuit::Expression::Instance" + [ + ("query_index", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "usize", + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |)); + ("column_index", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "usize", + [], + "clone", + [] + |), + [ M.read (| __self_1 |) ] + |)); + ("rotation", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::poly::Rotation", + [], + "clone", + [] + |), + [ M.read (| __self_2 |) ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Negated", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Negated" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Sum" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ M.read (| __self_1 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Product" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ M.read (| __self_1 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Scaled" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |); + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", F, [], "clone", [] |), + [ M.read (| __self_1 |) ] + |) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_for_halo2_proofs_plonk_circuit_Expression_F. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_for_halo2_proofs_plonk_circuit_Expression_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Constant", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Constant" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Selector", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Selector" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "rotation" + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + let __self_2 := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Fixed" |); + M.read (| Value.String "query_index" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + M.read (| Value.String "column_index" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_1 |)); + M.read (| Value.String "rotation" |); + (* Unsize *) M.pointer_coercion __self_2 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "rotation" + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + let __self_2 := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Advice" |); + M.read (| Value.String "query_index" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + M.read (| Value.String "column_index" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_1 |)); + M.read (| Value.String "rotation" |); + (* Unsize *) M.pointer_coercion __self_2 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "rotation" + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + let __self_2 := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Instance" |); + M.read (| Value.String "query_index" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + M.read (| Value.String "column_index" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_1 |)); + M.read (| Value.String "rotation" |); + (* Unsize *) M.pointer_coercion __self_2 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Negated", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Negated" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Sum" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + (* Unsize *) M.pointer_coercion __self_1 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Product" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + (* Unsize *) M.pointer_coercion __self_1 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Scaled" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + (* Unsize *) M.pointer_coercion __self_1 + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_for_halo2_proofs_plonk_circuit_Expression_F. + + Module Impl_halo2_proofs_plonk_circuit_Expression_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]. + + (* + pub fn is_constant(&self) -> Option { + match self { + Expression::Constant(c) => Some( *c), + _ => None, + } + } + *) + Definition is_constant (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Constant", + 0 + |) in + let c := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ M.read (| M.read (| c |) |) ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "core::option::Option::None" [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_is_constant : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "is_constant" (is_constant F). + + (* + pub fn is_pure_fixed(&self) -> Option { + match self { + Expression::Fixed { + column_index, + rotation, + .. + } => { + if rotation.0 == 0 { + Some( *column_index) + } else { + None + } + } + _ => None, + } + } + *) + Definition is_pure_fixed (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "column_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "rotation" + |) in + let column_index := M.alloc (| γ1_0 |) in + let rotation := M.alloc (| γ1_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| rotation |), + "halo2_proofs::poly::Rotation", + 0 + |) + |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ M.read (| M.read (| column_index |) |) ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "core::option::Option::None" [] |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "core::option::Option::None" [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_is_pure_fixed : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "is_pure_fixed" (is_pure_fixed F). + + (* + pub fn is_pure_advice(&self) -> Option { + match self { + Expression::Advice { + column_index, + rotation, + .. + } => { + if rotation.0 == 0 { + Some( *column_index) + } else { + None + } + } + _ => None, + } + } + *) + Definition is_pure_advice (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "column_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "rotation" + |) in + let column_index := M.alloc (| γ1_0 |) in + let rotation := M.alloc (| γ1_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| rotation |), + "halo2_proofs::poly::Rotation", + 0 + |) + |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ M.read (| M.read (| column_index |) |) ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "core::option::Option::None" [] |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "core::option::Option::None" [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_is_pure_advice : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "is_pure_advice" (is_pure_advice F). + + (* + pub fn is_pure_instance(&self) -> Option { + match self { + Expression::Instance { + column_index, + rotation, + .. + } => { + if rotation.0 == 0 { + Some( *column_index) + } else { + None + } + } + _ => None, + } + } + *) + Definition is_pure_instance (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "column_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "rotation" + |) in + let column_index := M.alloc (| γ1_0 |) in + let rotation := M.alloc (| γ1_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| rotation |), + "halo2_proofs::poly::Rotation", + 0 + |) + |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ M.read (| M.read (| column_index |) |) ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "core::option::Option::None" [] |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "core::option::Option::None" [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_is_pure_instance : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "is_pure_instance" (is_pure_instance F). + + (* + pub fn evaluate( + &self, + constant: &impl Fn(F) -> T, + selector_column: &impl Fn(Selector) -> T, + fixed_column: &impl Fn(usize, usize, Rotation) -> T, + advice_column: &impl Fn(usize, usize, Rotation) -> T, + instance_column: &impl Fn(usize, usize, Rotation) -> T, + negated: &impl Fn(T) -> T, + sum: &impl Fn(T, T) -> T, + product: &impl Fn(&dyn Fn() -> T, &dyn Fn() -> T) -> T, + scaled: &impl Fn(T, F) -> T, + ) -> T { + match self { + Expression::Constant(scalar) => constant( *scalar), + Expression::Selector(selector) => selector_column( *selector), + Expression::Fixed { + query_index, + column_index, + rotation, + } => fixed_column( *query_index, *column_index, *rotation), + Expression::Advice { + query_index, + column_index, + rotation, + } => advice_column( *query_index, *column_index, *rotation), + Expression::Instance { + query_index, + column_index, + rotation, + } => instance_column( *query_index, *column_index, *rotation), + Expression::Negated(a) => { + let a = a.evaluate( + constant, + selector_column, + fixed_column, + advice_column, + instance_column, + negated, + sum, + product, + scaled, + ); + negated(a) + } + Expression::Sum(a, b) => { + let a = a.evaluate( + constant, + selector_column, + fixed_column, + advice_column, + instance_column, + negated, + sum, + product, + scaled, + ); + let b = b.evaluate( + constant, + selector_column, + fixed_column, + advice_column, + instance_column, + negated, + sum, + product, + scaled, + ); + sum(a, b) + } + Expression::Product(a, b) => { + let a = || { + a.evaluate( + constant, + selector_column, + fixed_column, + advice_column, + instance_column, + negated, + sum, + product, + scaled, + ) + }; + let b = || { + b.evaluate( + constant, + selector_column, + fixed_column, + advice_column, + instance_column, + negated, + sum, + product, + scaled, + ) + }; + product(&a, &b) + } + Expression::Scaled(a, f) => { + let a = a.evaluate( + constant, + selector_column, + fixed_column, + advice_column, + instance_column, + negated, + sum, + product, + scaled, + ); + scaled(a, *f) + } + } + } + *) + Definition evaluate (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ + T; + impl_Fn_F__arrow_T; + impl_Fn_Selector__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T'1; + impl_Fn_usize__usize__Rotation__arrow_T'2; + impl_Fn_T__arrow_T; + impl_Fn_T__T__arrow_T; + impl_Fn__dyn_Fn___arrow_T___dyn_Fn___arrow_T__arrow_T; + impl_Fn_T__F__arrow_T + ], + [ + self; + constant; + selector_column; + fixed_column; + advice_column; + instance_column; + negated; + sum; + product; + scaled + ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let constant := M.alloc (| constant |) in + let selector_column := M.alloc (| selector_column |) in + let fixed_column := M.alloc (| fixed_column |) in + let advice_column := M.alloc (| advice_column |) in + let instance_column := M.alloc (| instance_column |) in + let negated := M.alloc (| negated |) in + let sum := M.alloc (| sum |) in + let product := M.alloc (| product |) in + let scaled := M.alloc (| scaled |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Constant", + 0 + |) in + let scalar := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn_F__arrow_T, + [ Ty.tuple [ F ] ], + "call", + [] + |), + [ M.read (| constant |); Value.Tuple [ M.read (| M.read (| scalar |) |) ] + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Selector", + 0 + |) in + let selector := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn_Selector__arrow_T, + [ Ty.tuple [ Ty.path "halo2_proofs::plonk::circuit::Selector" ] ], + "call", + [] + |), + [ + M.read (| selector_column |); + Value.Tuple [ M.read (| M.read (| selector |) |) ] + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "rotation" + |) in + let query_index := M.alloc (| γ1_0 |) in + let column_index := M.alloc (| γ1_1 |) in + let rotation := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn_usize__usize__Rotation__arrow_T, + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + "call", + [] + |), + [ + M.read (| fixed_column |); + Value.Tuple + [ + M.read (| M.read (| query_index |) |); + M.read (| M.read (| column_index |) |); + M.read (| M.read (| rotation |) |) + ] + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "rotation" + |) in + let query_index := M.alloc (| γ1_0 |) in + let column_index := M.alloc (| γ1_1 |) in + let rotation := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn_usize__usize__Rotation__arrow_T'1, + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + "call", + [] + |), + [ + M.read (| advice_column |); + Value.Tuple + [ + M.read (| M.read (| query_index |) |); + M.read (| M.read (| column_index |) |); + M.read (| M.read (| rotation |) |) + ] + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "rotation" + |) in + let query_index := M.alloc (| γ1_0 |) in + let column_index := M.alloc (| γ1_1 |) in + let rotation := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn_usize__usize__Rotation__arrow_T'2, + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + "call", + [] + |), + [ + M.read (| instance_column |); + Value.Tuple + [ + M.read (| M.read (| query_index |) |); + M.read (| M.read (| column_index |) |); + M.read (| M.read (| rotation |) |) + ] + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Negated", + 0 + |) in + let a := M.alloc (| γ1_0 |) in + let a := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "evaluate", + [ + T; + impl_Fn_F__arrow_T; + impl_Fn_Selector__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T'1; + impl_Fn_usize__usize__Rotation__arrow_T'2; + impl_Fn_T__arrow_T; + impl_Fn_T__T__arrow_T; + impl_Fn__dyn_Fn___arrow_T___dyn_Fn___arrow_T__arrow_T; + impl_Fn_T__F__arrow_T + ] + |), + [ + M.read (| M.read (| a |) |); + M.read (| constant |); + M.read (| selector_column |); + M.read (| fixed_column |); + M.read (| advice_column |); + M.read (| instance_column |); + M.read (| negated |); + M.read (| sum |); + M.read (| product |); + M.read (| scaled |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn_T__arrow_T, + [ Ty.tuple [ T ] ], + "call", + [] + |), + [ M.read (| negated |); Value.Tuple [ M.read (| a |) ] ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let b := M.alloc (| γ1_1 |) in + let a := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "evaluate", + [ + T; + impl_Fn_F__arrow_T; + impl_Fn_Selector__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T'1; + impl_Fn_usize__usize__Rotation__arrow_T'2; + impl_Fn_T__arrow_T; + impl_Fn_T__T__arrow_T; + impl_Fn__dyn_Fn___arrow_T___dyn_Fn___arrow_T__arrow_T; + impl_Fn_T__F__arrow_T + ] + |), + [ + M.read (| M.read (| a |) |); + M.read (| constant |); + M.read (| selector_column |); + M.read (| fixed_column |); + M.read (| advice_column |); + M.read (| instance_column |); + M.read (| negated |); + M.read (| sum |); + M.read (| product |); + M.read (| scaled |) + ] + |) + |) in + let b := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "evaluate", + [ + T; + impl_Fn_F__arrow_T; + impl_Fn_Selector__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T'1; + impl_Fn_usize__usize__Rotation__arrow_T'2; + impl_Fn_T__arrow_T; + impl_Fn_T__T__arrow_T; + impl_Fn__dyn_Fn___arrow_T___dyn_Fn___arrow_T__arrow_T; + impl_Fn_T__F__arrow_T + ] + |), + [ + M.read (| M.read (| b |) |); + M.read (| constant |); + M.read (| selector_column |); + M.read (| fixed_column |); + M.read (| advice_column |); + M.read (| instance_column |); + M.read (| negated |); + M.read (| sum |); + M.read (| product |); + M.read (| scaled |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn_T__T__arrow_T, + [ Ty.tuple [ T; T ] ], + "call", + [] + |), + [ M.read (| sum |); Value.Tuple [ M.read (| a |); M.read (| b |) ] ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let b := M.alloc (| γ1_1 |) in + let a := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "evaluate", + [ + T; + impl_Fn_F__arrow_T; + impl_Fn_Selector__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T'1; + impl_Fn_usize__usize__Rotation__arrow_T'2; + impl_Fn_T__arrow_T; + impl_Fn_T__T__arrow_T; + impl_Fn__dyn_Fn___arrow_T___dyn_Fn___arrow_T__arrow_T; + impl_Fn_T__F__arrow_T + ] + |), + [ + M.read (| M.read (| a |) |); + M.read (| constant |); + M.read (| selector_column |); + M.read (| fixed_column |); + M.read (| advice_column |); + M.read (| instance_column |); + M.read (| negated |); + M.read (| sum |); + M.read (| product |); + M.read (| scaled |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let b := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "evaluate", + [ + T; + impl_Fn_F__arrow_T; + impl_Fn_Selector__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T'1; + impl_Fn_usize__usize__Rotation__arrow_T'2; + impl_Fn_T__arrow_T; + impl_Fn_T__T__arrow_T; + impl_Fn__dyn_Fn___arrow_T___dyn_Fn___arrow_T__arrow_T; + impl_Fn_T__F__arrow_T + ] + |), + [ + M.read (| M.read (| b |) |); + M.read (| constant |); + M.read (| selector_column |); + M.read (| fixed_column |); + M.read (| advice_column |); + M.read (| instance_column |); + M.read (| negated |); + M.read (| sum |); + M.read (| product |); + M.read (| scaled |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__dyn_Fn___arrow_T___dyn_Fn___arrow_T__arrow_T, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.dyn [ ("core::ops::function::Fn::Trait", []) ] ]; + Ty.apply + (Ty.path "&") + [ Ty.dyn [ ("core::ops::function::Fn::Trait", []) ] ] + ] + ], + "call", + [] + |), + [ + M.read (| product |); + Value.Tuple + [ (* Unsize *) M.pointer_coercion a; (* Unsize *) M.pointer_coercion b + ] + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let f := M.alloc (| γ1_1 |) in + let a := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "evaluate", + [ + T; + impl_Fn_F__arrow_T; + impl_Fn_Selector__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T'1; + impl_Fn_usize__usize__Rotation__arrow_T'2; + impl_Fn_T__arrow_T; + impl_Fn_T__T__arrow_T; + impl_Fn__dyn_Fn___arrow_T___dyn_Fn___arrow_T__arrow_T; + impl_Fn_T__F__arrow_T + ] + |), + [ + M.read (| M.read (| a |) |); + M.read (| constant |); + M.read (| selector_column |); + M.read (| fixed_column |); + M.read (| advice_column |); + M.read (| instance_column |); + M.read (| negated |); + M.read (| sum |); + M.read (| product |); + M.read (| scaled |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn_T__F__arrow_T, + [ Ty.tuple [ T; F ] ], + "call", + [] + |), + [ + M.read (| scaled |); + Value.Tuple [ M.read (| a |); M.read (| M.read (| f |) |) ] + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_evaluate : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "evaluate" (evaluate F). + + (* + pub fn evaluate_lazy( + &self, + constant: &impl Fn(F) -> T, + selector_column: &impl Fn(Selector) -> T, + fixed_column: &impl Fn(usize, usize, Rotation) -> T, + advice_column: &impl Fn(usize, usize, Rotation) -> T, + instance_column: &impl Fn(usize, usize, Rotation) -> T, + negated: &impl Fn(T) -> T, + sum: &impl Fn(T, T) -> T, + product: &impl Fn(T, T) -> T, + scaled: &impl Fn(T, F) -> T, + zero: &T, + ) -> T { + match self { + Expression::Constant(scalar) => constant( *scalar), + Expression::Selector(selector) => selector_column( *selector), + Expression::Fixed { + query_index, + column_index, + rotation, + } => fixed_column( *query_index, *column_index, *rotation), + Expression::Advice { + query_index, + column_index, + rotation, + } => advice_column( *query_index, *column_index, *rotation), + Expression::Instance { + query_index, + column_index, + rotation, + } => instance_column( *query_index, *column_index, *rotation), + Expression::Negated(a) => { + let a = a.evaluate_lazy( + constant, + selector_column, + fixed_column, + advice_column, + instance_column, + negated, + sum, + product, + scaled, + zero, + ); + negated(a) + } + Expression::Sum(a, b) => { + let a = a.evaluate_lazy( + constant, + selector_column, + fixed_column, + advice_column, + instance_column, + negated, + sum, + product, + scaled, + zero, + ); + let b = b.evaluate_lazy( + constant, + selector_column, + fixed_column, + advice_column, + instance_column, + negated, + sum, + product, + scaled, + zero, + ); + sum(a, b) + } + Expression::Product(a, b) => { + let (a, b) = if a.complexity() <= b.complexity() { + (a, b) + } else { + (b, a) + }; + let a = a.evaluate_lazy( + constant, + selector_column, + fixed_column, + advice_column, + instance_column, + negated, + sum, + product, + scaled, + zero, + ); + + if a == *zero { + a + } else { + let b = b.evaluate_lazy( + constant, + selector_column, + fixed_column, + advice_column, + instance_column, + negated, + sum, + product, + scaled, + zero, + ); + product(a, b) + } + } + Expression::Scaled(a, f) => { + let a = a.evaluate_lazy( + constant, + selector_column, + fixed_column, + advice_column, + instance_column, + negated, + sum, + product, + scaled, + zero, + ); + scaled(a, *f) + } + } + } + *) + Definition evaluate_lazy (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ + T; + impl_Fn_F__arrow_T; + impl_Fn_Selector__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T'1; + impl_Fn_usize__usize__Rotation__arrow_T'2; + impl_Fn_T__arrow_T; + impl_Fn_T__T__arrow_T; + impl_Fn_T__T__arrow_T'1; + impl_Fn_T__F__arrow_T + ], + [ + self; + constant; + selector_column; + fixed_column; + advice_column; + instance_column; + negated; + sum; + product; + scaled; + zero + ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let constant := M.alloc (| constant |) in + let selector_column := M.alloc (| selector_column |) in + let fixed_column := M.alloc (| fixed_column |) in + let advice_column := M.alloc (| advice_column |) in + let instance_column := M.alloc (| instance_column |) in + let negated := M.alloc (| negated |) in + let sum := M.alloc (| sum |) in + let product := M.alloc (| product |) in + let scaled := M.alloc (| scaled |) in + let zero := M.alloc (| zero |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Constant", + 0 + |) in + let scalar := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn_F__arrow_T, + [ Ty.tuple [ F ] ], + "call", + [] + |), + [ M.read (| constant |); Value.Tuple [ M.read (| M.read (| scalar |) |) ] + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Selector", + 0 + |) in + let selector := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn_Selector__arrow_T, + [ Ty.tuple [ Ty.path "halo2_proofs::plonk::circuit::Selector" ] ], + "call", + [] + |), + [ + M.read (| selector_column |); + Value.Tuple [ M.read (| M.read (| selector |) |) ] + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "rotation" + |) in + let query_index := M.alloc (| γ1_0 |) in + let column_index := M.alloc (| γ1_1 |) in + let rotation := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn_usize__usize__Rotation__arrow_T, + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + "call", + [] + |), + [ + M.read (| fixed_column |); + Value.Tuple + [ + M.read (| M.read (| query_index |) |); + M.read (| M.read (| column_index |) |); + M.read (| M.read (| rotation |) |) + ] + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "rotation" + |) in + let query_index := M.alloc (| γ1_0 |) in + let column_index := M.alloc (| γ1_1 |) in + let rotation := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn_usize__usize__Rotation__arrow_T'1, + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + "call", + [] + |), + [ + M.read (| advice_column |); + Value.Tuple + [ + M.read (| M.read (| query_index |) |); + M.read (| M.read (| column_index |) |); + M.read (| M.read (| rotation |) |) + ] + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "rotation" + |) in + let query_index := M.alloc (| γ1_0 |) in + let column_index := M.alloc (| γ1_1 |) in + let rotation := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn_usize__usize__Rotation__arrow_T'2, + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + "call", + [] + |), + [ + M.read (| instance_column |); + Value.Tuple + [ + M.read (| M.read (| query_index |) |); + M.read (| M.read (| column_index |) |); + M.read (| M.read (| rotation |) |) + ] + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Negated", + 0 + |) in + let a := M.alloc (| γ1_0 |) in + let a := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "evaluate_lazy", + [ + T; + impl_Fn_F__arrow_T; + impl_Fn_Selector__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T'1; + impl_Fn_usize__usize__Rotation__arrow_T'2; + impl_Fn_T__arrow_T; + impl_Fn_T__T__arrow_T; + impl_Fn_T__T__arrow_T'1; + impl_Fn_T__F__arrow_T + ] + |), + [ + M.read (| M.read (| a |) |); + M.read (| constant |); + M.read (| selector_column |); + M.read (| fixed_column |); + M.read (| advice_column |); + M.read (| instance_column |); + M.read (| negated |); + M.read (| sum |); + M.read (| product |); + M.read (| scaled |); + M.read (| zero |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn_T__arrow_T, + [ Ty.tuple [ T ] ], + "call", + [] + |), + [ M.read (| negated |); Value.Tuple [ M.read (| a |) ] ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let b := M.alloc (| γ1_1 |) in + let a := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "evaluate_lazy", + [ + T; + impl_Fn_F__arrow_T; + impl_Fn_Selector__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T'1; + impl_Fn_usize__usize__Rotation__arrow_T'2; + impl_Fn_T__arrow_T; + impl_Fn_T__T__arrow_T; + impl_Fn_T__T__arrow_T'1; + impl_Fn_T__F__arrow_T + ] + |), + [ + M.read (| M.read (| a |) |); + M.read (| constant |); + M.read (| selector_column |); + M.read (| fixed_column |); + M.read (| advice_column |); + M.read (| instance_column |); + M.read (| negated |); + M.read (| sum |); + M.read (| product |); + M.read (| scaled |); + M.read (| zero |) + ] + |) + |) in + let b := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "evaluate_lazy", + [ + T; + impl_Fn_F__arrow_T; + impl_Fn_Selector__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T'1; + impl_Fn_usize__usize__Rotation__arrow_T'2; + impl_Fn_T__arrow_T; + impl_Fn_T__T__arrow_T; + impl_Fn_T__T__arrow_T'1; + impl_Fn_T__F__arrow_T + ] + |), + [ + M.read (| M.read (| b |) |); + M.read (| constant |); + M.read (| selector_column |); + M.read (| fixed_column |); + M.read (| advice_column |); + M.read (| instance_column |); + M.read (| negated |); + M.read (| sum |); + M.read (| product |); + M.read (| scaled |); + M.read (| zero |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn_T__T__arrow_T, + [ Ty.tuple [ T; T ] ], + "call", + [] + |), + [ M.read (| sum |); Value.Tuple [ M.read (| a |); M.read (| b |) ] ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let b := M.alloc (| γ1_1 |) in + M.match_operator (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.le + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "complexity", + [] + |), + [ M.read (| M.read (| a |) |) ] + |)) + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "complexity", + [] + |), + [ M.read (| M.read (| b |) |) ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| Value.Tuple [ M.read (| a |); M.read (| b |) ] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [ M.read (| b |); M.read (| a |) ] |))) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let a := M.copy (| γ0_0 |) in + let b := M.copy (| γ0_1 |) in + let a := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "evaluate_lazy", + [ + T; + impl_Fn_F__arrow_T; + impl_Fn_Selector__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T'1; + impl_Fn_usize__usize__Rotation__arrow_T'2; + impl_Fn_T__arrow_T; + impl_Fn_T__T__arrow_T; + impl_Fn_T__T__arrow_T'1; + impl_Fn_T__F__arrow_T + ] + |), + [ + M.read (| M.read (| a |) |); + M.read (| constant |); + M.read (| selector_column |); + M.read (| fixed_column |); + M.read (| advice_column |); + M.read (| instance_column |); + M.read (| negated |); + M.read (| sum |); + M.read (| product |); + M.read (| scaled |); + M.read (| zero |) + ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + T, + [ T ], + "eq", + [] + |), + [ a; M.read (| zero |) ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + a)); + fun γ => + ltac:(M.monadic + (let b := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "evaluate_lazy", + [ + T; + impl_Fn_F__arrow_T; + impl_Fn_Selector__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T'1; + impl_Fn_usize__usize__Rotation__arrow_T'2; + impl_Fn_T__arrow_T; + impl_Fn_T__T__arrow_T; + impl_Fn_T__T__arrow_T'1; + impl_Fn_T__F__arrow_T + ] + |), + [ + M.read (| M.read (| b |) |); + M.read (| constant |); + M.read (| selector_column |); + M.read (| fixed_column |); + M.read (| advice_column |); + M.read (| instance_column |); + M.read (| negated |); + M.read (| sum |); + M.read (| product |); + M.read (| scaled |); + M.read (| zero |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn_T__T__arrow_T'1, + [ Ty.tuple [ T; T ] ], + "call", + [] + |), + [ + M.read (| product |); + Value.Tuple [ M.read (| a |); M.read (| b |) ] + ] + |) + |))) + ] + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let f := M.alloc (| γ1_1 |) in + let a := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "evaluate_lazy", + [ + T; + impl_Fn_F__arrow_T; + impl_Fn_Selector__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T; + impl_Fn_usize__usize__Rotation__arrow_T'1; + impl_Fn_usize__usize__Rotation__arrow_T'2; + impl_Fn_T__arrow_T; + impl_Fn_T__T__arrow_T; + impl_Fn_T__T__arrow_T'1; + impl_Fn_T__F__arrow_T + ] + |), + [ + M.read (| M.read (| a |) |); + M.read (| constant |); + M.read (| selector_column |); + M.read (| fixed_column |); + M.read (| advice_column |); + M.read (| instance_column |); + M.read (| negated |); + M.read (| sum |); + M.read (| product |); + M.read (| scaled |); + M.read (| zero |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn_T__F__arrow_T, + [ Ty.tuple [ T; F ] ], + "call", + [] + |), + [ + M.read (| scaled |); + Value.Tuple [ M.read (| a |); M.read (| M.read (| f |) |) ] + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_evaluate_lazy : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "evaluate_lazy" (evaluate_lazy F). + + (* + pub fn identifier(&self) -> String { + match self { + Expression::Constant(scalar) => format!("{:?}", scalar), + Expression::Selector(selector) => format!("selector[{}]", selector.0), + Expression::Fixed { + query_index: _, + column_index, + rotation, + } => format!("fixed[{}][{}]", column_index, rotation.0), + Expression::Advice { + query_index: _, + column_index, + rotation, + } => format!("advice[{}][{}]", column_index, rotation.0), + Expression::Instance { + query_index: _, + column_index, + rotation, + } => format!("instance[{}][{}]", column_index, rotation.0), + Expression::Negated(a) => { + format!("(-{})", a.identifier()) + } + Expression::Sum(a, b) => { + format!("({}+{})", a.identifier(), b.identifier()) + } + Expression::Product(a, b) => { + format!("({}*{})", a.identifier(), b.identifier()) + } + Expression::Scaled(a, f) => { + format!("{}*{:?}", a.identifier(), f) + } + } + } + *) + Definition identifier (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Constant", + 0 + |) in + let scalar := M.alloc (| γ1_0 |) in + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| Value.Array [ M.read (| Value.String "" |) ] |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ Ty.apply (Ty.path "&") [ F ] ] + |), + [ scalar ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Selector", + 0 + |) in + let selector := M.alloc (| γ1_0 |) in + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "selector[" |); + M.read (| Value.String "]" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| selector |), + "halo2_proofs::plonk::circuit::Selector", + 0 + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "rotation" + |) in + let column_index := M.alloc (| γ1_1 |) in + let rotation := M.alloc (| γ1_2 |) in + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "fixed[" |); + M.read (| Value.String "][" |); + M.read (| Value.String "]" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "usize" ] ] + |), + [ column_index ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "i32" ] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| rotation |), + "halo2_proofs::poly::Rotation", + 0 + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "rotation" + |) in + let column_index := M.alloc (| γ1_1 |) in + let rotation := M.alloc (| γ1_2 |) in + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "advice[" |); + M.read (| Value.String "][" |); + M.read (| Value.String "]" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "usize" ] ] + |), + [ column_index ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "i32" ] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| rotation |), + "halo2_proofs::poly::Rotation", + 0 + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "rotation" + |) in + let column_index := M.alloc (| γ1_1 |) in + let rotation := M.alloc (| γ1_2 |) in + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "instance[" |); + M.read (| Value.String "][" |); + M.read (| Value.String "]" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "usize" ] ] + |), + [ column_index ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "i32" ] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| rotation |), + "halo2_proofs::poly::Rotation", + 0 + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Negated", + 0 + |) in + let a := M.alloc (| γ1_0 |) in + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "(-" |); + M.read (| Value.String ")" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "alloc::string::String" ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + "identifier", + [] + |), + [ M.read (| M.read (| a |) |) ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let b := M.alloc (| γ1_1 |) in + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "(" |); + M.read (| Value.String "+" |); + M.read (| Value.String ")" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "alloc::string::String" ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + "identifier", + [] + |), + [ M.read (| M.read (| a |) |) ] + |) + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "alloc::string::String" ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + "identifier", + [] + |), + [ M.read (| M.read (| b |) |) ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let b := M.alloc (| γ1_1 |) in + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "(" |); + M.read (| Value.String "*" |); + M.read (| Value.String ")" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "alloc::string::String" ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + "identifier", + [] + |), + [ M.read (| M.read (| a |) |) ] + |) + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "alloc::string::String" ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + "identifier", + [] + |), + [ M.read (| M.read (| b |) |) ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let f := M.alloc (| γ1_1 |) in + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "" |); + M.read (| Value.String "*" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "alloc::string::String" ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + "identifier", + [] + |), + [ M.read (| M.read (| a |) |) ] + |) + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ Ty.apply (Ty.path "&") [ F ] ] + |), + [ f ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_identifier : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "identifier" (identifier F). + + (* + pub fn degree(&self) -> usize { + match self { + Expression::Constant(_) => 0, + Expression::Selector(_) => 1, + Expression::Fixed { .. } => 1, + Expression::Advice { .. } => 1, + Expression::Instance { .. } => 1, + Expression::Negated(poly) => poly.degree(), + Expression::Sum(a, b) => max(a.degree(), b.degree()), + Expression::Product(a, b) => a.degree() + b.degree(), + Expression::Scaled(poly, _) => poly.degree(), + } + } + *) + Definition degree (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Constant", + 0 + |) in + M.alloc (| Value.Integer 0 |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Selector", + 0 + |) in + M.alloc (| Value.Integer 1 |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| Value.Integer 1 |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| Value.Integer 1 |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| Value.Integer 1 |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Negated", + 0 + |) in + let poly := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "degree", + [] + |), + [ M.read (| M.read (| poly |) |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let b := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_function (| "core::cmp::max", [ Ty.path "usize" ] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "degree", + [] + |), + [ M.read (| M.read (| a |) |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "degree", + [] + |), + [ M.read (| M.read (| b |) |) ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let b := M.alloc (| γ1_1 |) in + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "degree", + [] + |), + [ M.read (| M.read (| a |) |) ] + |), + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "degree", + [] + |), + [ M.read (| M.read (| b |) |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 1 + |) in + let poly := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "degree", + [] + |), + [ M.read (| M.read (| poly |) |) ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_degree : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "degree" (degree F). + + (* + pub fn complexity(&self) -> usize { + match self { + Expression::Constant(_) => 0, + Expression::Selector(_) => 1, + Expression::Fixed { .. } => 1, + Expression::Advice { .. } => 1, + Expression::Instance { .. } => 1, + Expression::Negated(poly) => poly.complexity() + 5, + Expression::Sum(a, b) => a.complexity() + b.complexity() + 15, + Expression::Product(a, b) => a.complexity() + b.complexity() + 30, + Expression::Scaled(poly, _) => poly.complexity() + 30, + } + } + *) + Definition complexity (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Constant", + 0 + |) in + M.alloc (| Value.Integer 0 |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Selector", + 0 + |) in + M.alloc (| Value.Integer 1 |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| Value.Integer 1 |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| Value.Integer 1 |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| Value.Integer 1 |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Negated", + 0 + |) in + let poly := M.alloc (| γ1_0 |) in + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "complexity", + [] + |), + [ M.read (| M.read (| poly |) |) ] + |), + Value.Integer 5 + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let b := M.alloc (| γ1_1 |) in + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "complexity", + [] + |), + [ M.read (| M.read (| a |) |) ] + |), + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "complexity", + [] + |), + [ M.read (| M.read (| b |) |) ] + |) + |), + Value.Integer 15 + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let b := M.alloc (| γ1_1 |) in + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "complexity", + [] + |), + [ M.read (| M.read (| a |) |) ] + |), + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "complexity", + [] + |), + [ M.read (| M.read (| b |) |) ] + |) + |), + Value.Integer 30 + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 1 + |) in + let poly := M.alloc (| γ1_0 |) in + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "complexity", + [] + |), + [ M.read (| M.read (| poly |) |) ] + |), + Value.Integer 30 + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_complexity : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "complexity" (complexity F). + + (* + pub fn square(self) -> Self { + self.clone() * self + } + *) + Definition square (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [], + "clone", + [] + |), + [ self ] + |); + M.read (| self |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_square : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "square" (square F). + + (* + fn contains_simple_selector(&self) -> bool { + self.evaluate( + &|_| false, + &|selector| selector.is_simple(), + &|_, _, _| false, + &|_, _, _| false, + &|_, _, _| false, + &|a| a, + &|a, b| a || b, + &|a, b| a() || b(), + &|a, _| a, + ) + } + *) + Definition contains_simple_selector (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "evaluate", + [ + Ty.path "bool"; + Ty.function [ Ty.tuple [ F ] ] (Ty.path "bool"); + Ty.function + [ Ty.tuple [ Ty.path "halo2_proofs::plonk::circuit::Selector" ] ] + (Ty.path "bool"); + Ty.function + [ + Ty.tuple + [ Ty.path "usize"; Ty.path "usize"; Ty.path "halo2_proofs::poly::Rotation" ] + ] + (Ty.path "bool"); + Ty.function + [ + Ty.tuple + [ Ty.path "usize"; Ty.path "usize"; Ty.path "halo2_proofs::poly::Rotation" ] + ] + (Ty.path "bool"); + Ty.function + [ + Ty.tuple + [ Ty.path "usize"; Ty.path "usize"; Ty.path "halo2_proofs::poly::Rotation" ] + ] + (Ty.path "bool"); + Ty.function [ Ty.tuple [ Ty.path "bool" ] ] (Ty.path "bool"); + Ty.function [ Ty.tuple [ Ty.path "bool"; Ty.path "bool" ] ] (Ty.path "bool"); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.dyn [ ("core::ops::function::Fn::Trait", []) ] ]; + Ty.apply + (Ty.path "&") + [ Ty.dyn [ ("core::ops::function::Fn::Trait", []) ] ] + ] + ] + (Ty.path "bool"); + Ty.function [ Ty.tuple [ Ty.path "bool"; F ] ] (Ty.path "bool") + ] + |), + [ + M.read (| self |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ fun γ => ltac:(M.monadic (Value.Bool false)) ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let selector := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::circuit::Selector", + "is_simple", + [] + |), + [ selector ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| α2 |), + [ fun γ => ltac:(M.monadic (Value.Bool false)) ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| α2 |), + [ fun γ => ltac:(M.monadic (Value.Bool false)) ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| α2 |), + [ fun γ => ltac:(M.monadic (Value.Bool false)) ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.read (| a |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let b := M.copy (| γ |) in + LogicalOp.or (| + M.read (| a |), + ltac:(M.monadic (M.read (| b |))) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let b := M.copy (| γ |) in + LogicalOp.or (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn [ ("core::ops::function::Fn::Trait", []) ], + [ Ty.tuple [] ], + "call", + [] + |), + [ M.read (| a |); Value.Tuple [] ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn [ ("core::ops::function::Fn::Trait", []) ], + [ Ty.tuple [] ], + "call", + [] + |), + [ M.read (| b |); Value.Tuple [] ] + |))) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ fun γ => ltac:(M.monadic (M.read (| a |))) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_contains_simple_selector : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "contains_simple_selector" (contains_simple_selector F). + + (* + fn extract_simple_selector(&self) -> Option { + let op = |a, b| match (a, b) { + (Some(a), None) | (None, Some(a)) => Some(a), + (Some(_), Some(_)) => panic!("two simple selectors cannot be in the same expression"), + _ => None, + }; + + self.evaluate( + &|_| None, + &|selector| { + if selector.is_simple() { + Some(selector) + } else { + None + } + }, + &|_, _, _| None, + &|_, _, _| None, + &|_, _, _| None, + &|a| a, + &op, + &|a, b| match (a(), b()) { + (Some(a), None) | (None, Some(a)) => Some(a), + (Some(_), Some(_)) => { + panic!("two simple selectors cannot be in the same expression") + } + _ => None, + }, + &|a, _| a, + ) + } + *) + Definition extract_simple_selector (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let op := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let b := M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| + Value.Tuple [ M.read (| a |); M.read (| b |) ] + |), + [ + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "core::option::Option::Some", + 0 + |) in + let a := M.copy (| γ1_0 |) in + Value.Tuple [ a ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "core::option::Option::Some", + 0 + |) in + let a := M.copy (| γ1_0 |) in + Value.Tuple [ a ])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ a ] => + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ M.read (| a |) ] + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "core::option::Option::Some", + 0 + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "std::panicking::begin_panic", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + Value.String + "two simple selectors cannot be in the same expression" + |) + ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))) + ] + |) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + "evaluate", + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::plonk::circuit::Selector" ]; + Ty.function + [ Ty.tuple [ F ] ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::plonk::circuit::Selector" ]); + Ty.function + [ Ty.tuple [ Ty.path "halo2_proofs::plonk::circuit::Selector" ] ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::plonk::circuit::Selector" ]); + Ty.function + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::plonk::circuit::Selector" ]); + Ty.function + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::plonk::circuit::Selector" ]); + Ty.function + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "usize"; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::plonk::circuit::Selector" ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::plonk::circuit::Selector" ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::plonk::circuit::Selector" ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::plonk::circuit::Selector" ]; + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::plonk::circuit::Selector" ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::plonk::circuit::Selector" ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.dyn [ ("core::ops::function::Fn::Trait", []) ] ]; + Ty.apply + (Ty.path "&") + [ Ty.dyn [ ("core::ops::function::Fn::Trait", []) ] ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::plonk::circuit::Selector" ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::plonk::circuit::Selector" ]; + F + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "halo2_proofs::plonk::circuit::Selector" ]) + ] + |), + [ + M.read (| self |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple "core::option::Option::None" [])) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let selector := M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::plonk::circuit::Selector", + "is_simple", + [] + |), + [ selector ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ M.read (| selector |) ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple "core::option::Option::None" [] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| α2 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::option::Option::None" + [])) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| α2 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::option::Option::None" + [])) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| α2 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::option::Option::None" + [])) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.read (| a |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + op; + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let b := M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ], + [ Ty.tuple [] ], + "call", + [] + |), + [ M.read (| a |); Value.Tuple [] ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ], + [ Ty.tuple [] ], + "call", + [] + |), + [ M.read (| b |); Value.Tuple [] ] + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "core::option::Option::Some", + 0 + |) in + let a := M.copy (| γ1_0 |) in + Value.Tuple [ a ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "core::option::Option::Some", + 0 + |) in + let a := M.copy (| γ1_0 |) in + Value.Tuple [ a ])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ a ] => + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ M.read (| a |) ] + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "core::option::Option::Some", + 0 + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "std::panicking::begin_panic", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + Value.String + "two simple selectors cannot be in the same expression" + |) + ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))) + ] + |) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ fun γ => ltac:(M.monadic (M.read (| a |))) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_extract_simple_selector : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "extract_simple_selector" (extract_simple_selector F). + End Impl_halo2_proofs_plonk_circuit_Expression_F. + + Module Impl_core_ops_arith_Neg_where_ff_Field_F_for_halo2_proofs_plonk_circuit_Expression_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]. + + (* type Output = Expression; *) + Definition _Output (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]. + + (* + fn neg(self) -> Self::Output { + Expression::Negated(Box::new(self)) + } + *) + Definition neg (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Negated" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| self |) ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::Neg" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F)); ("neg", InstanceField.Method (neg F)) ]. + End Impl_core_ops_arith_Neg_where_ff_Field_F_for_halo2_proofs_plonk_circuit_Expression_F. + + Module Impl_core_ops_arith_Add_where_ff_Field_F_for_halo2_proofs_plonk_circuit_Expression_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]. + + (* type Output = Expression; *) + Definition _Output (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]. + + (* + fn add(self, rhs: Expression) -> Expression { + if self.contains_simple_selector() || rhs.contains_simple_selector() { + panic!("attempted to use a simple selector in an addition"); + } + if Some(F::zero()) == self.is_constant() { + return rhs; + } + if Some(F::zero()) == rhs.is_constant() { + return self; + } + if let Some(l) = rhs.is_constant() { + if let Some(r) = self.is_constant() { + return Expression::Constant(l + r); + } + } + Expression::Sum(Box::new(self), Box::new(rhs)) + } + *) + Definition add (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.or (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "contains_simple_selector", + [] + |), + [ self ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "contains_simple_selector", + [] + |), + [ rhs ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "std::panicking::begin_panic", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + M.read (| + Value.String + "attempted to use a simple selector in an addition" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply (Ty.path "core::option::Option") [ F ], + [ Ty.apply (Ty.path "core::option::Option") [ F ] ], + "eq", + [] + |), + [ + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "is_constant", + [] + |), + [ self ] + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| M.read (| M.return_ (| M.read (| rhs |) |) |) |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply (Ty.path "core::option::Option") [ F ], + [ Ty.apply (Ty.path "core::option::Option") [ F ] ], + "eq", + [] + |), + [ + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "is_constant", + [] + |), + [ rhs ] + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| M.read (| M.return_ (| M.read (| self |) |) |) |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "is_constant", + [] + |), + [ rhs ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let l := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "is_constant", + [] + |), + [ self ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let r := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + F, + [ F ], + "add", + [] + |), + [ M.read (| l |); M.read (| r |) ] + |) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Sum" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| self |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| rhs |) ] + |) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::Add" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F)); ("add", InstanceField.Method (add F)) ]. + End Impl_core_ops_arith_Add_where_ff_Field_F_for_halo2_proofs_plonk_circuit_Expression_F. + + Module Impl_core_ops_arith_Sub_where_ff_Field_F_for_halo2_proofs_plonk_circuit_Expression_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]. + + (* type Output = Expression; *) + Definition _Output (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]. + + (* + fn sub(self, rhs: Expression) -> Expression { + if self.contains_simple_selector() || rhs.contains_simple_selector() { + panic!("attempted to use a simple selector in a subtraction"); + } + Expression::Sum(Box::new(self), Box::new(-rhs)) + } + *) + Definition sub (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.or (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "contains_simple_selector", + [] + |), + [ self ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "contains_simple_selector", + [] + |), + [ rhs ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "std::panicking::begin_panic", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + M.read (| + Value.String "attempted to use a simple selector in a subtraction" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Sum" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| self |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Neg", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [], + "neg", + [] + |), + [ M.read (| rhs |) ] + |) + ] + |) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::Sub" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F)); ("sub", InstanceField.Method (sub F)) ]. + End Impl_core_ops_arith_Sub_where_ff_Field_F_for_halo2_proofs_plonk_circuit_Expression_F. + + Module Impl_core_ops_arith_Mul_where_ff_Field_F_for_halo2_proofs_plonk_circuit_Expression_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]. + + (* type Output = Expression; *) + Definition _Output (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]. + + (* + fn mul(self, rhs: Expression) -> Expression { + if self.contains_simple_selector() && rhs.contains_simple_selector() { + panic!("attempted to multiply two expressions containing simple selectors"); + } + if Some(F::one()) == self.is_constant() { + return rhs; + } + if Some(F::one()) == rhs.is_constant() { + return self; + } + if let Some(l) = rhs.is_constant() { + if let Some(r) = self.is_constant() { + return Expression::Constant(l * r); + } + } + Expression::Product(Box::new(self), Box::new(rhs)) + } + *) + Definition mul (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "contains_simple_selector", + [] + |), + [ self ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "contains_simple_selector", + [] + |), + [ rhs ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "std::panicking::begin_panic", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + M.read (| + Value.String + "attempted to multiply two expressions containing simple selectors" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply (Ty.path "core::option::Option") [ F ], + [ Ty.apply (Ty.path "core::option::Option") [ F ] ], + "eq", + [] + |), + [ + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "is_constant", + [] + |), + [ self ] + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| M.read (| M.return_ (| M.read (| rhs |) |) |) |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply (Ty.path "core::option::Option") [ F ], + [ Ty.apply (Ty.path "core::option::Option") [ F ] ], + "eq", + [] + |), + [ + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "is_constant", + [] + |), + [ rhs ] + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| M.read (| M.return_ (| M.read (| self |) |) |) |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "is_constant", + [] + |), + [ rhs ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let l := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "is_constant", + [] + |), + [ self ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let r := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ F ], + "mul", + [] + |), + [ M.read (| l |); M.read (| r |) ] + |) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Product" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| self |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| rhs |) ] + |) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::Mul" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F)); ("mul", InstanceField.Method (mul F)) ]. + End Impl_core_ops_arith_Mul_where_ff_Field_F_for_halo2_proofs_plonk_circuit_Expression_F. + + Module Impl_core_ops_arith_Mul_where_ff_Field_F_F_for_halo2_proofs_plonk_circuit_Expression_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]. + + (* type Output = Expression; *) + Definition _Output (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]. + + (* + fn mul(self, rhs: F) -> Expression { + Expression::Scaled(Box::new(self), rhs) + } + *) + Definition mul (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Scaled" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| self |) ] + |); + M.read (| rhs |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::Mul" + (Self F) + (* Trait polymorphic types *) [ (* Rhs *) F ] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F)); ("mul", InstanceField.Method (mul F)) ]. + End Impl_core_ops_arith_Mul_where_ff_Field_F_F_for_halo2_proofs_plonk_circuit_Expression_F. + + (* StructTuple + { + name := "PointIndex"; + ty_params := []; + fields := [ Ty.path "usize" ]; + } *) + + Module Impl_core_marker_Copy_for_halo2_proofs_plonk_circuit_PointIndex. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::PointIndex". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_plonk_circuit_PointIndex. + + Module Impl_core_clone_Clone_for_halo2_proofs_plonk_circuit_PointIndex. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::PointIndex". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.read (| self |))) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_plonk_circuit_PointIndex. + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_circuit_PointIndex. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::PointIndex". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "PointIndex" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::PointIndex", + 0 + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_circuit_PointIndex. + + (* StructRecord + { + name := "VirtualCell"; + ty_params := []; + fields := + [ + ("column", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]); + ("rotation", Ty.path "halo2_proofs::poly::Rotation") + ]; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_plonk_circuit_VirtualCell. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::VirtualCell". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::plonk::circuit::VirtualCell" + [ + ("column", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::VirtualCell", + "column" + |) + ] + |)); + ("rotation", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::poly::Rotation", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::VirtualCell", + "rotation" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_plonk_circuit_VirtualCell. + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_circuit_VirtualCell. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::circuit::VirtualCell". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "VirtualCell" |); + M.read (| Value.String "column" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::VirtualCell", + "column" + |)); + M.read (| Value.String "rotation" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::VirtualCell", + "rotation" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_circuit_VirtualCell. + + Module Impl_core_convert_From_where_core_convert_Into_Col_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Any_Tuple_Col_halo2_proofs_poly_Rotation__for_halo2_proofs_plonk_circuit_VirtualCell. + Definition Self (Col : Ty.t) : Ty.t := Ty.path "halo2_proofs::plonk::circuit::VirtualCell". + + (* + fn from((column, rotation): (Col, Rotation)) -> Self { + VirtualCell { + column: column.into(), + rotation, + } + } + *) + Definition from (Col : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self Col in + match τ, α with + | [], [ β0 ] => + ltac:(M.monadic + (let β0 := M.alloc (| β0 |) in + M.match_operator (| + β0, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let column := M.copy (| γ0_0 |) in + let rotation := M.copy (| γ0_1 |) in + Value.StructRecord + "halo2_proofs::plonk::circuit::VirtualCell" + [ + ("column", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Col, + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "into", + [] + |), + [ M.read (| column |) ] + |)); + ("rotation", M.read (| rotation |)) + ])) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (Col : Ty.t), + M.IsTraitInstance + "core::convert::From" + (Self Col) + (* Trait polymorphic types *) + [ (* T *) Ty.tuple [ Col; Ty.path "halo2_proofs::poly::Rotation" ] ] + (* Instance *) [ ("from", InstanceField.Method (from Col)) ]. + End Impl_core_convert_From_where_core_convert_Into_Col_halo2_proofs_plonk_circuit_Column_halo2_proofs_plonk_circuit_Any_Tuple_Col_halo2_proofs_poly_Rotation__for_halo2_proofs_plonk_circuit_VirtualCell. + + (* StructRecord + { + name := "Constraint"; + ty_params := [ "F" ]; + fields := + [ + ("name", Ty.apply (Ty.path "&") [ Ty.path "str" ]); + ("poly", Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_plonk_circuit_Constraint_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Constraint") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Constraint" |); + M.read (| Value.String "name" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Constraint", + "name" + |)); + M.read (| Value.String "poly" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Constraint", + "poly" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_plonk_circuit_Constraint_F. + + Module Impl_core_convert_From_where_ff_Field_F_halo2_proofs_plonk_circuit_Expression_F_for_halo2_proofs_plonk_circuit_Constraint_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Constraint") [ F ]. + + (* + fn from(poly: Expression) -> Self { + Constraint { name: "", poly } + } + *) + Definition from (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ poly ] => + ltac:(M.monadic + (let poly := M.alloc (| poly |) in + Value.StructRecord + "halo2_proofs::plonk::circuit::Constraint" + [ ("name", M.read (| Value.String "" |)); ("poly", M.read (| poly |)) ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::convert::From" + (Self F) + (* Trait polymorphic types *) + [ (* T *) Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ] + (* Instance *) [ ("from", InstanceField.Method (from F)) ]. + End Impl_core_convert_From_where_ff_Field_F_halo2_proofs_plonk_circuit_Expression_F_for_halo2_proofs_plonk_circuit_Constraint_F. + + Module Impl_core_convert_From_where_ff_Field_F_Tuple_ref__str_halo2_proofs_plonk_circuit_Expression_F__for_halo2_proofs_plonk_circuit_Constraint_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Constraint") [ F ]. + + (* + fn from((name, poly): (&'static str, Expression)) -> Self { + Constraint { name, poly } + } + *) + Definition from (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ β0 ] => + ltac:(M.monadic + (let β0 := M.alloc (| β0 |) in + M.match_operator (| + β0, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let name := M.copy (| γ0_0 |) in + let poly := M.copy (| γ0_1 |) in + Value.StructRecord + "halo2_proofs::plonk::circuit::Constraint" + [ ("name", M.read (| name |)); ("poly", M.read (| poly |)) ])) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::convert::From" + (Self F) + (* Trait polymorphic types *) + [ + (* T *) + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ] + ] + (* Instance *) [ ("from", InstanceField.Method (from F)) ]. + End Impl_core_convert_From_where_ff_Field_F_Tuple_ref__str_halo2_proofs_plonk_circuit_Expression_F__for_halo2_proofs_plonk_circuit_Constraint_F. + + Module Impl_core_convert_From_where_ff_Field_F_halo2_proofs_plonk_circuit_Expression_F_for_alloc_vec_Vec_halo2_proofs_plonk_circuit_Constraint_F_alloc_alloc_Global. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Constraint") [ F ]; + Ty.path "alloc::alloc::Global" + ]. + + (* + fn from(poly: Expression) -> Self { + vec![Constraint { name: "", poly }] + } + *) + Definition from (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ poly ] => + ltac:(M.monadic + (let poly := M.alloc (| poly |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Constraint") [ F ] ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Constraint") [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.StructRecord + "halo2_proofs::plonk::circuit::Constraint" + [ + ("name", M.read (| Value.String "" |)); + ("poly", M.read (| poly |)) + ] + ] + |) + ] + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::convert::From" + (Self F) + (* Trait polymorphic types *) + [ (* T *) Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ] + (* Instance *) [ ("from", InstanceField.Method (from F)) ]. + End Impl_core_convert_From_where_ff_Field_F_halo2_proofs_plonk_circuit_Expression_F_for_alloc_vec_Vec_halo2_proofs_plonk_circuit_Constraint_F_alloc_alloc_Global. + + (* StructRecord + { + name := "Gate"; + ty_params := [ "F" ]; + fields := + [ + ("name", Ty.apply (Ty.path "&") [ Ty.path "str" ]); + ("constraint_names", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.apply (Ty.path "&") [ Ty.path "str" ]; Ty.path "alloc::alloc::Global" ]); + ("polys", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]); + ("queried_selectors", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "halo2_proofs::plonk::circuit::Selector"; Ty.path "alloc::alloc::Global" + ]); + ("queried_cells", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::VirtualCell"; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_for_halo2_proofs_plonk_circuit_Gate_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::plonk::circuit::Gate" + [ + ("name", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Gate", + "name" + |) + ] + |)); + ("constraint_names", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.apply (Ty.path "&") [ Ty.path "str" ]; Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Gate", + "constraint_names" + |) + ] + |)); + ("polys", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Gate", + "polys" + |) + ] + |)); + ("queried_selectors", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Gate", + "queried_selectors" + |) + ] + |)); + ("queried_cells", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::VirtualCell"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Gate", + "queried_cells" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_for_halo2_proofs_plonk_circuit_Gate_F. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_plonk_circuit_Gate_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field5_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Gate" |); + M.read (| Value.String "name" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Gate", + "name" + |)); + M.read (| Value.String "constraint_names" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Gate", + "constraint_names" + |)); + M.read (| Value.String "polys" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Gate", + "polys" + |)); + M.read (| Value.String "queried_selectors" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Gate", + "queried_selectors" + |)); + M.read (| Value.String "queried_cells" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Gate", + "queried_cells" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_plonk_circuit_Gate_F. + + Module Impl_halo2_proofs_plonk_circuit_Gate_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ]. + + (* + pub(crate) fn new_with_polys_and_queries( + polys: Vec>, + queried_cells: Vec, + ) -> Self { + Gate { + name: "", + constraint_names: vec![], + polys, + queried_cells, + queried_selectors: vec![], + } + } + *) + Definition new_with_polys_and_queries (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ polys; queried_cells ] => + ltac:(M.monadic + (let polys := M.alloc (| polys |) in + let queried_cells := M.alloc (| queried_cells |) in + Value.StructRecord + "halo2_proofs::plonk::circuit::Gate" + [ + ("name", M.read (| Value.String "" |)); + ("constraint_names", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.apply (Ty.path "&") [ Ty.path "str" ]; Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("polys", M.read (| polys |)); + ("queried_cells", M.read (| queried_cells |)); + ("queried_selectors", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new_with_polys_and_queries : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "new_with_polys_and_queries" (new_with_polys_and_queries F). + + (* + pub(crate) fn name(&self) -> &'static str { + self.name + } + *) + Definition name (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Gate", + "name" + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_name : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "name" (name F). + + (* + pub(crate) fn constraint_name(&self, constraint_index: usize) -> &'static str { + self.constraint_names[constraint_index] + } + *) + Definition constraint_name (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; constraint_index ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let constraint_index := M.alloc (| constraint_index |) in + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.apply (Ty.path "&") [ Ty.path "str" ]; Ty.path "alloc::alloc::Global" ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Gate", + "constraint_names" + |); + M.read (| constraint_index |) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_constraint_name : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "constraint_name" (constraint_name F). + + (* + pub(crate) fn polynomials(&self) -> &[Expression] { + &self.polys + } + *) + Definition polynomials (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Gate", + "polys" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_polynomials : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "polynomials" (polynomials F). + + (* + pub(crate) fn queried_selectors(&self) -> &[Selector] { + &self.queried_selectors + } + *) + Definition queried_selectors (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "halo2_proofs::plonk::circuit::Selector"; Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Gate", + "queried_selectors" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_queried_selectors : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "queried_selectors" (queried_selectors F). + + (* + pub(crate) fn queried_cells(&self) -> &[VirtualCell] { + &self.queried_cells + } + *) + Definition queried_cells (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::VirtualCell"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::Gate", + "queried_cells" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_queried_cells : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "queried_cells" (queried_cells F). + End Impl_halo2_proofs_plonk_circuit_Gate_F. + + (* StructRecord + { + name := "ConstraintSystem"; + ty_params := [ "F" ]; + fields := + [ + ("num_fixed_columns", Ty.path "usize"); + ("num_advice_columns", Ty.path "usize"); + ("num_instance_columns", Ty.path "usize"); + ("num_selectors", Ty.path "usize"); + ("selector_map", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ]); + ("gates", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ]; + Ty.path "alloc::alloc::Global" + ]); + ("advice_queries", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ]); + ("named_advices", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "alloc::string::String"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]); + ("num_advice_queries", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ]); + ("instance_queries", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ]); + ("fixed_queries", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ]); + ("permutation", Ty.path "halo2_proofs::plonk::permutation::Argument"); + ("lookups", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ]; + Ty.path "alloc::alloc::Global" + ]); + ("constants", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ]); + ("minimum_degree", Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_plonk_circuit_ConstraintSystem_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let names := + M.alloc (| + M.alloc (| + Value.Array + [ + M.read (| Value.String "num_fixed_columns" |); + M.read (| Value.String "num_advice_columns" |); + M.read (| Value.String "num_instance_columns" |); + M.read (| Value.String "num_selectors" |); + M.read (| Value.String "selector_map" |); + M.read (| Value.String "gates" |); + M.read (| Value.String "advice_queries" |); + M.read (| Value.String "named_advices" |); + M.read (| Value.String "num_advice_queries" |); + M.read (| Value.String "instance_queries" |); + M.read (| Value.String "fixed_queries" |); + M.read (| Value.String "permutation" |); + M.read (| Value.String "lookups" |); + M.read (| Value.String "constants" |); + M.read (| Value.String "minimum_degree" |) + ] + |) + |) in + let values := + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_fixed_columns" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_columns" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_instance_columns" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_selectors" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "selector_map" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "gates" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "advice_queries" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "named_advices" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_queries" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "instance_queries" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "fixed_queries" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "lookups" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "constants" + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "minimum_degree" + |) + |)) + ] + |)) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_fields_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "ConstraintSystem" |); + (* Unsize *) M.pointer_coercion (M.read (| names |)); + M.read (| values |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_plonk_circuit_ConstraintSystem_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_for_halo2_proofs_plonk_circuit_ConstraintSystem_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::plonk::circuit::ConstraintSystem" + [ + ("num_fixed_columns", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "usize", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_fixed_columns" + |) + ] + |)); + ("num_advice_columns", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "usize", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_columns" + |) + ] + |)); + ("num_instance_columns", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "usize", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_instance_columns" + |) + ] + |)); + ("num_selectors", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "usize", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_selectors" + |) + ] + |)); + ("selector_map", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "selector_map" + |) + ] + |)); + ("gates", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "gates" + |) + ] + |)); + ("advice_queries", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "advice_queries" + |) + ] + |)); + ("named_advices", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "alloc::string::String"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "named_advices" + |) + ] + |)); + ("num_advice_queries", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_queries" + |) + ] + |)); + ("instance_queries", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "instance_queries" + |) + ] + |)); + ("fixed_queries", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "fixed_queries" + |) + ] + |)); + ("permutation", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::permutation::Argument", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |) + ] + |)); + ("lookups", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "lookups" + |) + ] + |)); + ("constants", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "constants" + |) + ] + |)); + ("minimum_degree", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "minimum_degree" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_for_halo2_proofs_plonk_circuit_ConstraintSystem_F. + + (* StructRecord + { + name := "PinnedConstraintSystem"; + ty_params := [ "F" ]; + fields := + [ + ("num_fixed_columns", Ty.apply (Ty.path "&") [ Ty.path "usize" ]); + ("num_advice_columns", Ty.apply (Ty.path "&") [ Ty.path "usize" ]); + ("num_instance_columns", Ty.apply (Ty.path "&") [ Ty.path "usize" ]); + ("num_selectors", Ty.apply (Ty.path "&") [ Ty.path "usize" ]); + ("selector_map", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ] + ]); + ("gates", Ty.apply (Ty.path "halo2_proofs::plonk::circuit::PinnedGates") [ F ]); + ("advice_queries", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ] + ]); + ("instance_queries", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ] + ]); + ("fixed_queries", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ] + ]); + ("permutation", + Ty.apply (Ty.path "&") [ Ty.path "halo2_proofs::plonk::permutation::Argument" ]); + ("lookups", Ty.apply (Ty.path "halo2_proofs::plonk::circuit::PinnedLookups") [ F ]); + ("constants", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ] + ]); + ("minimum_degree", + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ] ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_plonk_circuit_PinnedConstraintSystem_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::PinnedConstraintSystem") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let names := + M.alloc (| + M.alloc (| + Value.Array + [ + M.read (| Value.String "num_fixed_columns" |); + M.read (| Value.String "num_advice_columns" |); + M.read (| Value.String "num_instance_columns" |); + M.read (| Value.String "num_selectors" |); + M.read (| Value.String "selector_map" |); + M.read (| Value.String "gates" |); + M.read (| Value.String "advice_queries" |); + M.read (| Value.String "instance_queries" |); + M.read (| Value.String "fixed_queries" |); + M.read (| Value.String "permutation" |); + M.read (| Value.String "lookups" |); + M.read (| Value.String "constants" |); + M.read (| Value.String "minimum_degree" |) + ] + |) + |) in + let values := + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::PinnedConstraintSystem", + "num_fixed_columns" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::PinnedConstraintSystem", + "num_advice_columns" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::PinnedConstraintSystem", + "num_instance_columns" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::PinnedConstraintSystem", + "num_selectors" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::PinnedConstraintSystem", + "selector_map" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::PinnedConstraintSystem", + "gates" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::PinnedConstraintSystem", + "advice_queries" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::PinnedConstraintSystem", + "instance_queries" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::PinnedConstraintSystem", + "fixed_queries" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::PinnedConstraintSystem", + "permutation" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::PinnedConstraintSystem", + "lookups" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::PinnedConstraintSystem", + "constants" + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::PinnedConstraintSystem", + "minimum_degree" + |) + |)) + ] + |)) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_fields_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "PinnedConstraintSystem" |); + (* Unsize *) M.pointer_coercion (M.read (| names |)); + M.read (| values |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_plonk_circuit_PinnedConstraintSystem_F. + + (* StructTuple + { + name := "PinnedLookups"; + ty_params := [ "F" ]; + fields := + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + } *) + + Module Impl_core_fmt_Debug_where_ff_Field_F_for_halo2_proofs_plonk_circuit_PinnedLookups_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::PinnedLookups") [ F ]. + + (* + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { + f.debug_list() + .entries(self.0.iter().enumerate().map(|(i, arg)| { + ( + format!("lookup{}", i), + &arg.input_expressions, + &arg.table_expressions, + ) + })) + .finish() + } + *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::builders::DebugList", + "finish", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::builders::DebugList", + "entries", + [ + Ty.tuple + [ + Ty.path "alloc::string::String"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ] ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ F ] + ] + ] + ] + ] + (Ty.tuple + [ + Ty.path "alloc::string::String"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]) + ] + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_list", + [] + |), + [ M.read (| f |) ] + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ] ] + ], + [], + "map", + [ + Ty.tuple + [ + Ty.path "alloc::string::String"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ F ] + ] + ] + ] + ] + (Ty.tuple + [ + Ty.path "alloc::string::String"; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ] ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::PinnedLookups", + 0 + |) + |) + ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let i := M.copy (| γ0_0 |) in + let arg := M.copy (| γ0_1 |) in + Value.Tuple + [ + M.read (| + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ M.read (| Value.String "lookup" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ i ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |); + M.SubPointer.get_struct_record_field (| + M.read (| arg |), + "halo2_proofs::plonk::lookup::Argument", + "input_expressions" + |); + M.SubPointer.get_struct_record_field (| + M.read (| arg |), + "halo2_proofs::plonk::lookup::Argument", + "table_expressions" + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_ff_Field_F_for_halo2_proofs_plonk_circuit_PinnedLookups_F. + + (* StructTuple + { + name := "PinnedGates"; + ty_params := [ "F" ]; + fields := + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + } *) + + Module Impl_core_fmt_Debug_where_ff_Field_F_for_halo2_proofs_plonk_circuit_PinnedGates_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::PinnedGates") [ F ]. + + (* + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { + f.debug_list() + .entries(self.0.iter().flat_map(|gate| gate.polynomials().iter())) + .finish() + } + *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::builders::DebugList", + "finish", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::builders::DebugList", + "entries", + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ] ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_list", + [] + |), + [ M.read (| f |) ] + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ] ], + [], + "flat_map", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ] ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::PinnedGates", + 0 + |) + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let gate := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ], + "polynomials", + [] + |), + [ M.read (| gate |) ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_ff_Field_F_for_halo2_proofs_plonk_circuit_PinnedGates_F. + + Module Impl_core_default_Default_where_ff_Field_F_for_halo2_proofs_plonk_circuit_ConstraintSystem_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ]. + + (* + fn default() -> ConstraintSystem { + ConstraintSystem { + num_fixed_columns: 0, + num_advice_columns: 0, + num_instance_columns: 0, + num_selectors: 0, + selector_map: vec![], + gates: vec![], + fixed_queries: Vec::new(), + advice_queries: Vec::new(), + named_advices: Vec::new(), + num_advice_queries: Vec::new(), + instance_queries: Vec::new(), + permutation: permutation::Argument::new(), + lookups: Vec::new(), + constants: vec![], + minimum_degree: None, + } + } + *) + Definition default (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [] => + ltac:(M.monadic + (Value.StructRecord + "halo2_proofs::plonk::circuit::ConstraintSystem" + [ + ("num_fixed_columns", Value.Integer 0); + ("num_advice_columns", Value.Integer 0); + ("num_instance_columns", Value.Integer 0); + ("num_selectors", Value.Integer 0); + ("selector_map", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("gates", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("fixed_queries", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("advice_queries", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("named_advices", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "alloc::string::String"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("num_advice_queries", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |)); + ("instance_queries", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("permutation", + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::permutation::Argument", + "new", + [] + |), + [] + |)); + ("lookups", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("constants", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("minimum_degree", Value.StructTuple "core::option::Option::None" []) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::default::Default" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("default", InstanceField.Method (default F)) ]. + End Impl_core_default_Default_where_ff_Field_F_for_halo2_proofs_plonk_circuit_ConstraintSystem_F. + + Module Impl_halo2_proofs_plonk_circuit_ConstraintSystem_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ]. + + (* + pub fn pinned(&self) -> PinnedConstraintSystem<'_, F> { + PinnedConstraintSystem { + num_fixed_columns: &self.num_fixed_columns, + num_advice_columns: &self.num_advice_columns, + num_instance_columns: &self.num_instance_columns, + num_selectors: &self.num_selectors, + selector_map: &self.selector_map, + gates: PinnedGates(&self.gates), + fixed_queries: &self.fixed_queries, + advice_queries: &self.advice_queries, + instance_queries: &self.instance_queries, + permutation: &self.permutation, + lookups: PinnedLookups(&self.lookups), + constants: &self.constants, + minimum_degree: &self.minimum_degree, + } + } + *) + Definition pinned (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::plonk::circuit::PinnedConstraintSystem" + [ + ("num_fixed_columns", + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_fixed_columns" + |)); + ("num_advice_columns", + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_columns" + |)); + ("num_instance_columns", + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_instance_columns" + |)); + ("num_selectors", + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_selectors" + |)); + ("selector_map", + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "selector_map" + |) + ] + |)); + ("gates", + Value.StructTuple + "halo2_proofs::plonk::circuit::PinnedGates" + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "gates" + |) + ]); + ("fixed_queries", + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "fixed_queries" + |)); + ("advice_queries", + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "advice_queries" + |)); + ("instance_queries", + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "instance_queries" + |)); + ("permutation", + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |)); + ("lookups", + Value.StructTuple + "halo2_proofs::plonk::circuit::PinnedLookups" + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "lookups" + |) + ]); + ("constants", + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "constants" + |)); + ("minimum_degree", + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "minimum_degree" + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_pinned : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "pinned" (pinned F). + + (* + pub fn enable_constant(&mut self, column: Column) { + if !self.constants.contains(&column) { + self.constants.push(column); + self.enable_equality(column); + } + } + *) + Definition enable_constant (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; column ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ], + "contains", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "constants" + |) + ] + |); + column + ] + |)) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "constants" + |); + M.read (| column |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "enable_equality", + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ] + |), + [ M.read (| self |); M.read (| column |) ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_enable_constant : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "enable_constant" (enable_constant F). + + (* + pub fn enable_equality>>(&mut self, column: C) { + let column = column.into(); + self.query_any_index(column, Rotation::cur()); + self.permutation.add_column(column); + } + *) + Definition enable_equality (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ C ], [ self; column ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + M.read (| + let column := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + C, + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "into", + [] + |), + [ M.read (| column |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "query_any_index", + [] + |), + [ + M.read (| self |); + M.read (| column |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::permutation::Argument", + "add_column", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |); + M.read (| column |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_enable_equality : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "enable_equality" (enable_equality F). + + (* + pub fn lookup( + &mut self, + name: &'static str, + table_map: impl FnOnce(&mut VirtualCells<'_, F>) -> Vec<(Expression, TableColumn)>, + ) -> usize { + let mut cells = VirtualCells::new(self); + let table_map = table_map(&mut cells) + .into_iter() + .map(|(input, table)| { + if input.contains_simple_selector() { + panic!("expression containing simple selector supplied to lookup argument"); + } + + let table = cells.query_fixed(table.inner(), Rotation::cur()); + + (input, table) + }) + .collect(); + + let index = self.lookups.len(); + + self.lookups.push(lookup::Argument::new(name, table_map)); + + index + } + *) + Definition lookup (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_FnOnce__mut_VirtualCells_'___F___arrow_Vec__Expression_F___TableColumn__ ], + [ self; name; table_map ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + let table_map := M.alloc (| table_map |) in + M.read (| + let cells := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") [ F ], + "new", + [] + |), + [ M.read (| self |) ] + |) + |) in + let table_map := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "halo2_proofs::plonk::circuit::TableColumn" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "halo2_proofs::plonk::circuit::TableColumn" + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "halo2_proofs::plonk::circuit::TableColumn" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "halo2_proofs::plonk::circuit::TableColumn" + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "halo2_proofs::plonk::circuit::TableColumn" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow_Vec__Expression_F___TableColumn__, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ M.read (| table_map |); Value.Tuple [ cells ] ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let input := M.copy (| γ0_0 |) in + let table := M.copy (| γ0_1 |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + "contains_simple_selector", + [] + |), + [ input ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "std::panicking::begin_panic", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + Value.String + "expression containing simple selector supplied to lookup argument" + |) + ] + |) + |) + |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let table := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + cells; + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::plonk::circuit::TableColumn", + "inner", + [] + |), + [ table ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [ M.read (| input |); M.read (| table |) ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "lookups" + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "lookups" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ], + "new", + [] + |), + [ M.read (| name |); M.read (| table_map |) ] + |) + ] + |) + |) in + index + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_lookup : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "lookup" (lookup F). + + (* + pub fn lookup_any( + &mut self, + name: &'static str, + table_map: impl FnOnce(&mut VirtualCells<'_, F>) -> Vec<(Expression, Expression)>, + ) -> usize { + let mut cells = VirtualCells::new(self); + let table_map = table_map(&mut cells); + + let index = self.lookups.len(); + + self.lookups.push(lookup::Argument::new(name, table_map)); + + index + } + *) + Definition lookup_any (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_FnOnce__mut_VirtualCells_'___F___arrow_Vec__Expression_F___Expression_F___ ], + [ self; name; table_map ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + let table_map := M.alloc (| table_map |) in + M.read (| + let cells := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") [ F ], + "new", + [] + |), + [ M.read (| self |) ] + |) + |) in + let table_map := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow_Vec__Expression_F___Expression_F___, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ M.read (| table_map |); Value.Tuple [ cells ] ] + |) + |) in + let index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "lookups" + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "lookups" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ], + "new", + [] + |), + [ M.read (| name |); M.read (| table_map |) ] + |) + ] + |) + |) in + index + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_lookup_any : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "lookup_any" (lookup_any F). + + (* + fn query_fixed_index(&mut self, column: Column, at: Rotation) -> usize { + // Return existing query, if it exists + for (index, fixed_query) in self.fixed_queries.iter().enumerate() { + if fixed_query == &(column, at) { + return index; + } + } + + // Make a new query + let index = self.fixed_queries.len(); + self.fixed_queries.push((column, at)); + + index + } + *) + Definition query_fixed_index (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; column; at_ ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + let at_ := M.alloc (| at_ |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "fixed_queries" + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let index := M.copy (| γ1_0 |) in + let fixed_query := M.copy (| γ1_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ], + "eq", + [] + |), + [ + fixed_query; + M.alloc (| + M.alloc (| + Value.Tuple + [ + M.read (| column |); + M.read (| at_ |) + ] + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| M.read (| index |) |) + |) + |) + |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "fixed_queries" + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "fixed_queries" + |); + Value.Tuple [ M.read (| column |); M.read (| at_ |) ] + ] + |) + |) in + index + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_query_fixed_index : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "query_fixed_index" (query_fixed_index F). + + (* + pub(crate) fn query_advice_index(&mut self, column: Column, at: Rotation) -> usize { + // Return existing query, if it exists + for (index, advice_query) in self.advice_queries.iter().enumerate() { + if advice_query == &(column, at) { + return index; + } + } + + // Make a new query + let index = self.advice_queries.len(); + self.advice_queries.push((column, at)); + self.num_advice_queries[column.index] += 1; + + index + } + *) + Definition query_advice_index (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; column; at_ ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + let at_ := M.alloc (| at_ |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "advice_queries" + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let index := M.copy (| γ1_0 |) in + let advice_query := M.copy (| γ1_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ], + "eq", + [] + |), + [ + advice_query; + M.alloc (| + M.alloc (| + Value.Tuple + [ + M.read (| column |); + M.read (| at_ |) + ] + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| M.read (| index |) |) + |) + |) + |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "advice_queries" + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "advice_queries" + |); + Value.Tuple [ M.read (| column |); M.read (| at_ |) ] + ] + |) + |) in + let _ := + let β := + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_queries" + |); + M.read (| + M.SubPointer.get_struct_record_field (| + column, + "halo2_proofs::plonk::circuit::Column", + "index" + |) + |) + ] + |) in + M.write (| + β, + BinOp.Panic.add (| Integer.Usize, M.read (| β |), Value.Integer 1 |) + |) in + index + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_query_advice_index : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "query_advice_index" (query_advice_index F). + + (* + fn query_instance_index(&mut self, column: Column, at: Rotation) -> usize { + // Return existing query, if it exists + for (index, instance_query) in self.instance_queries.iter().enumerate() { + if instance_query == &(column, at) { + return index; + } + } + + // Make a new query + let index = self.instance_queries.len(); + self.instance_queries.push((column, at)); + + index + } + *) + Definition query_instance_index (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; column; at_ ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + let at_ := M.alloc (| at_ |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "instance_queries" + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let index := M.copy (| γ1_0 |) in + let instance_query := M.copy (| γ1_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ], + "eq", + [] + |), + [ + instance_query; + M.alloc (| + M.alloc (| + Value.Tuple + [ + M.read (| column |); + M.read (| at_ |) + ] + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| M.read (| index |) |) + |) + |) + |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "instance_queries" + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "instance_queries" + |); + Value.Tuple [ M.read (| column |); M.read (| at_ |) ] + ] + |) + |) in + index + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_query_instance_index : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "query_instance_index" (query_instance_index F). + + (* + fn query_any_index(&mut self, column: Column, at: Rotation) -> usize { + match column.column_type() { + Any::Advice => self.query_advice_index(Column::::try_from(column).unwrap(), at), + Any::Fixed => self.query_fixed_index(Column::::try_from(column).unwrap(), at), + Any::Instance => { + self.query_instance_index(Column::::try_from(column).unwrap(), at) + } + } + } + *) + Definition query_any_index (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; column; at_ ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + let at_ := M.alloc (| at_ |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + "column_type", + [] + |), + [ column ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "query_advice_index", + [] + |), + [ + M.read (| self |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::TryFrom", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "try_from", + [] + |), + [ M.read (| column |) ] + |) + ] + |); + M.read (| at_ |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "query_fixed_index", + [] + |), + [ + M.read (| self |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::TryFrom", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "try_from", + [] + |), + [ M.read (| column |) ] + |) + ] + |); + M.read (| at_ |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "query_instance_index", + [] + |), + [ + M.read (| self |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ]; + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::TryFrom", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "try_from", + [] + |), + [ M.read (| column |) ] + |) + ] + |); + M.read (| at_ |) + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_query_any_index : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "query_any_index" (query_any_index F). + + (* + pub(crate) fn get_advice_query_index(&self, column: Column, at: Rotation) -> usize { + for (index, advice_query) in self.advice_queries.iter().enumerate() { + if advice_query == &(column, at) { + return index; + } + } + + panic!("get_advice_query_index called for non-existent query"); + } + *) + Definition get_advice_query_index (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; column; at_ ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + let at_ := M.alloc (| at_ |) in + M.catch_return (| + ltac:(M.monadic + (M.never_to_any (| + M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "advice_queries" + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let index := M.copy (| γ1_0 |) in + let advice_query := M.copy (| γ1_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ], + "eq", + [] + |), + [ + advice_query; + M.alloc (| + M.alloc (| + Value.Tuple + [ + M.read (| column |); + M.read (| at_ |) + ] + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| M.read (| index |) |) + |) + |) + |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + M.call_closure (| + M.get_function (| + "std::panicking::begin_panic", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + M.read (| + Value.String "get_advice_query_index called for non-existent query" + |) + ] + |) + |) + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get_advice_query_index : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "get_advice_query_index" (get_advice_query_index F). + + (* + pub(crate) fn get_fixed_query_index(&self, column: Column, at: Rotation) -> usize { + for (index, fixed_query) in self.fixed_queries.iter().enumerate() { + if fixed_query == &(column, at) { + return index; + } + } + + panic!("get_fixed_query_index called for non-existent query"); + } + *) + Definition get_fixed_query_index (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; column; at_ ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + let at_ := M.alloc (| at_ |) in + M.catch_return (| + ltac:(M.monadic + (M.never_to_any (| + M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "fixed_queries" + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let index := M.copy (| γ1_0 |) in + let fixed_query := M.copy (| γ1_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ], + "eq", + [] + |), + [ + fixed_query; + M.alloc (| + M.alloc (| + Value.Tuple + [ + M.read (| column |); + M.read (| at_ |) + ] + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| M.read (| index |) |) + |) + |) + |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + M.call_closure (| + M.get_function (| + "std::panicking::begin_panic", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + M.read (| + Value.String "get_fixed_query_index called for non-existent query" + |) + ] + |) + |) + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get_fixed_query_index : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "get_fixed_query_index" (get_fixed_query_index F). + + (* + pub(crate) fn get_instance_query_index(&self, column: Column, at: Rotation) -> usize { + for (index, instance_query) in self.instance_queries.iter().enumerate() { + if instance_query == &(column, at) { + return index; + } + } + + panic!("get_instance_query_index called for non-existent query"); + } + *) + Definition get_instance_query_index (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; column; at_ ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + let at_ := M.alloc (| at_ |) in + M.catch_return (| + ltac:(M.monadic + (M.never_to_any (| + M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "instance_queries" + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let index := M.copy (| γ1_0 |) in + let instance_query := M.copy (| γ1_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ], + "eq", + [] + |), + [ + instance_query; + M.alloc (| + M.alloc (| + Value.Tuple + [ + M.read (| column |); + M.read (| at_ |) + ] + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| M.read (| index |) |) + |) + |) + |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + M.call_closure (| + M.get_function (| + "std::panicking::begin_panic", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + M.read (| + Value.String "get_instance_query_index called for non-existent query" + |) + ] + |) + |) + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get_instance_query_index : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "get_instance_query_index" (get_instance_query_index F). + + (* + pub fn get_any_query_index(&self, column: Column, at: Rotation) -> usize { + match column.column_type() { + Any::Advice => { + self.get_advice_query_index(Column::::try_from(column).unwrap(), at) + } + Any::Fixed => { + self.get_fixed_query_index(Column::::try_from(column).unwrap(), at) + } + Any::Instance => { + self.get_instance_query_index(Column::::try_from(column).unwrap(), at) + } + } + } + *) + Definition get_any_query_index (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; column; at_ ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + let at_ := M.alloc (| at_ |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + "column_type", + [] + |), + [ column ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "get_advice_query_index", + [] + |), + [ + M.read (| self |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::TryFrom", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "try_from", + [] + |), + [ M.read (| column |) ] + |) + ] + |); + M.read (| at_ |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "get_fixed_query_index", + [] + |), + [ + M.read (| self |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::TryFrom", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "try_from", + [] + |), + [ M.read (| column |) ] + |) + ] + |); + M.read (| at_ |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "get_instance_query_index", + [] + |), + [ + M.read (| self |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ]; + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::TryFrom", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "try_from", + [] + |), + [ M.read (| column |) ] + |) + ] + |); + M.read (| at_ |) + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get_any_query_index : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "get_any_query_index" (get_any_query_index F). + + (* + pub fn set_minimum_degree(&mut self, degree: usize) { + self.minimum_degree = Some(degree); + } + *) + Definition set_minimum_degree (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; degree ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let degree := M.alloc (| degree |) in + M.read (| + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "minimum_degree" + |), + Value.StructTuple "core::option::Option::Some" [ M.read (| degree |) ] + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_set_minimum_degree : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "set_minimum_degree" (set_minimum_degree F). + + (* + pub fn create_gate>, Iter: IntoIterator>( + &mut self, + name: &'static str, + constraints: impl FnOnce(&mut VirtualCells<'_, F>) -> Iter, + ) { + let mut cells = VirtualCells::new(self); + let constraints = constraints(&mut cells); + let queried_selectors = cells.queried_selectors; + let queried_cells = cells.queried_cells; + + let (constraint_names, polys): (_, Vec<_>) = constraints + .into_iter() + .map(|c| c.into()) + .map(|c| (c.name, c.poly)) + .unzip(); + + assert!( + !polys.is_empty(), + "Gates must contain at least one constraint." + ); + + self.gates.push(Gate { + name, + constraint_names, + polys, + queried_selectors, + queried_cells, + }); + } + *) + Definition create_gate (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ C; Iter; impl_FnOnce__mut_VirtualCells_'___F___arrow_Iter ], + [ self; name; constraints ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + let constraints := M.alloc (| constraints |) in + M.read (| + let cells := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") [ F ], + "new", + [] + |), + [ M.read (| self |) ] + |) + |) in + let constraints := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow_Iter, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ M.read (| constraints |); Value.Tuple [ cells ] ] + |) + |) in + let queried_selectors := + M.copy (| + M.SubPointer.get_struct_record_field (| + cells, + "halo2_proofs::plonk::circuit::VirtualCells", + "queried_selectors" + |) + |) in + let queried_cells := + M.copy (| + M.SubPointer.get_struct_record_field (| + cells, + "halo2_proofs::plonk::circuit::VirtualCells", + "queried_cells" + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.associated; + Ty.function + [ Ty.tuple [ C ] ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Constraint") + [ F ]) + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Constraint") + [ F ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ], + [], + "unzip", + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.apply (Ty.path "&") [ Ty.path "str" ]; Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.associated; + Ty.function + [ Ty.tuple [ C ] ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Constraint") + [ F ]) + ], + [], + "map", + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Constraint") + [ F ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.associated, + [], + "map", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Constraint") [ F ]; + Ty.function + [ Ty.tuple [ C ] ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Constraint") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Iter, + [], + "into_iter", + [] + |), + [ M.read (| constraints |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let c := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + C, + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Constraint") + [ F ] + ], + "into", + [] + |), + [ M.read (| c |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let c := M.copy (| γ |) in + Value.Tuple + [ + M.read (| + M.SubPointer.get_struct_record_field (| + c, + "halo2_proofs::plonk::circuit::Constraint", + "name" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + c, + "halo2_proofs::plonk::circuit::Constraint", + "poly" + |) + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let constraint_names := M.copy (| γ0_0 |) in + let polys := M.copy (| γ0_1 |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "is_empty", + [] + |), + [ polys ] + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "std::panicking::begin_panic", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + M.read (| + Value.String "Gates must contain at least one constraint." + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "gates" + |); + Value.StructRecord + "halo2_proofs::plonk::circuit::Gate" + [ + ("name", M.read (| name |)); + ("constraint_names", M.read (| constraint_names |)); + ("polys", M.read (| polys |)); + ("queried_selectors", M.read (| queried_selectors |)); + ("queried_cells", M.read (| queried_cells |)) + ] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_create_gate : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "create_gate" (create_gate F). + + (* + pub(crate) fn compress_selectors(mut self, selectors: Vec>) -> (Self, Vec>) { + // The number of provided selector assignments must be the number we + // counted for this constraint system. + assert_eq!(selectors.len(), self.num_selectors); + + // Compute the maximal degree of every selector. We only consider the + // expressions in gates, as lookup arguments cannot support simple + // selectors. Selectors that are complex or do not appear in any gates + // will have degree zero. + let mut degrees = vec![0; selectors.len()]; + for expr in self.gates.iter().flat_map(|gate| gate.polys.iter()) { + if let Some(selector) = expr.extract_simple_selector() { + degrees[selector.0] = max(degrees[selector.0], expr.degree()); + } + } + + // We will not increase the degree of the constraint system, so we limit + // ourselves to the largest existing degree constraint. + let max_degree = self.degree(); + + let mut new_columns = vec![]; + let (polys, selector_assignment) = compress_selectors::process( + selectors + .into_iter() + .zip(degrees.into_iter()) + .enumerate() + .map( + |(i, (activations, max_degree))| compress_selectors::SelectorDescription { + selector: i, + activations, + max_degree, + }, + ) + .collect(), + max_degree, + || { + let column = self.fixed_column(); + new_columns.push(column); + Expression::Fixed { + query_index: self.query_fixed_index(column, Rotation::cur()), + column_index: column.index, + rotation: Rotation::cur(), + } + }, + ); + + let mut selector_map = vec![None; selector_assignment.len()]; + let mut selector_replacements = vec![None; selector_assignment.len()]; + for assignment in selector_assignment { + selector_replacements[assignment.selector] = Some(assignment.expression); + selector_map[assignment.selector] = Some(new_columns[assignment.combination_index]); + } + + self.selector_map = selector_map + .into_iter() + .map(|a| a.unwrap()) + .collect::>(); + let selector_replacements = selector_replacements + .into_iter() + .map(|a| a.unwrap()) + .collect::>(); + + fn replace_selectors( + expr: &mut Expression, + selector_replacements: &[Expression], + must_be_nonsimple: bool, + ) { + *expr = expr.evaluate( + &|constant| Expression::Constant(constant), + &|selector| { + if must_be_nonsimple { + // Simple selectors are prohibited from appearing in + // expressions in the lookup argument by + // `ConstraintSystem`. + assert!(!selector.is_simple()); + } + + selector_replacements[selector.0].clone() + }, + &|query_index, column_index, rotation| Expression::Fixed { + query_index, + column_index, + rotation, + }, + &|query_index, column_index, rotation| Expression::Advice { + query_index, + column_index, + rotation, + }, + &|query_index, column_index, rotation| Expression::Instance { + query_index, + column_index, + rotation, + }, + &|a| -a, + &|a, b| a + b, + &|a, b| a() * b(), + &|a, f| a * f, + ); + } + + // Substitute selectors for the real fixed columns in all gates + for expr in self.gates.iter_mut().flat_map(|gate| gate.polys.iter_mut()) { + replace_selectors(expr, &selector_replacements, false); + } + + // Substitute non-simple selectors for the real fixed columns in all + // lookup expressions + for expr in self.lookups.iter_mut().flat_map(|lookup| { + lookup + .input_expressions + .iter_mut() + .chain(lookup.table_expressions.iter_mut()) + }) { + replace_selectors(expr, &selector_replacements, true); + } + + (self, polys) + } + *) + Definition compress_selectors (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; selectors ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let selectors := M.alloc (| selectors |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ selectors ] + |) + |); + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_selectors" + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let degrees := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ Ty.path "usize" ] |), + [ + Value.Integer 0; + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ selectors ] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ] ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]) + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ] ], + [], + "flat_map", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "gates" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let gate := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| gate |), + "halo2_proofs::plonk::circuit::Gate", + "polys" + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]) + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let expr := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + "extract_simple_selector", + [] + |), + [ M.read (| expr |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let selector := M.copy (| γ0_0 |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + degrees; + M.read (| + M.SubPointer.get_struct_tuple_field (| + selector, + "halo2_proofs::plonk::circuit::Selector", + 0 + |) + |) + ] + |), + M.call_closure (| + M.get_function (| + "core::cmp::max", + [ Ty.path "usize" ] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + degrees; + M.read (| + M.SubPointer.get_struct_tuple_field (| + selector, + "halo2_proofs::plonk::circuit::Selector", + 0 + |) + |) + ] + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + "degree", + [] + |), + [ M.read (| expr |) ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let max_degree := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "degree", + [] + |), + [ self ] + |) + |) in + let new_columns := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::circuit::compress_selectors::process", + [ + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "usize" + ] + ] + ] + ] + (Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription") + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ] + ] + ], + [], + "map", + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription"; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" + ]; + Ty.path "usize" + ] + ] + ] + ] + (Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "zip", + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| selectors |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ], + [], + "into_iter", + [] + |), + [ M.read (| degrees |) ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let i := M.copy (| γ0_0 |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_1, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_1, 1 |) in + let activations := M.copy (| γ1_0 |) in + let max_degree := M.copy (| γ1_1 |) in + Value.StructRecord + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + [ + ("selector", M.read (| i |)); + ("activations", M.read (| activations |)); + ("max_degree", M.read (| max_degree |)) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |); + M.read (| max_degree |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let column := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "fixed_column", + [] + |), + [ self ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ new_columns; M.read (| column |) ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::circuit::Expression::Fixed" + [ + ("query_index", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "query_fixed_index", + [] + |), + [ + self; + M.read (| column |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |)); + ("column_index", + M.read (| + M.SubPointer.get_struct_record_field (| + column, + "halo2_proofs::plonk::circuit::Column", + "index" + |) + |)); + ("rotation", + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |)) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let polys := M.copy (| γ0_0 |) in + let selector_assignment := M.copy (| γ0_1 |) in + let selector_map := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ] + ] + |), + [ + Value.StructTuple "core::option::Option::None" []; + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ selector_assignment ] + |) + ] + |) + |) in + let selector_replacements := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + |), + [ + Value.StructTuple "core::option::Option::None" []; + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ selector_assignment ] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| selector_assignment |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let assignment := M.copy (| γ0_0 |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + selector_replacements; + M.read (| + M.SubPointer.get_struct_record_field (| + assignment, + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment", + "selector" + |) + |) + ] + |), + Value.StructTuple + "core::option::Option::Some" + [ + M.read (| + M.SubPointer.get_struct_record_field (| + assignment, + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment", + "expression" + |) + |) + ] + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + selector_map; + M.read (| + M.SubPointer.get_struct_record_field (| + assignment, + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment", + "selector" + |) + |) + ] + |), + Value.StructTuple + "core::option::Option::Some" + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + new_columns; + M.read (| + M.SubPointer.get_struct_record_field (| + assignment, + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment", + "combination_index" + |) + |) + ] + |) + |) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "selector_map" + |), + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| selector_map |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ] + ], + "unwrap", + [] + |), + [ M.read (| a |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let selector_replacements := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| selector_replacements |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "unwrap", + [] + |), + [ M.read (| a |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ]; + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]) + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "gates" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let gate := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| gate |), + "halo2_proofs::plonk::circuit::Gate", + "polys" + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ]; + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]) + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let expr := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Self, + "replace_selectors.compress_selectors", + [] + |), + [ + M.read (| expr |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ selector_replacements ] + |); + Value.Bool false + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ F ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]) + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ F ] + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ F ] + ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "lookups" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let lookup := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| lookup |), + "halo2_proofs::plonk::lookup::Argument", + "input_expressions" + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| lookup |), + "halo2_proofs::plonk::lookup::Argument", + "table_expressions" + |) + ] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ F ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]) + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let expr := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Self, + "replace_selectors.compress_selectors", + [] + |), + [ + M.read (| expr |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ selector_replacements ] + |); + Value.Bool true + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| polys |) ] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_compress_selectors : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "compress_selectors" (compress_selectors F). + + (* + pub fn selector(&mut self) -> Selector { + let index = self.num_selectors; + self.num_selectors += 1; + Selector(index, true) + } + *) + Definition selector (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let index := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_selectors" + |) + |) in + let _ := + let β := + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_selectors" + |) in + M.write (| + β, + BinOp.Panic.add (| Integer.Usize, M.read (| β |), Value.Integer 1 |) + |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::circuit::Selector" + [ M.read (| index |); Value.Bool true ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_selector : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "selector" (selector F). + + (* + pub fn complex_selector(&mut self) -> Selector { + let index = self.num_selectors; + self.num_selectors += 1; + Selector(index, false) + } + *) + Definition complex_selector (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let index := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_selectors" + |) + |) in + let _ := + let β := + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_selectors" + |) in + M.write (| + β, + BinOp.Panic.add (| Integer.Usize, M.read (| β |), Value.Integer 1 |) + |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::circuit::Selector" + [ M.read (| index |); Value.Bool false ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_complex_selector : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "complex_selector" (complex_selector F). + + (* + pub fn lookup_table_column(&mut self) -> TableColumn { + TableColumn { + inner: self.fixed_column(), + } + } + *) + Definition lookup_table_column (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::plonk::circuit::TableColumn" + [ + ("inner", + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "fixed_column", + [] + |), + [ M.read (| self |) ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_lookup_table_column : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "lookup_table_column" (lookup_table_column F). + + (* + pub fn fixed_column(&mut self) -> Column { + let tmp = Column { + index: self.num_fixed_columns, + column_type: Fixed, + }; + self.num_fixed_columns += 1; + tmp + } + *) + Definition fixed_column (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let tmp := + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::circuit::Column" + [ + ("index", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_fixed_columns" + |) + |)); + ("column_type", Value.StructTuple "halo2_proofs::plonk::circuit::Fixed" []) + ] + |) in + let _ := + let β := + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_fixed_columns" + |) in + M.write (| + β, + BinOp.Panic.add (| Integer.Usize, M.read (| β |), Value.Integer 1 |) + |) in + tmp + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_fixed_column : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "fixed_column" (fixed_column F). + + (* + pub fn advice_column(&mut self) -> Column { + let tmp = Column { + index: self.num_advice_columns, + column_type: Advice, + }; + self.num_advice_columns += 1; + self.num_advice_queries.push(0); + tmp + } + *) + Definition advice_column (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let tmp := + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::circuit::Column" + [ + ("index", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_columns" + |) + |)); + ("column_type", Value.StructTuple "halo2_proofs::plonk::circuit::Advice" []) + ] + |) in + let _ := + let β := + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_columns" + |) in + M.write (| + β, + BinOp.Panic.add (| Integer.Usize, M.read (| β |), Value.Integer 1 |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_queries" + |); + Value.Integer 0 + ] + |) + |) in + tmp + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_advice_column : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "advice_column" (advice_column F). + + (* + pub fn named_advice_column(&mut self, name: String) -> Column { + let res = Column { + index: self.num_advice_columns, + column_type: Advice, + }; + self.named_advices + .push((name, self.num_advice_columns as u32)); + self.num_advice_columns += 1; + self.num_advice_queries.push(0); + res + } + *) + Definition named_advice_column (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; name ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + M.read (| + let res := + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::circuit::Column" + [ + ("index", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_columns" + |) + |)); + ("column_type", Value.StructTuple "halo2_proofs::plonk::circuit::Advice" []) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "alloc::string::String"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "named_advices" + |); + Value.Tuple + [ + M.read (| name |); + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_columns" + |) + |)) + ] + ] + |) + |) in + let _ := + let β := + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_columns" + |) in + M.write (| + β, + BinOp.Panic.add (| Integer.Usize, M.read (| β |), Value.Integer 1 |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_queries" + |); + Value.Integer 0 + ] + |) + |) in + res + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_named_advice_column : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "named_advice_column" (named_advice_column F). + + (* + pub fn instance_column(&mut self) -> Column { + let tmp = Column { + index: self.num_instance_columns, + column_type: Instance, + }; + self.num_instance_columns += 1; + tmp + } + *) + Definition instance_column (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let tmp := + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::circuit::Column" + [ + ("index", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_instance_columns" + |) + |)); + ("column_type", Value.StructTuple "halo2_proofs::plonk::circuit::Instance" []) + ] + |) in + let _ := + let β := + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_instance_columns" + |) in + M.write (| + β, + BinOp.Panic.add (| Integer.Usize, M.read (| β |), Value.Integer 1 |) + |) in + tmp + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_instance_column : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "instance_column" (instance_column F). + + (* + pub fn degree(&self) -> usize { + // The permutation argument will serve alongside the gates, so must be + // accounted for. + let mut degree = self.permutation.required_degree(); + + // The lookup argument also serves alongside the gates and must be accounted + // for. + degree = std::cmp::max( + degree, + self.lookups + .iter() + .map(|l| l.required_degree()) + .max() + .unwrap_or(1), + ); + + // Account for each gate to ensure our quotient polynomial is the + // correct degree and that our extended domain is the right size. + degree = std::cmp::max( + degree, + self.gates + .iter() + .flat_map(|gate| gate.polynomials().iter().map(|poly| poly.degree())) + .max() + .unwrap_or(0), + ); + + std::cmp::max(degree, self.minimum_degree.unwrap_or(1)) + } + *) + Definition degree (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let degree := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::permutation::Argument", + "required_degree", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |) + ] + |) + |) in + let _ := + M.write (| + degree, + M.call_closure (| + M.get_function (| "core::cmp::max", [ Ty.path "usize" ] |), + [ + M.read (| degree |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ F ] + ] + ] + ] + (Ty.path "usize") + ], + [], + "max", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ F ] + ], + [], + "map", + [ + Ty.path "usize"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ F ] + ] + ] + ] + (Ty.path "usize") + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "lookups" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let l := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ F ], + "required_degree", + [] + |), + [ M.read (| l |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |); + Value.Integer 1 + ] + |) + ] + |) + |) in + let _ := + M.write (| + degree, + M.call_closure (| + M.get_function (| "core::cmp::max", [ Ty.path "usize" ] |), + [ + M.read (| degree |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + (Ty.path "usize") + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + (Ty.path "usize") + ]) + ], + [], + "max", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Gate") [ F ] + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + (Ty.path "usize") + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + (Ty.path "usize") + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "gates" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let gate := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + [], + "map", + [ + Ty.path "usize"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + (Ty.path "usize") + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ F ], + "polynomials", + [] + |), + [ M.read (| gate |) ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let poly := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + "degree", + [] + |), + [ M.read (| poly |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |); + Value.Integer 0 + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_function (| "core::cmp::max", [ Ty.path "usize" ] |), + [ + M.read (| degree |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ], + "unwrap_or", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "minimum_degree" + |) + |); + Value.Integer 1 + ] + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_degree : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "degree" (degree F). + + (* + pub fn blinding_factors(&self) -> usize { + // All of the prover's advice columns are evaluated at no more than + let factors = *self.num_advice_queries.iter().max().unwrap_or(&1); + // distinct points during gate checks. + + // - The permutation argument witness polynomials are evaluated at most 3 times. + // - Each lookup argument has independent witness polynomials, and they are + // evaluated at most 2 times. + let factors = std::cmp::max(3, factors); + + // Each polynomial is evaluated at most an additional time during + // multiopen (at x_3 to produce q_evals): + let factors = factors + 1; + + // h(x) is derived by the other evaluations so it does not reveal + // anything; in fact it does not even appear in the proof. + + // h(x_3) is also not revealed; the verifier only learns a single + // evaluation of a polynomial in x_1 which has h(x_3) and another random + // polynomial evaluated at x_3 as coefficients -- this random polynomial + // is "random_poly" in the vanishing argument. + + // Add an additional blinding factor as a slight defense against + // off-by-one errors. + factors + 1 + } + *) + Definition blinding_factors (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let factors := + M.copy (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.path "usize" ] ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.path "usize" ], + [], + "max", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "usize" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_queries" + |) + ] + |) + ] + |) + ] + |); + M.alloc (| Value.Integer 1 |) + ] + |) + |) in + let factors := + M.alloc (| + M.call_closure (| + M.get_function (| "core::cmp::max", [ Ty.path "usize" ] |), + [ Value.Integer 3; M.read (| factors |) ] + |) + |) in + let factors := + M.alloc (| + BinOp.Panic.add (| Integer.Usize, M.read (| factors |), Value.Integer 1 |) + |) in + M.alloc (| + BinOp.Panic.add (| Integer.Usize, M.read (| factors |), Value.Integer 1 |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_blinding_factors : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "blinding_factors" (blinding_factors F). + + (* + pub fn minimum_rows(&self) -> usize { + self.blinding_factors() // m blinding factors + + 1 // for l_{-(m + 1)} (l_last) + + 1 // for l_0 (just for extra breathing room for the permutation + // argument, to essentially force a separation in the + // permutation polynomial between the roles of l_last, l_0 + // and the interstitial values.) + + 1 // for at least one row + } + *) + Definition minimum_rows (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "blinding_factors", + [] + |), + [ M.read (| self |) ] + |), + Value.Integer 1 + |), + Value.Integer 1 + |), + Value.Integer 1 + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_minimum_rows : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "minimum_rows" (minimum_rows F). + End Impl_halo2_proofs_plonk_circuit_ConstraintSystem_F. + + (* StructRecord + { + name := "VirtualCells"; + ty_params := [ "F" ]; + fields := + [ + ("meta", + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ] ]); + ("queried_selectors", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "halo2_proofs::plonk::circuit::Selector"; Ty.path "alloc::alloc::Global" + ]); + ("queried_cells", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::VirtualCell"; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_plonk_circuit_VirtualCells_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "VirtualCells" |); + M.read (| Value.String "meta" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::VirtualCells", + "meta" + |)); + M.read (| Value.String "queried_selectors" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::VirtualCells", + "queried_selectors" + |)); + M.read (| Value.String "queried_cells" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::VirtualCells", + "queried_cells" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_plonk_circuit_VirtualCells_F. + + Module Impl_halo2_proofs_plonk_circuit_VirtualCells_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") [ F ]. + + (* + fn new(meta: &'a mut ConstraintSystem) -> Self { + VirtualCells { + meta, + queried_selectors: vec![], + queried_cells: vec![], + } + } + *) + Definition new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ meta ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + Value.StructRecord + "halo2_proofs::plonk::circuit::VirtualCells" + [ + ("meta", M.read (| meta |)); + ("queried_selectors", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("queried_cells", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::VirtualCell"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "new" (new F). + + (* + pub fn query_selector(&mut self, selector: Selector) -> Expression { + self.queried_selectors.push(selector); + Expression::Selector(selector) + } + *) + Definition query_selector (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; selector ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let selector := M.alloc (| selector |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::Selector"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::VirtualCells", + "queried_selectors" + |); + M.read (| selector |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Selector" + [ M.read (| selector |) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_query_selector : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "query_selector" (query_selector F). + + (* + pub fn query_fixed(&mut self, column: Column, at: Rotation) -> Expression { + self.queried_cells.push((column, at).into()); + Expression::Fixed { + query_index: self.meta.query_fixed_index(column, at), + column_index: column.index, + rotation: at, + } + } + *) + Definition query_fixed (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; column; at_ ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + let at_ := M.alloc (| at_ |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::VirtualCell"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::VirtualCells", + "queried_cells" + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "halo2_proofs::poly::Rotation" + ], + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" ], + "into", + [] + |), + [ Value.Tuple [ M.read (| column |); M.read (| at_ |) ] ] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::circuit::Expression::Fixed" + [ + ("query_index", + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "query_fixed_index", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::VirtualCells", + "meta" + |) + |); + M.read (| column |); + M.read (| at_ |) + ] + |)); + ("column_index", + M.read (| + M.SubPointer.get_struct_record_field (| + column, + "halo2_proofs::plonk::circuit::Column", + "index" + |) + |)); + ("rotation", M.read (| at_ |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_query_fixed : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "query_fixed" (query_fixed F). + + (* + pub fn query_advice(&mut self, column: Column, at: Rotation) -> Expression { + self.queried_cells.push((column, at).into()); + Expression::Advice { + query_index: self.meta.query_advice_index(column, at), + column_index: column.index, + rotation: at, + } + } + *) + Definition query_advice (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; column; at_ ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + let at_ := M.alloc (| at_ |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::VirtualCell"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::VirtualCells", + "queried_cells" + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "halo2_proofs::poly::Rotation" + ], + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" ], + "into", + [] + |), + [ Value.Tuple [ M.read (| column |); M.read (| at_ |) ] ] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::circuit::Expression::Advice" + [ + ("query_index", + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "query_advice_index", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::VirtualCells", + "meta" + |) + |); + M.read (| column |); + M.read (| at_ |) + ] + |)); + ("column_index", + M.read (| + M.SubPointer.get_struct_record_field (| + column, + "halo2_proofs::plonk::circuit::Column", + "index" + |) + |)); + ("rotation", M.read (| at_ |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_query_advice : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "query_advice" (query_advice F). + + (* + pub fn query_instance(&mut self, column: Column, at: Rotation) -> Expression { + self.queried_cells.push((column, at).into()); + Expression::Instance { + query_index: self.meta.query_instance_index(column, at), + column_index: column.index, + rotation: at, + } + } + *) + Definition query_instance (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; column; at_ ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + let at_ := M.alloc (| at_ |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::circuit::VirtualCell"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::VirtualCells", + "queried_cells" + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ]; + Ty.path "halo2_proofs::poly::Rotation" + ], + [ Ty.path "halo2_proofs::plonk::circuit::VirtualCell" ], + "into", + [] + |), + [ Value.Tuple [ M.read (| column |); M.read (| at_ |) ] ] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::circuit::Expression::Instance" + [ + ("query_index", + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "query_instance_index", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::VirtualCells", + "meta" + |) + |); + M.read (| column |); + M.read (| at_ |) + ] + |)); + ("column_index", + M.read (| + M.SubPointer.get_struct_record_field (| + column, + "halo2_proofs::plonk::circuit::Column", + "index" + |) + |)); + ("rotation", M.read (| at_ |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_query_instance : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "query_instance" (query_instance F). + + (* + pub fn query_any>>(&mut self, column: C, at: Rotation) -> Expression { + let column = column.into(); + match column.column_type() { + Any::Advice => self.query_advice(Column::::try_from(column).unwrap(), at), + Any::Fixed => self.query_fixed(Column::::try_from(column).unwrap(), at), + Any::Instance => self.query_instance(Column::::try_from(column).unwrap(), at), + } + } + *) + Definition query_any (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ C ], [ self; column; at_ ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + let at_ := M.alloc (| at_ |) in + M.read (| + let column := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + C, + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "into", + [] + |), + [ M.read (| column |) ] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ], + "column_type", + [] + |), + [ column ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") [ F ], + "query_advice", + [] + |), + [ + M.read (| self |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::TryFrom", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "try_from", + [] + |), + [ M.read (| column |) ] + |) + ] + |); + M.read (| at_ |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") [ F ], + "query_fixed", + [] + |), + [ + M.read (| self |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::TryFrom", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "try_from", + [] + |), + [ M.read (| column |) ] + |) + ] + |); + M.read (| at_ |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") [ F ], + "query_instance", + [] + |), + [ + M.read (| self |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ]; + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::TryFrom", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "try_from", + [] + |), + [ M.read (| column |) ] + |) + ] + |); + M.read (| at_ |) + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_query_any : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "query_any" (query_any F). + End Impl_halo2_proofs_plonk_circuit_VirtualCells_F. + End circuit. +End plonk. diff --git a/CoqOfRust/halo2_proofs/plonk/circuit/compress_selectors.v b/CoqOfRust/halo2_proofs/plonk/circuit/compress_selectors.v new file mode 100644 index 000000000..5238b0b6f --- /dev/null +++ b/CoqOfRust/halo2_proofs/plonk/circuit/compress_selectors.v @@ -0,0 +1,3927 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module plonk. + Module circuit. + Module compress_selectors. + (* StructRecord + { + name := "SelectorDescription"; + ty_params := []; + fields := + [ + ("selector", Ty.path "usize"); + ("activations", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]); + ("max_degree", Ty.path "usize") + ]; + } *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_circuit_compress_selectors_SelectorDescription. + Definition Self : Ty.t := + Ty.path "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "SelectorDescription" |); + M.read (| Value.String "selector" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription", + "selector" + |)); + M.read (| Value.String "activations" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription", + "activations" + |)); + M.read (| Value.String "max_degree" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription", + "max_degree" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_circuit_compress_selectors_SelectorDescription. + + Module Impl_core_clone_Clone_for_halo2_proofs_plonk_circuit_compress_selectors_SelectorDescription. + Definition Self : Ty.t := + Ty.path "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + [ + ("selector", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "usize", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription", + "selector" + |) + ] + |)); + ("activations", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription", + "activations" + |) + ] + |)); + ("max_degree", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "usize", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription", + "max_degree" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_plonk_circuit_compress_selectors_SelectorDescription. + + (* StructRecord + { + name := "SelectorAssignment"; + ty_params := [ "F" ]; + fields := + [ + ("selector", Ty.path "usize"); + ("combination_index", Ty.path "usize"); + ("expression", Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_for_halo2_proofs_plonk_circuit_compress_selectors_SelectorAssignment_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment") + [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "SelectorAssignment" |); + M.read (| Value.String "selector" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment", + "selector" + |)); + M.read (| Value.String "combination_index" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment", + "combination_index" + |)); + M.read (| Value.String "expression" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment", + "expression" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_for_halo2_proofs_plonk_circuit_compress_selectors_SelectorAssignment_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_for_halo2_proofs_plonk_circuit_compress_selectors_SelectorAssignment_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment") + [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment" + [ + ("selector", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "usize", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment", + "selector" + |) + ] + |)); + ("combination_index", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "usize", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment", + "combination_index" + |) + ] + |)); + ("expression", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment", + "expression" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_for_halo2_proofs_plonk_circuit_compress_selectors_SelectorAssignment_F. + + (* + pub fn process( + mut selectors: Vec, + max_degree: usize, + mut allocate_fixed_column: E, + ) -> (Vec>, Vec>) + where + E: FnMut() -> Expression, + { + if selectors.is_empty() { + // There is nothing to optimize. + return (vec![], vec![]); + } + + // The length of all provided selectors must be the same. + let n = selectors[0].activations.len(); + assert!(selectors.iter().all(|a| a.activations.len() == n)); + + let mut combination_assignments = vec![]; + let mut selector_assignments = vec![]; + + // All provided selectors of degree 0 are assumed to be either concrete + // selectors or do not appear in a gate. Let's address these first. + selectors = selectors + .into_iter() + .filter(|selector| { + if selector.max_degree == 0 { + // This is a complex selector, or a selector that does not appear in any + // gate constraint. + let expression = allocate_fixed_column(); + + let combination_assignment = selector + .activations + .iter() + .map(|b| if *b { F::one() } else { F::zero() }) + .collect::>(); + let combination_index = combination_assignments.len(); + combination_assignments.push(combination_assignment); + selector_assignments.push(SelectorAssignment { + selector: selector.selector, + combination_index, + expression, + }); + + false + } else { + true + } + }) + .collect(); + + // All of the remaining `selectors` are simple. Let's try to combine them. + // First, we compute the exclusion matrix that has (j, k) = true if selector + // j and selector k conflict -- that is, they are both enabled on the same + // row. This matrix is symmetric and the diagonal entries are false, so we + // only need to store the lower triangular entries. + let mut exclusion_matrix = (0..selectors.len()) + .map(|i| vec![false; i]) + .collect::>(); + + for (i, rows) in selectors + .iter() + .map(|selector| &selector.activations) + .enumerate() + { + // Loop over the selectors previous to this one + for (j, other_selector) in selectors.iter().enumerate().take(i) { + // Look at what selectors are active at the same row + if rows + .iter() + .zip(other_selector.activations.iter()) + .any(|(l, r)| l & r) + { + // Mark them as incompatible + exclusion_matrix[i][j] = true; + } + } + } + + // Simple selectors that we've added to combinations already. + let mut added = vec![false; selectors.len()]; + + for (i, selector) in selectors.iter().enumerate() { + if added[i] { + continue; + } + added[i] = true; + assert!(selector.max_degree <= max_degree); + // This is used to keep track of the largest degree gate involved in the + // combination so far. We subtract by one to omit the virtual selector + // which will be substituted by the caller with the expression we give + // them. + let mut d = selector.max_degree - 1; + let mut combination = vec![selector]; + let mut combination_added = vec![i]; + + // Try to find other selectors that can join this one. + 'try_selectors: for (j, selector) in selectors.iter().enumerate().skip(i + 1) { + if d + combination.len() == max_degree { + // Short circuit; nothing can be added to this + // combination. + break 'try_selectors; + } + + // Skip selectors that have been added to previous combinations + if added[j] { + continue 'try_selectors; + } + + // Is this selector excluded from co-existing in the same + // combination with any of the other selectors so far? + for &i in combination_added.iter() { + if exclusion_matrix[j][i] { + continue 'try_selectors; + } + } + + // Can the new selector join the combination? Reminder: we use + // selector.max_degree - 1 to omit the influence of the virtual + // selector on the degree, as it will be substituted. + let new_d = std::cmp::max(d, selector.max_degree - 1); + if new_d + combination.len() + 1 > max_degree { + // Guess not. + continue 'try_selectors; + } + + d = new_d; + combination.push(selector); + combination_added.push(j); + added[j] = true; + } + + // Now, compute the selector and combination assignments. + let mut combination_assignment = vec![F::zero(); n]; + let combination_len = combination.len(); + let combination_index = combination_assignments.len(); + let query = allocate_fixed_column(); + + let mut assigned_root = F::one(); + selector_assignments.extend(combination.into_iter().map(|selector| { + // Compute the expression for substitution. This produces an expression of the + // form + // q * Prod[i = 1..=combination_len, i != assigned_root](i - q) + // + // which is non-zero only on rows where `combination_assignment` is set to + // `assigned_root`. In particular, rows set to 0 correspond to all selectors + // being disabled. + let mut expression = query.clone(); + let mut root = F::one(); + for _ in 0..combination_len { + if root != assigned_root { + expression = expression * (Expression::Constant(root) - query.clone()); + } + root += F::one(); + } + + // Update the combination assignment + for (combination, selector) in combination_assignment + .iter_mut() + .zip(selector.activations.iter()) + { + // This will not overwrite another selector's activations because + // we have ensured that selectors are disjoint. + if *selector { + *combination = assigned_root; + } + } + + assigned_root += F::one(); + + SelectorAssignment { + selector: selector.selector, + combination_index, + expression, + } + })); + combination_assignments.push(combination_assignment); + } + + (combination_assignments, selector_assignments) + } + *) + Definition process (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F; E ], [ selectors; max_degree; allocate_fixed_column ] => + ltac:(M.monadic + (let selectors := M.alloc (| selectors |) in + let max_degree := M.alloc (| max_degree |) in + let allocate_fixed_column := M.alloc (| allocate_fixed_column |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription"; + Ty.path "alloc::alloc::Global" + ], + "is_empty", + [] + |), + [ selectors ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let n := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ selectors; Value.Integer 0 ] + |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription", + "activations" + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ], + [], + "all", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ selectors ] + |) + ] + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + BinOp.Pure.eq + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| a |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription", + "activations" + |) + ] + |)) + (M.read (| n |)))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "assertion failed: selectors.iter().all(|a| a.activations.len() == n)" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let combination_assignments := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let selector_assignments := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.write (| + selectors, + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription"; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ] + ] + ] + (Ty.path "bool") + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription"; + Ty.path "alloc::alloc::Global" + ], + [], + "filter", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription"; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| selectors |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let selector := M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| selector |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription", + "max_degree" + |) + |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let expression := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnMut", + E, + [ Ty.tuple [] ], + "call_mut", + [] + |), + [ + allocate_fixed_column; + Value.Tuple [] + ] + |) + |) in + let combination_assignment := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.path "bool" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "bool" ] + ] + ] + F + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + F; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.path "bool" ], + [], + "map", + [ + F; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "bool" ] + ] + ] + F + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "bool" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| selector |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription", + "activations" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let b := + M.copy (| + γ + |) in + M.read (| + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun γ => + ltac:(M.monadic + (let + γ := + M.use + (M.read (| + b + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let combination_index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ combination_assignments ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + combination_assignments; + M.read (| combination_assignment |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + selector_assignments; + Value.StructRecord + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment" + [ + ("selector", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| selector |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription", + "selector" + |) + |)); + ("combination_index", + M.read (| + combination_index + |)); + ("expression", + M.read (| expression |)) + ] + ] + |) + |) in + M.alloc (| Value.Bool false |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Bool true |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let exclusion_matrix := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "map", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]) + ] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ selectors ] + |)) + ]; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let i := M.copy (| γ |) in + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ Ty.path "bool" ] + |), + [ Value.Bool false; M.read (| i |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ] + ] + ] + (Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]) + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ] + ] + ] + (Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]) + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ], + [], + "map", + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ] + ] + ] + (Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ selectors ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let selector := M.copy (| γ |) in + M.SubPointer.get_struct_record_field (| + M.read (| selector |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription", + "activations" + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ] + ] + ] + (Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path "alloc::alloc::Global" + ] + ]) + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let i := M.copy (| γ1_0 |) in + let rows := M.copy (| γ1_1 |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::take::Take") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ] + ], + [], + "take", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ selectors ] + |) + ] + |) + ] + |); + M.read (| i |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::take::Take") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let j := M.copy (| γ1_0 |) in + let other_selector := + M.copy (| γ1_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "bool" + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "bool" + ] + ], + [], + "any", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "bool" + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.path + "bool" + ] + ] + ] + ] + (Ty.path + "bool") + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "bool" + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "bool" + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.path + "bool" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "bool"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + rows + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.path + "bool" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "bool"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + other_selector + |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription", + "activations" + |) + ] + |) + ] + |) + ] + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + l := + M.copy (| + γ0_0 + |) in + let + r := + M.copy (| + γ0_1 + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::BitAnd", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "bool" + ], + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "bool" + ] + ], + "bitand", + [] + |), + [ + M.read (| + l + |); + M.read (| + r + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "bool"; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "bool"; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index_mut", + [] + |), + [ + exclusion_matrix; + M.read (| + i + |) + ] + |); + M.read (| j |) + ] + |), + Value.Bool true + |) in + M.alloc (| + Value.Tuple [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple [] + |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let added := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ Ty.path "bool" ] |), + [ + Value.Bool false; + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ selectors ] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ selectors ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let i := M.copy (| γ1_0 |) in + let selector := M.copy (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ added; M.read (| i |) ] + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| M.continue (||) |) + |) + |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ added; M.read (| i |) ] + |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.le + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| selector |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription", + "max_degree" + |) + |)) + (M.read (| max_degree |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic", + [] + |), + [ + M.read (| + Value.String + "assertion failed: selector.max_degree <= max_degree" + |) + ] + |) + |) + |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let d := + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| selector |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription", + "max_degree" + |) + |), + Value.Integer 1 + |) + |) in + let combination := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array [ M.read (| selector |) ] + |) + ] + |) + |)) + ] + |) + |) in + let combination_added := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "usize" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "usize" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array [ M.read (| i |) ] + |) + ] + |) + |)) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ] + ], + [], + "skip", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ selectors ] + |) + ] + |) + ] + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| i |), + Value.Integer 1 + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let j := M.copy (| γ1_0 |) in + let selector := + M.copy (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (BinOp.Panic.add (| + Integer.Usize, + M.read (| + d + |), + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ]; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ + combination + ] + |) + |)) + (M.read (| + max_degree + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple [] + |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "bool"; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + added; + M.read (| + j + |) + ] + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.continue (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple [] + |))) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "usize" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.path + "usize" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "usize"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + combination_added + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "usize" + ], + [], + "next", + [] + |), + [ iter + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + γ0_0 := + M.read (| + γ0_0 + |) in + let + i := + M.copy (| + γ0_0 + |) in + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "bool"; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "bool"; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + exclusion_matrix; + M.read (| + j + |) + ] + |); + M.read (| + i + |) + ] + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.continue (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple + [] + |))) + ] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + let new_d := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::cmp::max", + [ Ty.path "usize" ] + |), + [ + M.read (| d |); + BinOp.Panic.sub (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + selector + |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription", + "max_degree" + |) + |), + Value.Integer 1 + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.read (| + new_d + |), + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ]; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ + combination + ] + |) + |), + Value.Integer + 1 + |)) + (M.read (| + max_degree + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.continue (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple [] + |))) + ] + |) in + let _ := + M.write (| + d, + M.read (| new_d |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ]; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + combination; + M.read (| selector |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path "usize"; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + combination_added; + M.read (| j |) + ] + |) + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ added; M.read (| j |) + ] + |), + Value.Bool true + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let combination_assignment := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ F ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |); + M.read (| n |) + ] + |) + |) in + let combination_len := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ combination ] + |) + |) in + let combination_index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ combination_assignments ] + |) + |) in + let query := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnMut", + E, + [ Ty.tuple [] ], + "call_mut", + [] + |), + [ allocate_fixed_column; Value.Tuple [] ] + |) + |) in + let assigned_root := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::Extend", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment") + [ F ] + ], + "extend", + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment") + [ F ]) + ] + ] + |), + [ + selector_assignments; + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| combination |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let selector := + M.copy (| γ |) in + M.read (| + let expression := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ query ] + |) + |) in + let root := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "usize" + ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + Value.Integer + 0); + ("end_", + M.read (| + combination_len + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "usize" + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + F, + [ + F + ], + "ne", + [] + |), + [ + root; + assigned_root + ] + |) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + let + _ := + M.write (| + expression, + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "mul", + [] + |), + [ + M.read (| + expression + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.read (| + root + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [], + "clone", + [] + |), + [ + query + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::AddAssign", + F, + [ + F + ], + "add_assign", + [] + |), + [ + root; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ F ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "bool" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ F ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "bool" + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ F + ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ + combination_assignment + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.path + "bool" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "bool"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + selector + |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription", + "activations" + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + F + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "bool" + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + combination := + M.copy (| + γ1_0 + |) in + let + selector := + M.copy (| + γ1_1 + |) in + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.read (| + selector + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + let + _ := + M.write (| + M.read (| + combination + |), + M.read (| + assigned_root + |) + |) in + M.alloc (| + Value.Tuple + [] + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple + [] + |))) + ] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::AddAssign", + F, + [ F ], + "add_assign", + [] + |), + [ + assigned_root; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::circuit::compress_selectors::SelectorAssignment" + [ + ("selector", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + selector + |), + "halo2_proofs::plonk::circuit::compress_selectors::SelectorDescription", + "selector" + |) + |)); + ("combination_index", + M.read (| + combination_index + |)); + ("expression", + M.read (| + expression + |)) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + combination_assignments; + M.read (| combination_assignment |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.Tuple + [ M.read (| combination_assignments |); M.read (| selector_assignments |) ] + |) + |))) + |))) + | _, _ => M.impossible + end. + End compress_selectors. + End circuit. +End plonk. diff --git a/CoqOfRust/halo2_proofs/plonk/error.v b/CoqOfRust/halo2_proofs/plonk/error.v new file mode 100644 index 000000000..fb5ab2905 --- /dev/null +++ b/CoqOfRust/halo2_proofs/plonk/error.v @@ -0,0 +1,837 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module plonk. + Module error. + (* + Enum Error + { + ty_params := []; + variants := + [ + { + name := "Synthesis"; + item := StructTuple []; + discriminant := None; + }; + { + name := "InvalidInstances"; + item := StructTuple []; + discriminant := None; + }; + { + name := "ConstraintSystemFailure"; + item := StructTuple []; + discriminant := None; + }; + { + name := "BoundsFailure"; + item := StructTuple []; + discriminant := None; + }; + { + name := "Opening"; + item := StructTuple []; + discriminant := None; + }; + { + name := "Transcript"; + item := StructTuple [ Ty.path "std::io::error::Error" ]; + discriminant := None; + }; + { + name := "NotEnoughRowsAvailable"; + item := StructRecord [ ("current_k", Ty.path "u32") ]; + discriminant := None; + }; + { + name := "InstanceTooLarge"; + item := StructTuple []; + discriminant := None; + }; + { + name := "NotEnoughColumnsForConstants"; + item := StructTuple []; + discriminant := None; + }; + { + name := "ColumnNotInPermutation"; + item := + StructTuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ]; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_error_Error. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::error::Error". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_str", + [] + |), + [ M.read (| f |); M.read (| Value.String "Synthesis" |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_str", + [] + |), + [ M.read (| f |); M.read (| Value.String "InvalidInstances" |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_str", + [] + |), + [ M.read (| f |); M.read (| Value.String "ConstraintSystemFailure" |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_str", + [] + |), + [ M.read (| f |); M.read (| Value.String "BoundsFailure" |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_str", + [] + |), + [ M.read (| f |); M.read (| Value.String "Opening" |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::error::Error::Transcript", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Transcript" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::error::Error::NotEnoughRowsAvailable", + "current_k" + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "NotEnoughRowsAvailable" |); + M.read (| Value.String "current_k" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_str", + [] + |), + [ M.read (| f |); M.read (| Value.String "InstanceTooLarge" |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_str", + [] + |), + [ M.read (| f |); M.read (| Value.String "NotEnoughColumnsForConstants" |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::error::Error::ColumnNotInPermutation", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "ColumnNotInPermutation" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_error_Error. + + Module Impl_core_convert_From_std_io_error_Error_for_halo2_proofs_plonk_error_Error. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::error::Error". + + (* + fn from(error: io::Error) -> Self { + // The only place we can get io::Error from is the transcript. + Error::Transcript(error) + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ error ] => + ltac:(M.monadic + (let error := M.alloc (| error |) in + Value.StructTuple + "halo2_proofs::plonk::error::Error::Transcript" + [ M.read (| error |) ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) [ (* T *) Ty.path "std::io::error::Error" ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_std_io_error_Error_for_halo2_proofs_plonk_error_Error. + + Module Impl_halo2_proofs_plonk_error_Error. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::error::Error". + + (* + pub(crate) fn not_enough_rows_available(current_k: u32) -> Self { + Error::NotEnoughRowsAvailable { current_k } + } + *) + Definition not_enough_rows_available (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ current_k ] => + ltac:(M.monadic + (let current_k := M.alloc (| current_k |) in + Value.StructRecord + "halo2_proofs::plonk::error::Error::NotEnoughRowsAvailable" + [ ("current_k", M.read (| current_k |)) ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_not_enough_rows_available : + M.IsAssociatedFunction Self "not_enough_rows_available" not_enough_rows_available. + End Impl_halo2_proofs_plonk_error_Error. + + Module Impl_core_fmt_Display_for_halo2_proofs_plonk_error_Error. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::error::Error". + + (* + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Error::Synthesis => write!(f, "General synthesis error"), + Error::InvalidInstances => write!(f, "Provided instances do not match the circuit"), + Error::ConstraintSystemFailure => write!(f, "The constraint system is not satisfied"), + Error::BoundsFailure => write!(f, "An out-of-bounds index was passed to the backend"), + Error::Opening => write!(f, "Multi-opening proof was invalid"), + Error::Transcript(e) => write!(f, "Transcript error: {}", e), + Error::NotEnoughRowsAvailable { current_k } => write!( + f, + "k = {} is too small for the given circuit. Try using a larger value of k", + current_k, + ), + Error::InstanceTooLarge => write!(f, "Instance vectors are larger than the circuit"), + Error::NotEnoughColumnsForConstants => { + write!( + f, + "Too few fixed columns are enabled for global constants usage" + ) + } + Error::ColumnNotInPermutation(column) => write!( + f, + "Column {:?} must be included in the permutation. Help: try applying `meta.enable_equalty` on the column", + column + ), + } + } + *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ M.read (| Value.String "General synthesis error" |) ] + |)) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String "Provided instances do not match the circuit" + |) + ] + |)) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String "The constraint system is not satisfied" + |) + ] + |)) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "An out-of-bounds index was passed to the backend" + |) + ] + |)) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ M.read (| Value.String "Multi-opening proof was invalid" |) + ] + |)) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::error::Error::Transcript", + 0 + |) in + let e := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array [ M.read (| Value.String "Transcript error: " |) ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "std::io::error::Error" ] + ] + |), + [ e ] + |) + ] + |)) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::error::Error::NotEnoughRowsAvailable", + "current_k" + |) in + let current_k := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "k = " |); + M.read (| + Value.String + " is too small for the given circuit. Try using a larger value of k" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ] + |), + [ current_k ] + |) + ] + |)) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "Instance vectors are larger than the circuit" + |) + ] + |)) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "Too few fixed columns are enabled for global constants usage" + |) + ] + |)) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::error::Error::ColumnNotInPermutation", + 0 + |) in + let column := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "Column " |); + M.read (| + Value.String + " must be included in the permutation. Help: try applying `meta.enable_equalty` on the column" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ] + ] + |), + [ column ] + |) + ] + |)) + ] + |) + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Display" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Display_for_halo2_proofs_plonk_error_Error. + + Module Impl_core_error_Error_for_halo2_proofs_plonk_error_Error. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::error::Error". + + (* + fn source(&self) -> Option<&(dyn error::Error + 'static)> { + match self { + Error::Transcript(e) => Some(e), + _ => None, + } + } + *) + Definition source (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::error::Error::Transcript", + 0 + |) in + let e := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ (* Unsize *) M.pointer_coercion (M.read (| e |)) ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "core::option::Option::None" [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::error::Error" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("source", InstanceField.Method source) ]. + End Impl_core_error_Error_for_halo2_proofs_plonk_error_Error. + End error. +End plonk. diff --git a/CoqOfRust/halo2_proofs/plonk/evaluation.v b/CoqOfRust/halo2_proofs/plonk/evaluation.v new file mode 100644 index 000000000..ab5b5ffb6 --- /dev/null +++ b/CoqOfRust/halo2_proofs/plonk/evaluation.v @@ -0,0 +1,19198 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module plonk. + Module evaluation. + (* + fn get_rotation_idx(idx: usize, rot: i32, rot_scale: i32, isize: i32) -> usize { + (((idx as i32) + (rot * rot_scale)).rem_euclid(isize)) as usize + } + *) + Definition get_rotation_idx (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ idx; rot; rot_scale; isize ] => + ltac:(M.monadic + (let idx := M.alloc (| idx |) in + let rot := M.alloc (| rot |) in + let rot_scale := M.alloc (| rot_scale |) in + let isize := M.alloc (| isize |) in + M.rust_cast + (M.call_closure (| + M.get_associated_function (| Ty.path "i32", "rem_euclid", [] |), + [ + BinOp.Panic.add (| + Integer.I32, + M.rust_cast (M.read (| idx |)), + BinOp.Panic.mul (| Integer.I32, M.read (| rot |), M.read (| rot_scale |) |) + |); + M.read (| isize |) + ] + |)))) + | _, _ => M.impossible + end. + + (* + Enum ValueSource + { + ty_params := []; + variants := + [ + { + name := "Constant"; + item := StructTuple [ Ty.path "usize" ]; + discriminant := None; + }; + { + name := "Intermediate"; + item := StructTuple [ Ty.path "usize" ]; + discriminant := None; + }; + { + name := "Fixed"; + item := StructTuple [ Ty.path "usize"; Ty.path "usize" ]; + discriminant := None; + }; + { + name := "Advice"; + item := StructTuple [ Ty.path "usize"; Ty.path "usize" ]; + discriminant := None; + }; + { + name := "Instance"; + item := StructTuple [ Ty.path "usize"; Ty.path "usize" ]; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_clone_Clone_for_halo2_proofs_plonk_evaluation_ValueSource. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation::ValueSource". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.read (| self |))) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_plonk_evaluation_ValueSource. + + Module Impl_core_marker_Copy_for_halo2_proofs_plonk_evaluation_ValueSource. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation::ValueSource". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_plonk_evaluation_ValueSource. + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_evaluation_ValueSource. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation::ValueSource". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::ValueSource::Constant", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Constant" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::ValueSource::Intermediate", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Intermediate" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::ValueSource::Fixed", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::ValueSource::Fixed", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Fixed" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + (* Unsize *) M.pointer_coercion __self_1 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::ValueSource::Advice", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::ValueSource::Advice", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Advice" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + (* Unsize *) M.pointer_coercion __self_1 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::ValueSource::Instance", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::ValueSource::Instance", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Instance" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + (* Unsize *) M.pointer_coercion __self_1 + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_evaluation_ValueSource. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_plonk_evaluation_ValueSource. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation::ValueSource". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_plonk_evaluation_ValueSource. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_plonk_evaluation_ValueSource. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation::ValueSource". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" ] + |), + [ M.read (| other |) ] + |) + |) in + M.alloc (| + LogicalOp.and (| + BinOp.Pure.eq (M.read (| __self_tag |)) (M.read (| __arg1_tag |)), + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| other |) ] |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::ValueSource::Constant", + 0 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::ValueSource::Constant", + 0 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + M.alloc (| + BinOp.Pure.eq + (M.read (| M.read (| __self_0 |) |)) + (M.read (| M.read (| __arg1_0 |) |)) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::ValueSource::Intermediate", + 0 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::ValueSource::Intermediate", + 0 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + M.alloc (| + BinOp.Pure.eq + (M.read (| M.read (| __self_0 |) |)) + (M.read (| M.read (| __arg1_0 |) |)) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::ValueSource::Fixed", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::ValueSource::Fixed", + 1 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::ValueSource::Fixed", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::ValueSource::Fixed", + 1 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.alloc (| + LogicalOp.and (| + BinOp.Pure.eq + (M.read (| M.read (| __self_0 |) |)) + (M.read (| M.read (| __arg1_0 |) |)), + ltac:(M.monadic + (BinOp.Pure.eq + (M.read (| M.read (| __self_1 |) |)) + (M.read (| M.read (| __arg1_1 |) |)))) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::ValueSource::Advice", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::ValueSource::Advice", + 1 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::ValueSource::Advice", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::ValueSource::Advice", + 1 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.alloc (| + LogicalOp.and (| + BinOp.Pure.eq + (M.read (| M.read (| __self_0 |) |)) + (M.read (| M.read (| __arg1_0 |) |)), + ltac:(M.monadic + (BinOp.Pure.eq + (M.read (| M.read (| __self_1 |) |)) + (M.read (| M.read (| __arg1_1 |) |)))) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::ValueSource::Instance", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::ValueSource::Instance", + 1 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::ValueSource::Instance", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::ValueSource::Instance", + 1 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.alloc (| + LogicalOp.and (| + BinOp.Pure.eq + (M.read (| M.read (| __self_0 |) |)) + (M.read (| M.read (| __arg1_0 |) |)), + ltac:(M.monadic + (BinOp.Pure.eq + (M.read (| M.read (| __self_1 |) |)) + (M.read (| M.read (| __arg1_1 |) |)))) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::intrinsics::unreachable", [] |), + [] + |) + |) + |))) + ] + |) + |))) + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_plonk_evaluation_ValueSource. + + Module Impl_core_cmp_PartialOrd_for_halo2_proofs_plonk_evaluation_ValueSource. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation::ValueSource". + + (* PartialOrd *) + Definition partial_cmp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" ] + |), + [ M.read (| other |) ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| other |) ] |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::ValueSource::Constant", + 0 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::ValueSource::Constant", + 0 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "usize", + [ Ty.path "usize" ], + "partial_cmp", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::ValueSource::Intermediate", + 0 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::ValueSource::Intermediate", + 0 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "usize", + [ Ty.path "usize" ], + "partial_cmp", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::ValueSource::Fixed", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::ValueSource::Fixed", + 1 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::ValueSource::Fixed", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::ValueSource::Fixed", + 1 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "usize", + [ Ty.path "usize" ], + "partial_cmp", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "usize", + [ Ty.path "usize" ], + "partial_cmp", + [] + |), + [ M.read (| __self_1 |); M.read (| __arg1_1 |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let cmp := M.copy (| γ |) in + cmp)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::ValueSource::Advice", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::ValueSource::Advice", + 1 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::ValueSource::Advice", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::ValueSource::Advice", + 1 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "usize", + [ Ty.path "usize" ], + "partial_cmp", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "usize", + [ Ty.path "usize" ], + "partial_cmp", + [] + |), + [ M.read (| __self_1 |); M.read (| __arg1_1 |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let cmp := M.copy (| γ |) in + cmp)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::ValueSource::Instance", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::ValueSource::Instance", + 1 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::ValueSource::Instance", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::ValueSource::Instance", + 1 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "usize", + [ Ty.path "usize" ], + "partial_cmp", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "usize", + [ Ty.path "usize" ], + "partial_cmp", + [] + |), + [ M.read (| __self_1 |); M.read (| __arg1_1 |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let cmp := M.copy (| γ |) in + cmp)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "isize", + [ Ty.path "isize" ], + "partial_cmp", + [] + |), + [ __self_tag; __arg1_tag ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialOrd" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("partial_cmp", InstanceField.Method partial_cmp) ]. + End Impl_core_cmp_PartialOrd_for_halo2_proofs_plonk_evaluation_ValueSource. + + Module Impl_halo2_proofs_plonk_evaluation_ValueSource. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation::ValueSource". + + (* + pub fn get( + &self, + rotations: &[usize], + constants: &[F], + intermediates: &[F], + fixed_values: &[Polynomial], + advice_values: &[Polynomial], + instance_values: &[Polynomial], + ) -> F { + match self { + ValueSource::Constant(idx) => constants[*idx], + ValueSource::Intermediate(idx) => intermediates[*idx], + ValueSource::Fixed(column_index, rotation) => { + fixed_values[*column_index][rotations[*rotation]] + } + ValueSource::Advice(column_index, rotation) => { + advice_values[*column_index][rotations[*rotation]] + } + ValueSource::Instance(column_index, rotation) => { + instance_values[*column_index][rotations[*rotation]] + } + } + } + *) + Definition get (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F; B ], + [ + self; + rotations; + constants; + intermediates; + fixed_values; + advice_values; + instance_values + ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rotations := M.alloc (| rotations |) in + let constants := M.alloc (| constants |) in + let intermediates := M.alloc (| intermediates |) in + let fixed_values := M.alloc (| fixed_values |) in + let advice_values := M.alloc (| advice_values |) in + let instance_values := M.alloc (| instance_values |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::ValueSource::Constant", + 0 + |) in + let idx := M.alloc (| γ1_0 |) in + M.SubPointer.get_array_field (| M.read (| constants |), M.read (| idx |) |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::ValueSource::Intermediate", + 0 + |) in + let idx := M.alloc (| γ1_0 |) in + M.SubPointer.get_array_field (| + M.read (| intermediates |), + M.read (| idx |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::ValueSource::Fixed", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::ValueSource::Fixed", + 1 + |) in + let column_index := M.alloc (| γ1_0 |) in + let rotation := M.alloc (| γ1_1 |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| fixed_values |), + M.read (| column_index |) + |); + M.read (| + M.SubPointer.get_array_field (| + M.read (| rotations |), + M.read (| rotation |) + |) + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::ValueSource::Advice", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::ValueSource::Advice", + 1 + |) in + let column_index := M.alloc (| γ1_0 |) in + let rotation := M.alloc (| γ1_1 |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| advice_values |), + M.read (| column_index |) + |); + M.read (| + M.SubPointer.get_array_field (| + M.read (| rotations |), + M.read (| rotation |) + |) + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::ValueSource::Instance", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::ValueSource::Instance", + 1 + |) in + let column_index := M.alloc (| γ1_0 |) in + let rotation := M.alloc (| γ1_1 |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| instance_values |), + M.read (| column_index |) + |); + M.read (| + M.SubPointer.get_array_field (| + M.read (| rotations |), + M.read (| rotation |) + |) + |) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get : M.IsAssociatedFunction Self "get" get. + End Impl_halo2_proofs_plonk_evaluation_ValueSource. + + (* + Enum Calculation + { + ty_params := []; + variants := + [ + { + name := "Add"; + item := + StructTuple + [ + Ty.path "halo2_proofs::plonk::evaluation::ValueSource"; + Ty.path "halo2_proofs::plonk::evaluation::ValueSource" + ]; + discriminant := None; + }; + { + name := "Sub"; + item := + StructTuple + [ + Ty.path "halo2_proofs::plonk::evaluation::ValueSource"; + Ty.path "halo2_proofs::plonk::evaluation::ValueSource" + ]; + discriminant := None; + }; + { + name := "Mul"; + item := + StructTuple + [ + Ty.path "halo2_proofs::plonk::evaluation::ValueSource"; + Ty.path "halo2_proofs::plonk::evaluation::ValueSource" + ]; + discriminant := None; + }; + { + name := "Negate"; + item := StructTuple [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" ]; + discriminant := None; + }; + { + name := "LcBeta"; + item := + StructTuple + [ + Ty.path "halo2_proofs::plonk::evaluation::ValueSource"; + Ty.path "halo2_proofs::plonk::evaluation::ValueSource" + ]; + discriminant := None; + }; + { + name := "LcTheta"; + item := + StructTuple + [ + Ty.path "halo2_proofs::plonk::evaluation::ValueSource"; + Ty.path "halo2_proofs::plonk::evaluation::ValueSource" + ]; + discriminant := None; + }; + { + name := "AddGamma"; + item := StructTuple [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" ]; + discriminant := None; + }; + { + name := "Store"; + item := StructTuple [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" ]; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_clone_Clone_for_halo2_proofs_plonk_evaluation_Calculation. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation::Calculation". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Add", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Add", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::Add" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [], + "clone", + [] + |), + [ M.read (| __self_1 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Sub", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Sub", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::Sub" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [], + "clone", + [] + |), + [ M.read (| __self_1 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Mul", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Mul", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::Mul" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [], + "clone", + [] + |), + [ M.read (| __self_1 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Negate", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::Negate" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::LcBeta", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::LcBeta", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::LcBeta" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [], + "clone", + [] + |), + [ M.read (| __self_1 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::LcTheta", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::LcTheta", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::LcTheta" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [], + "clone", + [] + |), + [ M.read (| __self_1 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::AddGamma", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::AddGamma" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Store", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::Store" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_plonk_evaluation_Calculation. + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_evaluation_Calculation. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation::Calculation". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Add", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Add", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Add" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + (* Unsize *) M.pointer_coercion __self_1 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Sub", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Sub", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Sub" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + (* Unsize *) M.pointer_coercion __self_1 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Mul", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Mul", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Mul" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + (* Unsize *) M.pointer_coercion __self_1 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Negate", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Negate" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::LcBeta", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::LcBeta", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "LcBeta" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + (* Unsize *) M.pointer_coercion __self_1 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::LcTheta", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::LcTheta", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "LcTheta" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + (* Unsize *) M.pointer_coercion __self_1 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::AddGamma", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AddGamma" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Store", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Store" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_evaluation_Calculation. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_plonk_evaluation_Calculation. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation::Calculation". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_plonk_evaluation_Calculation. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_plonk_evaluation_Calculation. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation::Calculation". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::plonk::evaluation::Calculation" ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::plonk::evaluation::Calculation" ] + |), + [ M.read (| other |) ] + |) + |) in + M.alloc (| + LogicalOp.and (| + BinOp.Pure.eq (M.read (| __self_tag |)) (M.read (| __arg1_tag |)), + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| other |) ] |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::Calculation::Add", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::Calculation::Add", + 1 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::Calculation::Add", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::Calculation::Add", + 1 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" ], + "eq", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" ], + "eq", + [] + |), + [ M.read (| __self_1 |); M.read (| __arg1_1 |) ] + |))) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::Calculation::Sub", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::Calculation::Sub", + 1 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::Calculation::Sub", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::Calculation::Sub", + 1 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" ], + "eq", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" ], + "eq", + [] + |), + [ M.read (| __self_1 |); M.read (| __arg1_1 |) ] + |))) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::Calculation::Mul", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::Calculation::Mul", + 1 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::Calculation::Mul", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::Calculation::Mul", + 1 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" ], + "eq", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" ], + "eq", + [] + |), + [ M.read (| __self_1 |); M.read (| __arg1_1 |) ] + |))) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::Calculation::Negate", + 0 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::Calculation::Negate", + 0 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" ], + "eq", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::Calculation::LcBeta", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::Calculation::LcBeta", + 1 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::Calculation::LcBeta", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::Calculation::LcBeta", + 1 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" ], + "eq", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" ], + "eq", + [] + |), + [ M.read (| __self_1 |); M.read (| __arg1_1 |) ] + |))) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::Calculation::LcTheta", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::Calculation::LcTheta", + 1 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::Calculation::LcTheta", + 0 + |) in + let γ2_1 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::Calculation::LcTheta", + 1 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" ], + "eq", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" ], + "eq", + [] + |), + [ M.read (| __self_1 |); M.read (| __arg1_1 |) ] + |))) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::Calculation::AddGamma", + 0 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::Calculation::AddGamma", + 0 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" ], + "eq", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::plonk::evaluation::Calculation::Store", + 0 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::plonk::evaluation::Calculation::Store", + 0 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" ], + "eq", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::intrinsics::unreachable", [] |), + [] + |) + |) + |))) + ] + |) + |))) + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_plonk_evaluation_Calculation. + + Module Impl_halo2_proofs_plonk_evaluation_Calculation. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation::Calculation". + + (* + pub fn evaluate( + &self, + rotations: &[usize], + constants: &[F], + intermediates: &[F], + fixed_values: &[Polynomial], + advice_values: &[Polynomial], + instance_values: &[Polynomial], + beta: &F, + gamma: &F, + theta: &F, + ) -> F { + match self { + Calculation::Add(a, b) => { + let a = a.get( + rotations, + constants, + intermediates, + fixed_values, + advice_values, + instance_values, + ); + let b = b.get( + rotations, + constants, + intermediates, + fixed_values, + advice_values, + instance_values, + ); + a + b + } + Calculation::Sub(a, b) => { + let a = a.get( + rotations, + constants, + intermediates, + fixed_values, + advice_values, + instance_values, + ); + let b = b.get( + rotations, + constants, + intermediates, + fixed_values, + advice_values, + instance_values, + ); + a - b + } + Calculation::Mul(a, b) => { + let a = a.get( + rotations, + constants, + intermediates, + fixed_values, + advice_values, + instance_values, + ); + let b = b.get( + rotations, + constants, + intermediates, + fixed_values, + advice_values, + instance_values, + ); + a * b + } + Calculation::Negate(v) => -v.get( + rotations, + constants, + intermediates, + fixed_values, + advice_values, + instance_values, + ), + Calculation::LcBeta(a, b) => { + let a = a.get( + rotations, + constants, + intermediates, + fixed_values, + advice_values, + instance_values, + ); + let b = b.get( + rotations, + constants, + intermediates, + fixed_values, + advice_values, + instance_values, + ); + (a + beta) * b + } + Calculation::LcTheta(a, b) => { + let a = a.get( + rotations, + constants, + intermediates, + fixed_values, + advice_values, + instance_values, + ); + let b = b.get( + rotations, + constants, + intermediates, + fixed_values, + advice_values, + instance_values, + ); + a * theta + b + } + Calculation::AddGamma(v) => { + v.get( + rotations, + constants, + intermediates, + fixed_values, + advice_values, + instance_values, + ) + gamma + } + Calculation::Store(v) => v.get( + rotations, + constants, + intermediates, + fixed_values, + advice_values, + instance_values, + ), + } + } + *) + Definition evaluate (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F; B ], + [ + self; + rotations; + constants; + intermediates; + fixed_values; + advice_values; + instance_values; + beta; + gamma; + theta + ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rotations := M.alloc (| rotations |) in + let constants := M.alloc (| constants |) in + let intermediates := M.alloc (| intermediates |) in + let fixed_values := M.alloc (| fixed_values |) in + let advice_values := M.alloc (| advice_values |) in + let instance_values := M.alloc (| instance_values |) in + let beta := M.alloc (| beta |) in + let gamma := M.alloc (| gamma |) in + let theta := M.alloc (| theta |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Add", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Add", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let b := M.alloc (| γ1_1 |) in + let a := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + "get", + [ F; B ] + |), + [ + M.read (| a |); + M.read (| rotations |); + M.read (| constants |); + M.read (| intermediates |); + M.read (| fixed_values |); + M.read (| advice_values |); + M.read (| instance_values |) + ] + |) + |) in + let b := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + "get", + [ F; B ] + |), + [ + M.read (| b |); + M.read (| rotations |); + M.read (| constants |); + M.read (| intermediates |); + M.read (| fixed_values |); + M.read (| advice_values |); + M.read (| instance_values |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Add", F, [ F ], "add", [] |), + [ M.read (| a |); M.read (| b |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Sub", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Sub", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let b := M.alloc (| γ1_1 |) in + let a := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + "get", + [ F; B ] + |), + [ + M.read (| a |); + M.read (| rotations |); + M.read (| constants |); + M.read (| intermediates |); + M.read (| fixed_values |); + M.read (| advice_values |); + M.read (| instance_values |) + ] + |) + |) in + let b := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + "get", + [ F; B ] + |), + [ + M.read (| b |); + M.read (| rotations |); + M.read (| constants |); + M.read (| intermediates |); + M.read (| fixed_values |); + M.read (| advice_values |); + M.read (| instance_values |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Sub", F, [ F ], "sub", [] |), + [ M.read (| a |); M.read (| b |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Mul", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Mul", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let b := M.alloc (| γ1_1 |) in + let a := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + "get", + [ F; B ] + |), + [ + M.read (| a |); + M.read (| rotations |); + M.read (| constants |); + M.read (| intermediates |); + M.read (| fixed_values |); + M.read (| advice_values |); + M.read (| instance_values |) + ] + |) + |) in + let b := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + "get", + [ F; B ] + |), + [ + M.read (| b |); + M.read (| rotations |); + M.read (| constants |); + M.read (| intermediates |); + M.read (| fixed_values |); + M.read (| advice_values |); + M.read (| instance_values |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Mul", F, [ F ], "mul", [] |), + [ M.read (| a |); M.read (| b |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Negate", + 0 + |) in + let v := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Neg", F, [], "neg", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + "get", + [ F; B ] + |), + [ + M.read (| v |); + M.read (| rotations |); + M.read (| constants |); + M.read (| intermediates |); + M.read (| fixed_values |); + M.read (| advice_values |); + M.read (| instance_values |) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::LcBeta", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::LcBeta", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let b := M.alloc (| γ1_1 |) in + let a := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + "get", + [ F; B ] + |), + [ + M.read (| a |); + M.read (| rotations |); + M.read (| constants |); + M.read (| intermediates |); + M.read (| fixed_values |); + M.read (| advice_values |); + M.read (| instance_values |) + ] + |) + |) in + let b := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + "get", + [ F; B ] + |), + [ + M.read (| b |); + M.read (| rotations |); + M.read (| constants |); + M.read (| intermediates |); + M.read (| fixed_values |); + M.read (| advice_values |); + M.read (| instance_values |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Mul", F, [ F ], "mul", [] |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + F, + [ Ty.apply (Ty.path "&") [ F ] ], + "add", + [] + |), + [ M.read (| a |); M.read (| beta |) ] + |); + M.read (| b |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::LcTheta", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::LcTheta", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let b := M.alloc (| γ1_1 |) in + let a := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + "get", + [ F; B ] + |), + [ + M.read (| a |); + M.read (| rotations |); + M.read (| constants |); + M.read (| intermediates |); + M.read (| fixed_values |); + M.read (| advice_values |); + M.read (| instance_values |) + ] + |) + |) in + let b := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + "get", + [ F; B ] + |), + [ + M.read (| b |); + M.read (| rotations |); + M.read (| constants |); + M.read (| intermediates |); + M.read (| fixed_values |); + M.read (| advice_values |); + M.read (| instance_values |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Add", F, [ F ], "add", [] |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ Ty.apply (Ty.path "&") [ F ] ], + "mul", + [] + |), + [ M.read (| a |); M.read (| theta |) ] + |); + M.read (| b |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::AddGamma", + 0 + |) in + let v := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + F, + [ Ty.apply (Ty.path "&") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + "get", + [ F; B ] + |), + [ + M.read (| v |); + M.read (| rotations |); + M.read (| constants |); + M.read (| intermediates |); + M.read (| fixed_values |); + M.read (| advice_values |); + M.read (| instance_values |) + ] + |); + M.read (| gamma |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::Calculation::Store", + 0 + |) in + let v := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + "get", + [ F; B ] + |), + [ + M.read (| v |); + M.read (| rotations |); + M.read (| constants |); + M.read (| intermediates |); + M.read (| fixed_values |); + M.read (| advice_values |); + M.read (| instance_values |) + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_evaluate : M.IsAssociatedFunction Self "evaluate" evaluate. + End Impl_halo2_proofs_plonk_evaluation_Calculation. + + (* StructRecord + { + name := "Evaluator"; + ty_params := [ "C" ]; + fields := + [ + ("constants", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]); + ("rotations", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "i32"; Ty.path "alloc::alloc::Global" ]); + ("calculations", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::evaluation::CalculationInfo"; + Ty.path "alloc::alloc::Global" + ]); + ("value_parts", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::evaluation::ValueSource"; + Ty.path "alloc::alloc::Global" + ]); + ("lookup_results", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::evaluation::Calculation"; + Ty.path "alloc::alloc::Global" + ]); + ("gpu_gates_expr", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]); + ("gpu_lookup_expr", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]); + ("unit_ref_count", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; Ty.path "alloc::alloc::Global" ]) + ]; + } *) + + Module Impl_core_default_Default_where_core_default_Default_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_default_Default_associated_type_where_core_default_Default_associated_type_where_core_default_Default_associated_type_for_halo2_proofs_plonk_evaluation_Evaluator_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") [ C ]. + + (* Default *) + Definition default (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [] => + ltac:(M.monadic + (Value.StructRecord + "halo2_proofs::plonk::evaluation::Evaluator" + [ + ("constants", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "default", + [] + |), + [] + |)); + ("rotations", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "i32"; Ty.path "alloc::alloc::Global" ], + [], + "default", + [] + |), + [] + |)); + ("calculations", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::evaluation::CalculationInfo"; + Ty.path "alloc::alloc::Global" + ], + [], + "default", + [] + |), + [] + |)); + ("value_parts", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::evaluation::ValueSource"; + Ty.path "alloc::alloc::Global" + ], + [], + "default", + [] + |), + [] + |)); + ("lookup_results", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::evaluation::Calculation"; + Ty.path "alloc::alloc::Global" + ], + [], + "default", + [] + |), + [] + |)); + ("gpu_gates_expr", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "default", + [] + |), + [] + |)); + ("gpu_lookup_expr", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "default", + [] + |), + [] + |)); + ("unit_ref_count", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "default", + [] + |), + [] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::default::Default" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("default", InstanceField.Method (default C)) ]. + End Impl_core_default_Default_where_core_default_Default_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_default_Default_associated_type_where_core_default_Default_associated_type_where_core_default_Default_associated_type_for_halo2_proofs_plonk_evaluation_Evaluator_C. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_evaluation_Evaluator_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let names := + M.alloc (| + M.alloc (| + Value.Array + [ + M.read (| Value.String "constants" |); + M.read (| Value.String "rotations" |); + M.read (| Value.String "calculations" |); + M.read (| Value.String "value_parts" |); + M.read (| Value.String "lookup_results" |); + M.read (| Value.String "gpu_gates_expr" |); + M.read (| Value.String "gpu_lookup_expr" |); + M.read (| Value.String "unit_ref_count" |) + ] + |) + |) in + let values := + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::Evaluator", + "constants" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::Evaluator", + "rotations" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::Evaluator", + "calculations" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::Evaluator", + "value_parts" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::Evaluator", + "lookup_results" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::Evaluator", + "gpu_gates_expr" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::Evaluator", + "gpu_lookup_expr" + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::Evaluator", + "unit_ref_count" + |) + |)) + ] + |)) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_fields_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Evaluator" |); + (* Unsize *) M.pointer_coercion (M.read (| names |)); + M.read (| values |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_evaluation_Evaluator_C. + + (* StructRecord + { + name := "CalculationInfo"; + ty_params := []; + fields := + [ + ("calculation", Ty.path "halo2_proofs::plonk::evaluation::Calculation"); + ("counter", Ty.path "usize") + ]; + } *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_evaluation_CalculationInfo. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation::CalculationInfo". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "CalculationInfo" |); + M.read (| Value.String "calculation" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::CalculationInfo", + "calculation" + |)); + M.read (| Value.String "counter" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::CalculationInfo", + "counter" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_evaluation_CalculationInfo. + + Module Impl_halo2_proofs_plonk_evaluation_Evaluator_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") [ C ]. + + (* + pub fn new(cs: &ConstraintSystem) -> Self { + let mut e = ProveExpression::new(); + + let mut ev = Evaluator::default(); + ev.add_constant(&C::ScalarExt::zero()); + ev.add_constant(&C::ScalarExt::one()); + + // Custom gates + + for gate in cs.gates.iter() { + for poly in gate.polynomials().iter() { + let vs = ev.add_expression(poly); + ev.value_parts.push(vs); + e = e.add_gate(poly); + } + } + + let e_exprs = e.flatten().into_iter().collect::>(); + + let n_gpu = *crate::plonk::N_GPU; + log::debug!("gpus number is {}", n_gpu); + let es = e_exprs + .chunks((e_exprs.len() + n_gpu - 1) / n_gpu) + .map(|e| ProveExpression::reconstruct(e)) + .collect::>(); + + for (i, e) in es.iter().enumerate() { + let complexity = e.get_complexity(); + ev.unit_ref_count = complexity.ref_cnt.into_iter().collect(); + ev.unit_ref_count.sort_by(|(_, l), (_, r)| u32::cmp(l, r)); + ev.unit_ref_count.reverse(); + + debug!("--------- expr part {} ---------", i); + debug!("complexity is {:?}", e.get_complexity()); + debug!("sorted ref cnt is {:?}", ev.unit_ref_count); + debug!("r deep is {}", e.get_r_deep()); + } + + // Lookups + for lookup in cs.lookups.iter() { + let evaluate_lc = |ev: &mut Evaluator<_>, expressions: &Vec>| { + let parts = expressions + .iter() + .map(|expr| ev.add_expression(expr)) + .collect::>(); + let mut lc = parts[0]; + for part in parts.iter().skip(1) { + lc = ev.add_calculation(Calculation::LcTheta(lc, *part)); + } + lc + }; + // Input coset + let compressed_input_coset = evaluate_lc(&mut ev, &lookup.input_expressions); + // table coset + let compressed_table_coset = evaluate_lc(&mut ev, &lookup.table_expressions); + // z(\omega X) (a'(X) + \beta) (s'(X) + \gamma) + let right_gamma = ev.add_calculation(Calculation::AddGamma(compressed_table_coset)); + ev.lookup_results + .push(Calculation::LcBeta(compressed_input_coset, right_gamma)); + } + + // Lookups in GPU + for lookup in cs.lookups.iter() { + let evaluate_lc = |expressions: &Vec>| { + let parts = expressions + .iter() + .map(|expr| LookupProveExpression::Expression(ProveExpression::from_expr(expr))) + .collect::>(); + let mut lc = parts[0].clone(); + for part in parts.into_iter().skip(1) { + lc = LookupProveExpression::LcTheta(Box::new(lc), Box::new(part)); + } + lc + }; + // Input coset + let compressed_input_coset = evaluate_lc(&lookup.input_expressions); + // table coset + let compressed_table_coset = evaluate_lc(&lookup.table_expressions); + // z(\omega X) (a'(X) + \beta) (s'(X) + \gamma) + let right_gamma = LookupProveExpression::AddGamma(Box::new(compressed_table_coset)); + ev.gpu_lookup_expr.push(LookupProveExpression::LcBeta( + Box::new(compressed_input_coset), + Box::new(right_gamma), + )); + } + + ev.gpu_gates_expr = es; + ev + } + *) + Definition new (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ cs ] => + ltac:(M.monadic + (let cs := M.alloc (| cs |) in + M.read (| + let e := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ Ty.associated ], + "new", + [] + |), + [] + |) + |) in + let ev := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") [ C ], + [], + "default", + [] + |), + [] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") [ C ], + "add_constant", + [] + |), + [ + ev; + M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "zero", [] |), + [] + |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") [ C ], + "add_constant", + [] + |), + [ + ev; + M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "one", [] |), + [] + |) + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| cs |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "gates" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let gate := M.copy (| γ0_0 |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ], + "polynomials", + [] + |), + [ M.read (| gate |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let poly := M.copy (| γ0_0 |) in + let vs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "add_expression", + [] + |), + [ ev; M.read (| poly |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource"; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + ev, + "halo2_proofs::plonk::evaluation::Evaluator", + "value_parts" + |); + M.read (| vs |) + ] + |) + |) in + let _ := + M.write (| + e, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ Ty.associated ], + "add_gate", + [] + |), + [ + M.read (| e |); + M.read (| poly |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let e_exprs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; Ty.associated; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ Ty.associated ], + "flatten", + [] + |), + [ M.read (| e |) ] + |) + ] + |) + ] + |) + |) in + let n_gpu := + M.copy (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "halo2_proofs::plonk::prover::N_GPU", + [], + "deref", + [] + |), + [ M.read (| M.get_constant (| "halo2_proofs::plonk::prover::N_GPU" |) |) ] + |) + |) in + let _ := + let lvl := M.alloc (| Value.StructTuple "log::Level::Debug" [] |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ lvl; M.get_constant (| "log::STATIC_MAX_LEVEL" |) ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ + lvl; + M.alloc (| + M.call_closure (| + M.get_function (| "log::max_level", [] |), + [] + |) + |) + ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| "log::__private_api::log", [ Ty.tuple [] ] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array [ M.read (| Value.String "gpus number is " |) ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ n_gpu ] + |) + ] + |)) + ] + |); + M.read (| lvl |); + M.alloc (| + Value.Tuple + [ + M.read (| Value.String "halo2_proofs::plonk::evaluation" |); + M.read (| Value.String "halo2_proofs::plonk::evaluation" |); + M.read (| + Value.String "halo2_proofs/src/plonk/evaluation.rs" + |) + ] + |); + Value.Integer 298; + Value.Tuple [] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let es := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Chunks") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ Ty.associated ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Chunks") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ Ty.associated ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ Ty.associated ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "chunks", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ e_exprs ] + |); + BinOp.Panic.div (| + Integer.Usize, + BinOp.Panic.sub (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ e_exprs ] + |), + M.read (| n_gpu |) + |), + Value.Integer 1 + |), + M.read (| n_gpu |) + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let e := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ Ty.associated ], + "reconstruct", + [] + |), + [ M.read (| e |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ Ty.associated ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ Ty.associated ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ Ty.associated ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ es ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ Ty.associated ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let i := M.copy (| γ1_0 |) in + let e := M.copy (| γ1_1 |) in + let complexity := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ Ty.associated ], + "get_complexity", + [] + |), + [ M.read (| e |) ] + |) + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + ev, + "halo2_proofs::plonk::evaluation::Evaluator", + "unit_ref_count" + |), + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "std::collections::hash::map::IntoIter") + [ Ty.path "usize"; Ty.path "u32" ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "u32"; + Ty.path "std::hash::random::RandomState" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + complexity, + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "ref_cnt" + |) + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] ], + "sort_by", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ Ty.path "usize"; Ty.path "u32" ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ Ty.path "usize"; Ty.path "u32" ] + ] + ] + ] + (Ty.path "core::cmp::Ordering") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + ev, + "halo2_proofs::plonk::evaluation::Evaluator", + "unit_ref_count" + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let l := M.alloc (| γ1_1 |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let r := + M.alloc (| γ1_1 |) in + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path "u32", + [], + "cmp", + [] + |), + [ + M.read (| l |); + M.read (| r |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] ], + "reverse", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + ev, + "halo2_proofs::plonk::evaluation::Evaluator", + "unit_ref_count" + |) + ] + |) + ] + |) + |) in + let _ := + let lvl := + M.alloc (| + Value.StructTuple "log::Level::Debug" [] + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ + lvl; + M.get_constant (| + "log::STATIC_MAX_LEVEL" + |) + ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ + lvl; + M.alloc (| + M.call_closure (| + M.get_function (| + "log::max_level", + [] + |), + [] + |) + |) + ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "log::__private_api::log", + [ Ty.tuple [] ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "--------- expr part " + |); + M.read (| + Value.String " ---------" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ i ] + |) + ] + |)) + ] + |); + M.read (| lvl |); + M.alloc (| + Value.Tuple + [ + M.read (| + Value.String + "halo2_proofs::plonk::evaluation" + |); + M.read (| + Value.String + "halo2_proofs::plonk::evaluation" + |); + M.read (| + Value.String + "halo2_proofs/src/plonk/evaluation.rs" + |) + ] + |); + Value.Integer 310; + Value.Tuple [] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + let lvl := + M.alloc (| + Value.StructTuple "log::Level::Debug" [] + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ + lvl; + M.get_constant (| + "log::STATIC_MAX_LEVEL" + |) + ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ + lvl; + M.alloc (| + M.call_closure (| + M.get_function (| + "log::max_level", + [] + |), + [] + |) + |) + ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "log::__private_api::log", + [ Ty.tuple [] ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "complexity is " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_debug", + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler" + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ Ty.associated ], + "get_complexity", + [] + |), + [ M.read (| e |) ] + |) + |) + ] + |) + ] + |)) + ] + |); + M.read (| lvl |); + M.alloc (| + Value.Tuple + [ + M.read (| + Value.String + "halo2_proofs::plonk::evaluation" + |); + M.read (| + Value.String + "halo2_proofs::plonk::evaluation" + |); + M.read (| + Value.String + "halo2_proofs/src/plonk/evaluation.rs" + |) + ] + |); + Value.Integer 311; + Value.Tuple [] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + let lvl := + M.alloc (| + Value.StructTuple "log::Level::Debug" [] + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ + lvl; + M.get_constant (| + "log::STATIC_MAX_LEVEL" + |) + ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ + lvl; + M.alloc (| + M.call_closure (| + M.get_function (| + "log::max_level", + [] + |), + [] + |) + |) + ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "log::__private_api::log", + [ Ty.tuple [] ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "sorted ref cnt is " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_debug", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.path "u32" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.SubPointer.get_struct_record_field (| + ev, + "halo2_proofs::plonk::evaluation::Evaluator", + "unit_ref_count" + |) + ] + |) + ] + |)) + ] + |); + M.read (| lvl |); + M.alloc (| + Value.Tuple + [ + M.read (| + Value.String + "halo2_proofs::plonk::evaluation" + |); + M.read (| + Value.String + "halo2_proofs::plonk::evaluation" + |); + M.read (| + Value.String + "halo2_proofs/src/plonk/evaluation.rs" + |) + ] + |); + Value.Integer 312; + Value.Tuple [] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + let lvl := + M.alloc (| + Value.StructTuple "log::Level::Debug" [] + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ + lvl; + M.get_constant (| + "log::STATIC_MAX_LEVEL" + |) + ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ + lvl; + M.alloc (| + M.call_closure (| + M.get_function (| + "log::max_level", + [] + |), + [] + |) + |) + ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "log::__private_api::log", + [ Ty.tuple [] ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String "r deep is " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "u32" ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ Ty.associated ], + "get_r_deep", + [] + |), + [ M.read (| e |) ] + |) + |) + ] + |) + ] + |)) + ] + |); + M.read (| lvl |); + M.alloc (| + Value.Tuple + [ + M.read (| + Value.String + "halo2_proofs::plonk::evaluation" + |); + M.read (| + Value.String + "halo2_proofs::plonk::evaluation" + |); + M.read (| + Value.String + "halo2_proofs/src/plonk/evaluation.rs" + |) + ] + |); + Value.Integer 313; + Value.Tuple [] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| cs |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "lookups" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let lookup := M.copy (| γ0_0 |) in + let evaluate_lc := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ev := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let expressions := + M.copy (| γ |) in + M.read (| + let parts := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + Ty.associated + ] + ] + ] + ] + (Ty.path + "halo2_proofs::plonk::evaluation::ValueSource") + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource"; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + Ty.associated + ] + ], + [], + "map", + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + Ty.associated + ] + ] + ] + ] + (Ty.path + "halo2_proofs::plonk::evaluation::ValueSource") + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + Ty.associated + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + expressions + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + expr := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation::Evaluator") + [ + C + ], + "add_expression", + [] + |), + [ + M.read (| + ev + |); + M.read (| + expr + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let lc := + M.copy (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ parts; Value.Integer 0 + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource" + ], + [], + "skip", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ parts + ] + |) + ] + |); + Value.Integer + 1 + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource" + ] + ], + [], + "next", + [] + |), + [ iter + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + part := + M.copy (| + γ0_0 + |) in + let + _ := + M.write (| + lc, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation::Evaluator") + [ + C + ], + "add_calculation", + [] + |), + [ + M.read (| + ev + |); + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::LcTheta" + [ + M.read (| + lc + |); + M.read (| + M.read (| + part + |) + |) + ] + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + lc + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let compressed_input_coset := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation::Evaluator") + [ C ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + (Ty.path + "halo2_proofs::plonk::evaluation::ValueSource"), + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation::Evaluator") + [ C ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ], + "call", + [] + |), + [ + evaluate_lc; + Value.Tuple + [ + ev; + M.SubPointer.get_struct_record_field (| + M.read (| lookup |), + "halo2_proofs::plonk::lookup::Argument", + "input_expressions" + |) + ] + ] + |) + |) in + let compressed_table_coset := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation::Evaluator") + [ C ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + (Ty.path + "halo2_proofs::plonk::evaluation::ValueSource"), + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation::Evaluator") + [ C ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ], + "call", + [] + |), + [ + evaluate_lc; + Value.Tuple + [ + ev; + M.SubPointer.get_struct_record_field (| + M.read (| lookup |), + "halo2_proofs::plonk::lookup::Argument", + "table_expressions" + |) + ] + ] + |) + |) in + let right_gamma := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "add_calculation", + [] + |), + [ + ev; + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::AddGamma" + [ M.read (| compressed_table_coset |) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation::Calculation"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + ev, + "halo2_proofs::plonk::evaluation::Evaluator", + "lookup_results" + |); + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::LcBeta" + [ + M.read (| compressed_input_coset |); + M.read (| right_gamma |) + ] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| cs |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "lookups" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let lookup := M.copy (| γ0_0 |) in + let evaluate_lc := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let expressions := M.copy (| γ |) in + M.read (| + let parts := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + Ty.associated + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ Ty.associated ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ Ty.associated ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ Ty.associated ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + Ty.associated + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ Ty.associated ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + expressions + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + expr := + M.copy (| + γ + |) in + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression::Expression" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ + Ty.associated + ], + "from_expr", + [] + |), + [ + M.read (| + expr + |) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let lc := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ Ty.associated ], + [], + "clone", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ Ty.associated ]; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ parts; Value.Integer 0 ] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "skip", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ + Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| parts |) + ] + |); + Value.Integer 1 + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := + M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ + Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let part := + M.copy (| + γ0_0 + |) in + let _ := + M.write (| + lc, + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression::LcTheta" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ + Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.read (| + lc + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ + Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.read (| + part + |) + ] + |) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + |))) + ] + |)) in + lc + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let compressed_input_coset := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ Ty.associated ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ], + "call", + [] + |), + [ + evaluate_lc; + Value.Tuple + [ + M.SubPointer.get_struct_record_field (| + M.read (| lookup |), + "halo2_proofs::plonk::lookup::Argument", + "input_expressions" + |) + ] + ] + |) + |) in + let compressed_table_coset := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ Ty.associated ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ], + "call", + [] + |), + [ + evaluate_lc; + Value.Tuple + [ + M.SubPointer.get_struct_record_field (| + M.read (| lookup |), + "halo2_proofs::plonk::lookup::Argument", + "table_expressions" + |) + ] + ] + |) + |) in + let right_gamma := + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression::AddGamma" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| compressed_table_coset |) ] + |) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + ev, + "halo2_proofs::plonk::evaluation::Evaluator", + "gpu_lookup_expr" + |); + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression::LcBeta" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| compressed_input_coset |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| right_gamma |) ] + |) + ] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + ev, + "halo2_proofs::plonk::evaluation::Evaluator", + "gpu_gates_expr" + |), + M.read (| es |) + |) in + ev + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "new" (new C). + + (* + fn add_rotation(&mut self, rotation: &Rotation) -> usize { + let position = self.rotations.iter().position(|&c| c == rotation.0); + match position { + Some(pos) => pos, + None => { + self.rotations.push(rotation.0); + self.rotations.len() - 1 + } + } + } + *) + Definition add_rotation (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; rotation ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rotation := M.alloc (| rotation |) in + M.read (| + let position := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.path "i32" ], + [], + "position", + [ + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "i32" ] ] ] + (Ty.path "bool") + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "i32" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "i32"; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::Evaluator", + "rotations" + |) + ] + |) + ] + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let c := M.copy (| γ |) in + BinOp.Pure.eq + (M.read (| c |)) + (M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| rotation |), + "halo2_proofs::poly::Rotation", + 0 + |) + |)))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.match_operator (| + position, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let pos := M.copy (| γ0_0 |) in + pos)); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "i32"; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::Evaluator", + "rotations" + |); + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| rotation |), + "halo2_proofs::poly::Rotation", + 0 + |) + |) + ] + |) + |) in + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "i32"; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::Evaluator", + "rotations" + |) + ] + |), + Value.Integer 1 + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_add_rotation : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "add_rotation" (add_rotation C). + + (* + fn add_constant(&mut self, constant: &C::ScalarExt) -> ValueSource { + let position = self.constants.iter().position(|&c| c == *constant); + ValueSource::Constant(match position { + Some(pos) => pos, + None => { + self.constants.push( *constant); + self.constants.len() - 1 + } + }) + } + *) + Definition add_constant (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; constant ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let constant := M.alloc (| constant |) in + M.read (| + let position := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.associated ], + [], + "position", + [ + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.associated ] ] ] + (Ty.path "bool") + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::Evaluator", + "constants" + |) + ] + |) + ] + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let c := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ Ty.associated ], + "eq", + [] + |), + [ c; M.read (| constant |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::ValueSource::Constant" + [ + M.read (| + M.match_operator (| + position, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let pos := M.copy (| γ0_0 |) in + pos)); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::Evaluator", + "constants" + |); + M.read (| M.read (| constant |) |) + ] + |) + |) in + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::Evaluator", + "constants" + |) + ] + |), + Value.Integer 1 + |) + |))) + ] + |) + |) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_add_constant : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "add_constant" (add_constant C). + + (* + fn add_calculation(&mut self, calculation: Calculation) -> ValueSource { + let position = self + .calculations + .iter() + .position(|c| c.calculation == calculation); + match position { + Some(pos) => { + self.calculations[pos].counter += 1; + ValueSource::Intermediate(pos) + } + None => { + self.calculations.push(CalculationInfo { + counter: 1, + calculation, + }); + ValueSource::Intermediate(self.calculations.len() - 1) + } + } + } + *) + Definition add_calculation (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; calculation ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let calculation := M.alloc (| calculation |) in + M.read (| + let position := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "halo2_proofs::plonk::evaluation::CalculationInfo" ], + [], + "position", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "halo2_proofs::plonk::evaluation::CalculationInfo" ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "halo2_proofs::plonk::evaluation::CalculationInfo" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::evaluation::CalculationInfo"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::Evaluator", + "calculations" + |) + ] + |) + ] + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let c := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::plonk::evaluation::Calculation", + [ Ty.path "halo2_proofs::plonk::evaluation::Calculation" + ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| c |), + "halo2_proofs::plonk::evaluation::CalculationInfo", + "calculation" + |); + calculation + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.match_operator (| + position, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let pos := M.copy (| γ0_0 |) in + let _ := + let β := + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::evaluation::CalculationInfo"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::Evaluator", + "calculations" + |); + M.read (| pos |) + ] + |), + "halo2_proofs::plonk::evaluation::CalculationInfo", + "counter" + |) in + M.write (| + β, + BinOp.Panic.add (| Integer.Usize, M.read (| β |), Value.Integer 1 |) + |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::ValueSource::Intermediate" + [ M.read (| pos |) ] + |))); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::evaluation::CalculationInfo"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::Evaluator", + "calculations" + |); + Value.StructRecord + "halo2_proofs::plonk::evaluation::CalculationInfo" + [ + ("counter", Value.Integer 1); + ("calculation", M.read (| calculation |)) + ] + ] + |) + |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::ValueSource::Intermediate" + [ + BinOp.Panic.sub (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::plonk::evaluation::CalculationInfo"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::Evaluator", + "calculations" + |) + ] + |), + Value.Integer 1 + |) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_add_calculation : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "add_calculation" (add_calculation C). + + (* + fn add_expression(&mut self, expr: &Expression) -> ValueSource { + match expr { + Expression::Constant(scalar) => self.add_constant(scalar), + Expression::Selector(_selector) => unreachable!(), + Expression::Fixed { + query_index: _, + column_index, + rotation, + } => { + let rot_idx = self.add_rotation(rotation); + self.add_calculation(Calculation::Store(ValueSource::Fixed( + *column_index, + rot_idx, + ))) + } + Expression::Advice { + query_index: _, + column_index, + rotation, + } => { + let rot_idx = self.add_rotation(rotation); + self.add_calculation(Calculation::Store(ValueSource::Advice( + *column_index, + rot_idx, + ))) + } + Expression::Instance { + query_index: _, + column_index, + rotation, + } => { + let rot_idx = self.add_rotation(rotation); + self.add_calculation(Calculation::Store(ValueSource::Instance( + *column_index, + rot_idx, + ))) + } + Expression::Negated(a) => match **a { + Expression::Constant(scalar) => self.add_constant(&-scalar), + _ => { + let result_a = self.add_expression(a); + match result_a { + ValueSource::Constant(0) => result_a, + _ => self.add_calculation(Calculation::Negate(result_a)), + } + } + }, + Expression::Sum(a, b) => { + // Undo subtraction stored as a + (-b) in expressions + match &**b { + Expression::Negated(b_int) => { + let result_a = self.add_expression(a); + let result_b = self.add_expression(b_int); + if result_a == ValueSource::Constant(0) { + result_b + } else if result_b == ValueSource::Constant(0) { + result_a + } else { + self.add_calculation(Calculation::Sub(result_a, result_b)) + } + } + _ => { + let result_a = self.add_expression(a); + let result_b = self.add_expression(b); + if result_a == ValueSource::Constant(0) { + result_b + } else if result_b == ValueSource::Constant(0) { + result_a + } else if result_a <= result_b { + self.add_calculation(Calculation::Add(result_a, result_b)) + } else { + self.add_calculation(Calculation::Add(result_b, result_a)) + } + } + } + } + Expression::Product(a, b) => { + let result_a = self.add_expression(a); + let result_b = self.add_expression(b); + if result_a == ValueSource::Constant(0) || result_b == ValueSource::Constant(0) { + ValueSource::Constant(0) + } else if result_a == ValueSource::Constant(1) { + result_b + } else if result_b == ValueSource::Constant(1) { + result_a + } else if result_a <= result_b { + self.add_calculation(Calculation::Mul(result_a, result_b)) + } else { + self.add_calculation(Calculation::Mul(result_b, result_a)) + } + } + Expression::Scaled(a, f) => { + if *f == C::ScalarExt::zero() { + ValueSource::Constant(0) + } else if *f == C::ScalarExt::one() { + self.add_expression(a) + } else { + let cst = self.add_constant(f); + let result_a = self.add_expression(a); + self.add_calculation(Calculation::Mul(result_a, cst)) + } + } + } + } + *) + Definition add_expression (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; expr ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let expr := M.alloc (| expr |) in + M.read (| + M.match_operator (| + expr, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Constant", + 0 + |) in + let scalar := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") [ C ], + "add_constant", + [] + |), + [ M.read (| self |); M.read (| scalar |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Selector", + 0 + |) in + let _selector := M.alloc (| γ1_0 |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "internal error: entered unreachable code" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "rotation" + |) in + let column_index := M.alloc (| γ1_1 |) in + let rotation := M.alloc (| γ1_2 |) in + let rot_idx := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") [ C ], + "add_rotation", + [] + |), + [ M.read (| self |); M.read (| rotation |) ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") [ C ], + "add_calculation", + [] + |), + [ + M.read (| self |); + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::Store" + [ + Value.StructTuple + "halo2_proofs::plonk::evaluation::ValueSource::Fixed" + [ M.read (| M.read (| column_index |) |); M.read (| rot_idx |) ] + ] + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "rotation" + |) in + let column_index := M.alloc (| γ1_1 |) in + let rotation := M.alloc (| γ1_2 |) in + let rot_idx := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") [ C ], + "add_rotation", + [] + |), + [ M.read (| self |); M.read (| rotation |) ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") [ C ], + "add_calculation", + [] + |), + [ + M.read (| self |); + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::Store" + [ + Value.StructTuple + "halo2_proofs::plonk::evaluation::ValueSource::Advice" + [ M.read (| M.read (| column_index |) |); M.read (| rot_idx |) ] + ] + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "query_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "column_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "rotation" + |) in + let column_index := M.alloc (| γ1_1 |) in + let rotation := M.alloc (| γ1_2 |) in + let rot_idx := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") [ C ], + "add_rotation", + [] + |), + [ M.read (| self |); M.read (| rotation |) ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") [ C ], + "add_calculation", + [] + |), + [ + M.read (| self |); + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::Store" + [ + Value.StructTuple + "halo2_proofs::plonk::evaluation::ValueSource::Instance" + [ M.read (| M.read (| column_index |) |); M.read (| rot_idx |) ] + ] + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Negated", + 0 + |) in + let a := M.alloc (| γ1_0 |) in + M.match_operator (| + M.read (| M.read (| a |) |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Constant", + 0 + |) in + let scalar := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "add_constant", + [] + |), + [ + M.read (| self |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Neg", + Ty.associated, + [], + "neg", + [] + |), + [ M.read (| scalar |) ] + |) + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let result_a := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "add_expression", + [] + |), + [ M.read (| self |); M.read (| M.read (| a |) |) ] + |) + |) in + M.match_operator (| + result_a, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation::ValueSource::Constant", + 0 + |) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ0_0 |), + Value.Integer 0 + |) in + result_a)); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "add_calculation", + [] + |), + [ + M.read (| self |); + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::Negate" + [ M.read (| result_a |) ] + ] + |) + |))) + ] + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let b := M.alloc (| γ1_1 |) in + M.match_operator (| + M.alloc (| M.read (| M.read (| b |) |) |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Negated", + 0 + |) in + let b_int := M.alloc (| γ1_0 |) in + let result_a := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "add_expression", + [] + |), + [ M.read (| self |); M.read (| M.read (| a |) |) ] + |) + |) in + let result_b := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "add_expression", + [] + |), + [ M.read (| self |); M.read (| M.read (| b_int |) |) ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource", + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource" + ], + "eq", + [] + |), + [ + result_a; + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::ValueSource::Constant" + [ Value.Integer 0 ] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + result_b)); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource", + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource" + ], + "eq", + [] + |), + [ + result_b; + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::ValueSource::Constant" + [ Value.Integer 0 ] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + result_a)); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "add_calculation", + [] + |), + [ + M.read (| self |); + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::Sub" + [ M.read (| result_a |); M.read (| result_b |) + ] + ] + |) + |))) + ] + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let result_a := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "add_expression", + [] + |), + [ M.read (| self |); M.read (| M.read (| a |) |) ] + |) + |) in + let result_b := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "add_expression", + [] + |), + [ M.read (| self |); M.read (| M.read (| b |) |) ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource", + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource" + ], + "eq", + [] + |), + [ + result_a; + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::ValueSource::Constant" + [ Value.Integer 0 ] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + result_b)); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource", + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource" + ], + "eq", + [] + |), + [ + result_b; + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::ValueSource::Constant" + [ Value.Integer 0 ] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + result_a)); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource", + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource" + ], + "le", + [] + |), + [ result_a; result_b ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "add_calculation", + [] + |), + [ + M.read (| self |); + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::Add" + [ + M.read (| result_a |); + M.read (| result_b |) + ] + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "add_calculation", + [] + |), + [ + M.read (| self |); + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::Add" + [ + M.read (| result_b |); + M.read (| result_a |) + ] + ] + |) + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let b := M.alloc (| γ1_1 |) in + let result_a := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") [ C ], + "add_expression", + [] + |), + [ M.read (| self |); M.read (| M.read (| a |) |) ] + |) + |) in + let result_b := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") [ C ], + "add_expression", + [] + |), + [ M.read (| self |); M.read (| M.read (| b |) |) ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.or (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" + ], + "eq", + [] + |), + [ + result_a; + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::ValueSource::Constant" + [ Value.Integer 0 ] + |) + ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::plonk::evaluation::ValueSource", + [ Ty.path "halo2_proofs::plonk::evaluation::ValueSource" + ], + "eq", + [] + |), + [ + result_b; + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::ValueSource::Constant" + [ Value.Integer 0 ] + |) + ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::ValueSource::Constant" + [ Value.Integer 0 ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource", + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource" + ], + "eq", + [] + |), + [ + result_a; + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::ValueSource::Constant" + [ Value.Integer 1 ] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + result_b)); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource", + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource" + ], + "eq", + [] + |), + [ + result_b; + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::ValueSource::Constant" + [ Value.Integer 1 ] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + result_a)); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource", + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource" + ], + "le", + [] + |), + [ result_a; result_b ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "add_calculation", + [] + |), + [ + M.read (| self |); + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::Mul" + [ + M.read (| result_a |); + M.read (| result_b |) + ] + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "add_calculation", + [] + |), + [ + M.read (| self |); + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::Mul" + [ + M.read (| result_b |); + M.read (| result_a |) + ] + ] + |) + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 1 + |) in + let a := M.alloc (| γ1_0 |) in + let f := M.alloc (| γ1_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ Ty.associated ], + "eq", + [] + |), + [ + M.read (| f |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "zero", + [] + |), + [] + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation::ValueSource::Constant" + [ Value.Integer 0 ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ Ty.associated ], + "eq", + [] + |), + [ + M.read (| f |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "add_expression", + [] + |), + [ M.read (| self |); M.read (| M.read (| a |) |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let cst := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "add_constant", + [] + |), + [ M.read (| self |); M.read (| f |) ] + |) + |) in + let result_a := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "add_expression", + [] + |), + [ M.read (| self |); M.read (| M.read (| a |) |) ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "add_calculation", + [] + |), + [ + M.read (| self |); + Value.StructTuple + "halo2_proofs::plonk::evaluation::Calculation::Mul" + [ M.read (| result_a |); M.read (| cst |) ] + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_add_expression : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "add_expression" (add_expression C). + + (* + pub(in crate::plonk) fn evaluate_h( + &self, + pk: &ProvingKey, + advice: Vec<&Vec>>, + instance: Vec<&Vec>>, + y: C::ScalarExt, + beta: C::ScalarExt, + gamma: C::ScalarExt, + theta: C::ScalarExt, + lookups: &[Vec>], + permutations: &[permutation::prover::Committed], + ) -> Polynomial { + let domain = &pk.vk.domain; + let size = domain.extended_len(); + let rot_scale = 1 << (domain.extended_k() - domain.k()); + let fixed = &pk.fixed_cosets[..]; + let extended_omega = domain.get_extended_omega(); + let num_lookups = pk.vk.cs.lookups.len(); + let isize = size as i32; + let one = C::ScalarExt::one(); + let l0 = &pk.l0; + let l_last = &pk.l_last; + let l_active_row = &pk.l_active_row; + let p = &pk.vk.cs.permutation; + + let mut values = domain.empty_extended(); + let mut lookup_values = vec![C::Scalar::zero(); size * num_lookups]; + + // Core expression evaluations + let num_threads = multicore::current_num_threads(); + let mut table_values_box = ThreadBox::wrap(&mut lookup_values); + + for (((advice, instance), lookups), permutation) in advice + .iter() + .zip(instance.iter()) + .zip(lookups.iter()) + .zip(permutations.iter()) + { + let timer = ark_std::start_timer!(|| "expressions"); + multicore::scope(|scope| { + let chunk_size = (size + num_threads - 1) / num_threads; + for (thread_idx, values) in values.chunks_mut(chunk_size).enumerate() { + let start = thread_idx * chunk_size; + scope.spawn(move |_| { + let table_values = table_values_box.unwrap(); + let mut rotations = vec![0usize; self.rotations.len()]; + let mut intermediates: Vec = + vec![C::ScalarExt::zero(); self.calculations.len()]; + for (i, value) in values.iter_mut().enumerate() { + let idx = start + i; + + // All rotation index values + for (rot_idx, rot) in self.rotations.iter().enumerate() { + rotations[rot_idx] = get_rotation_idx(idx, *rot, rot_scale, isize); + } + + // All calculations, with cached intermediate results + for (i_idx, calc) in self.calculations.iter().enumerate() { + intermediates[i_idx] = calc.calculation.evaluate( + &rotations, + &self.constants, + &intermediates, + fixed, + advice, + instance, + &beta, + &gamma, + &theta, + ); + } + + // Accumulate value parts + for value_part in self.value_parts.iter() { + *value = *value * y + + value_part.get( + &rotations, + &self.constants, + &intermediates, + fixed, + advice, + instance, + ); + } + + // Values required for the lookups + for (t, table_result) in self.lookup_results.iter().enumerate() { + table_values[t * size + idx] = table_result.evaluate( + &rotations, + &self.constants, + &intermediates, + fixed, + advice, + instance, + &beta, + &gamma, + &theta, + ); + } + } + }); + } + }); + end_timer!(timer); + + let timer = ark_std::start_timer!(|| "permutations"); + // Permutations + let sets = &permutation.sets; + if !sets.is_empty() { + let blinding_factors = pk.vk.cs.blinding_factors(); + let last_rotation = Rotation(-((blinding_factors + 1) as i32)); + let chunk_len = pk.vk.cs.degree() - 2; + let delta_start = beta * &C::Scalar::ZETA; + + let first_set = sets.first().unwrap(); + let last_set = sets.last().unwrap(); + + // Permutation constraints + parallelize(&mut values, |values, start| { + let mut beta_term = extended_omega.pow_vartime(&[start as u64, 0, 0, 0]); + for (i, value) in values.iter_mut().enumerate() { + let idx = start + i; + let r_next = get_rotation_idx(idx, 1, rot_scale, isize); + let r_last = get_rotation_idx(idx, last_rotation.0, rot_scale, isize); + + // Enforce only for the first set. + // l_0(X) * (1 - z_0(X)) = 0 + *value = *value * y + + ((one - first_set.permutation_product_coset[idx]) * l0[idx]); + // Enforce only for the last set. + // l_last(X) * (z_l(X)^2 - z_l(X)) = 0 + *value = *value * y + + ((last_set.permutation_product_coset[idx] + * last_set.permutation_product_coset[idx] + - last_set.permutation_product_coset[idx]) + * l_last[idx]); + // Except for the first set, enforce. + // l_0(X) * (z_i(X) - z_{i-1}(\omega^(last) X)) = 0 + for (set_idx, set) in sets.iter().enumerate() { + if set_idx != 0 { + *value = *value * y + + ((set.permutation_product_coset[idx] + - permutation.sets[set_idx - 1].permutation_product_coset + [r_last]) + * l0[idx]); + } + } + // And for all the sets we enforce: + // (1 - (l_last(X) + l_blind(X))) * ( + // z_i(\omega X) \prod_j (p(X) + \beta s_j(X) + \gamma) + // - z_i(X) \prod_j (p(X) + \delta^j \beta X + \gamma) + // ) + let mut current_delta = delta_start * beta_term; + for ((set, columns), cosets) in sets + .iter() + .zip(p.columns.chunks(chunk_len)) + .zip(pk.permutation.cosets.chunks(chunk_len)) + { + let mut left = set.permutation_product_coset[r_next]; + for (values, permutation) in columns + .iter() + .map(|&column| match column.column_type() { + Any::Advice => &advice[column.index()], + Any::Fixed => &fixed[column.index()], + Any::Instance => &instance[column.index()], + }) + .zip(cosets.iter()) + { + left *= values[idx] + beta * permutation[idx] + gamma; + } + + let mut right = set.permutation_product_coset[idx]; + for values in columns.iter().map(|&column| match column.column_type() { + Any::Advice => &advice[column.index()], + Any::Fixed => &fixed[column.index()], + Any::Instance => &instance[column.index()], + }) { + right *= values[idx] + current_delta + gamma; + current_delta *= &C::Scalar::DELTA; + } + + *value = *value * y + ((left - right) * l_active_row[idx]); + } + beta_term *= &extended_omega; + } + }); + } + end_timer!(timer); + + let timer = ark_std::start_timer!(|| "eval_h_lookups"); + + for (lookup_idx, lookup) in lookups.iter().enumerate() { + // Lookup constraints + let table = &lookup_values[lookup_idx * size..(lookup_idx + 1) * size]; + // Polynomials required for this lookup. + // Calculated here so these only have to be kept in memory for the short time + // they are actually needed. + let product_coset = pk.vk.domain.coeff_to_extended(lookup.product_poly.clone()); + let permuted_input_coset = pk + .vk + .domain + .coeff_to_extended(lookup.permuted_input_poly.clone()); + let permuted_table_coset = pk + .vk + .domain + .coeff_to_extended(lookup.permuted_table_poly.clone()); + + parallelize(&mut values, |values, start| { + for (i, value) in values.iter_mut().enumerate() { + let idx = start + i; + + let r_next = get_rotation_idx(idx, 1, rot_scale, isize); + let r_prev = get_rotation_idx(idx, -1, rot_scale, isize); + + let a_minus_s = permuted_input_coset[idx] - permuted_table_coset[idx]; + // l_0(X) * (1 - z(X)) = 0 + *value = *value * y + ((one - product_coset[idx]) * l0[idx]); + // l_last(X) * (z(X)^2 - z(X)) = 0 + *value = *value * y + + ((product_coset[idx] * product_coset[idx] - product_coset[idx]) + * l_last[idx]); + // (1 - (l_last(X) + l_blind(X))) * ( + // z(\omega X) (a'(X) + \beta) (s'(X) + \gamma) + // - z(X) (\theta^{m-1} a_0(X) + ... + a_{m-1}(X) + \beta) + // (\theta^{m-1} s_0(X) + ... + s_{m-1}(X) + \gamma) + // ) = 0 + + *value = *value * y + + ((product_coset[r_next] + * (permuted_input_coset[idx] + beta) + * (permuted_table_coset[idx] + gamma) + - product_coset[idx] * table[idx]) + * l_active_row[idx]); + + // Check that the first values in the permuted input expression and permuted + // fixed expression are the same. + // l_0(X) * (a'(X) - s'(X)) = 0 + *value = *value * y + (a_minus_s * l0[idx]); + + // Check that each value in the permuted lookup input expression is either + // equal to the value above it, or the value at the same index in the + // permuted table expression. + // (1 - (l_last + l_blind)) * (a′(X) − s′(X))⋅(a′(X) − a′(\omega^{-1} X)) = 0 + *value = *value * y + + (a_minus_s + * (permuted_input_coset[idx] - permuted_input_coset[r_prev]) + * l_active_row[idx]); + } + }); + } + + end_timer!(timer); + } + + values + } + *) + Definition evaluate_h (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; pk; advice; instance; y; beta; gamma; theta; lookups; permutations ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let pk := M.alloc (| pk |) in + let advice := M.alloc (| advice |) in + let instance := M.alloc (| instance |) in + let y := M.alloc (| y |) in + let beta := M.alloc (| beta |) in + let gamma := M.alloc (| gamma |) in + let theta := M.alloc (| theta |) in + let lookups := M.alloc (| lookups |) in + let permutations := M.alloc (| permutations |) in + M.read (| + let domain := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + |) in + let size := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "extended_len", + [] + |), + [ M.read (| domain |) ] + |) + |) in + let rot_scale := + M.alloc (| + BinOp.Panic.shl (| + Value.Integer 1, + BinOp.Panic.sub (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "extended_k", + [] + |), + [ M.read (| domain |) ] + |), + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "k", + [] + |), + [ M.read (| domain |) ] + |) + |) + |) + |) in + let fixed := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::ExtendedLagrangeCoeff" ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "core::ops::range::RangeFull" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "fixed_cosets" + |); + Value.StructTuple "core::ops::range::RangeFull" [] + ] + |) + |) in + let extended_omega := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "get_extended_omega", + [] + |), + [ M.read (| domain |) ] + |) + |) in + let num_lookups := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "lookups" + |) + ] + |) + |) in + let isize := M.alloc (| M.rust_cast (M.read (| size |)) |) in + let one := + M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "one", [] |), + [] + |) + |) in + let l0 := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "l0" + |) + |) in + let l_last := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "l_last" + |) + |) in + let l_active_row := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "l_active_row" + |) + |) in + let p := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |) + |) in + let values := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "empty_extended", + [] + |), + [ M.read (| domain |) ] + |) + |) in + let lookup_values := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ Ty.associated ] |), + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "zero", [] |), + [] + |); + BinOp.Panic.mul (| + Integer.Usize, + M.read (| size |), + M.read (| num_lookups |) + |) + ] + |) + |) in + let num_threads := + M.alloc (| + M.call_closure (| + M.get_function (| "rayon_core::current_num_threads", [] |), + [] + |) + |) in + let table_values_box := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation::ThreadBox") + [ Ty.associated ], + "wrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ lookup_values ] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ C ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::permutation::prover::Committed") + [ C ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ C ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ C ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ C ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ advice ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ instance ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ C ]; + Ty.path "alloc::alloc::Global" + ] + ], + "iter", + [] + |), + [ M.read (| lookups |) ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ C ] + ], + "iter", + [] + |), + [ M.read (| permutations |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ C ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ C ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let γ2_0 := M.SubPointer.get_tuple_field (| γ1_0, 0 |) in + let γ2_1 := M.SubPointer.get_tuple_field (| γ1_0, 1 |) in + let γ3_0 := M.SubPointer.get_tuple_field (| γ2_0, 0 |) in + let γ3_1 := M.SubPointer.get_tuple_field (| γ2_0, 1 |) in + let advice := M.copy (| γ3_0 |) in + let instance := M.copy (| γ3_1 |) in + let lookups := M.copy (| γ2_1 |) in + let permutation := M.copy (| γ1_1 |) in + let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "rayon_core::scope::scope", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "rayon_core::scope::Scope" ] + ] + ] + (Ty.tuple []); + Ty.tuple [] + ] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let scope := M.copy (| γ |) in + M.read (| + let chunk_size := + M.alloc (| + BinOp.Panic.div (| + Integer.Usize, + BinOp.Panic.sub (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.read (| size |), + M.read (| num_threads |) + |), + Value.Integer 1 + |), + M.read (| num_threads |) + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::ChunksMut") + [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::ChunksMut") + [ Ty.associated ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ], + "chunks_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [], + "deref_mut", + [] + |), + [ values ] + |); + M.read (| + chunk_size + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := + M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::ChunksMut") + [ + Ty.associated + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + thread_idx := + M.copy (| + γ1_0 + |) in + let + values := + M.copy (| + γ1_1 + |) in + let + start := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + M.read (| + thread_idx + |), + M.read (| + chunk_size + |) + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "rayon_core::scope::Scope", + "spawn", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "rayon_core::scope::Scope" + ] + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.read (| + scope + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + let + table_values := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation::ThreadBox") + [ + Ty.associated + ], + "unwrap", + [] + |), + [ + table_values_box + ] + |) + |) in + let + rotations := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ + Ty.path + "usize" + ] + |), + [ + Value.Integer + 0; + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "i32"; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::plonk::evaluation::Evaluator", + "rotations" + |) + ] + |) + ] + |) + |) in + let + intermediates := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "zero", + [] + |), + [] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation::CalculationInfo"; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::plonk::evaluation::Evaluator", + "calculations" + |) + ] + |) + ] + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ], + "iter_mut", + [] + |), + [ + M.read (| + values + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + i := + M.copy (| + γ1_0 + |) in + let + value := + M.copy (| + γ1_1 + |) in + let + idx := + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.read (| + start + |), + M.read (| + i + |) + |) + |) in + let + _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "i32" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "i32" + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.path + "i32" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "i32"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::plonk::evaluation::Evaluator", + "rotations" + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "i32" + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + rot_idx := + M.copy (| + γ1_0 + |) in + let + rot := + M.copy (| + γ1_1 + |) in + let + _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "usize"; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index_mut", + [] + |), + [ + rotations; + M.read (| + rot_idx + |) + ] + |), + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::evaluation::get_rotation_idx", + [] + |), + [ + M.read (| + idx + |); + M.read (| + M.read (| + rot + |) + |); + M.read (| + rot_scale + |); + M.read (| + isize + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + let + _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::evaluation::CalculationInfo" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::evaluation::CalculationInfo" + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.path + "halo2_proofs::plonk::evaluation::CalculationInfo" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation::CalculationInfo"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::plonk::evaluation::Evaluator", + "calculations" + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::evaluation::CalculationInfo" + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + i_idx := + M.copy (| + γ1_0 + |) in + let + calc := + M.copy (| + γ1_1 + |) in + let + _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index_mut", + [] + |), + [ + intermediates; + M.read (| + i_idx + |) + ] + |), + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::plonk::evaluation::Calculation", + "evaluate", + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + calc + |), + "halo2_proofs::plonk::evaluation::CalculationInfo", + "calculation" + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "usize"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + rotations + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::plonk::evaluation::Evaluator", + "constants" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + intermediates + ] + |); + M.read (| + fixed + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + M.read (| + advice + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + M.read (| + instance + |) + |) + ] + |); + beta; + gamma; + theta + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + let + _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::plonk::evaluation::Evaluator", + "value_parts" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource" + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + value_part := + M.copy (| + γ0_0 + |) in + let + _ := + M.write (| + M.read (| + value + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + M.read (| + value + |) + |); + M.read (| + y + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::plonk::evaluation::ValueSource", + "get", + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + |), + [ + M.read (| + value_part + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "usize"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + rotations + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::plonk::evaluation::Evaluator", + "constants" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + intermediates + ] + |); + M.read (| + fixed + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + M.read (| + advice + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + M.read (| + instance + |) + |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::evaluation::Calculation" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::evaluation::Calculation" + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.path + "halo2_proofs::plonk::evaluation::Calculation" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation::Calculation"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::plonk::evaluation::Evaluator", + "lookup_results" + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::evaluation::Calculation" + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + t := + M.copy (| + γ1_0 + |) in + let + table_result := + M.copy (| + γ1_1 + |) in + let + _ := + M.write (| + M.SubPointer.get_array_field (| + M.read (| + table_values + |), + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.mul (| + Integer.Usize, + M.read (| + t + |), + M.read (| + size + |) + |), + M.read (| + idx + |) + |) + |) + |), + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::plonk::evaluation::Calculation", + "evaluate", + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + |), + [ + M.read (| + table_result + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "usize"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + rotations + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::plonk::evaluation::Evaluator", + "constants" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + intermediates + ] + |); + M.read (| + fixed + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + M.read (| + advice + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + M.read (| + instance + |) + |) + ] + |); + beta; + gamma; + theta + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + |))) + ] + |)) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let sets := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| permutation |), + "halo2_proofs::plonk::permutation::prover::Committed", + "sets" + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ C ]; + Ty.path + "alloc::alloc::Global" + ], + "is_empty", + [] + |), + [ M.read (| sets |) ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let blinding_factors := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "blinding_factors", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |) + |) in + let last_rotation := + M.alloc (| + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + UnOp.Panic.neg (| + Integer.I32, + M.rust_cast + (BinOp.Panic.add (| + Integer.Usize, + M.read (| + blinding_factors + |), + Value.Integer 1 + |)) + |) + ] + |) in + let chunk_len := + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "degree", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |), + Value.Integer 2 + |) + |) in + let delta_start := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ], + "mul", + [] + |), + [ + M.read (| beta |); + M.get_constant (| + "pairing_bn256::arithmetic::fields::FieldExt::ZETA" + |) + ] + |) + |) in + let first_set := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ C ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ C ] + ], + "first", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ C ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| sets |) ] + |) + ] + |) + ] + |) + |) in + let last_set := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ C ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ C ] + ], + "last", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ C ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| sets |) ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [], + "deref_mut", + [] + |), + [ values ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let values := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (let + start := + M.copy (| + γ + |) in + M.read (| + let + beta_term := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "pow_vartime", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.path + "u64" + ] + ] + ] + |), + [ + extended_omega; + M.alloc (| + Value.Array + [ + M.rust_cast + (M.read (| + start + |)); + Value.Integer + 0; + Value.Integer + 0; + Value.Integer + 0 + ] + |) + ] + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ], + "iter_mut", + [] + |), + [ + M.read (| + values + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + i := + M.copy (| + γ1_0 + |) in + let + value := + M.copy (| + γ1_1 + |) in + let + idx := + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.read (| + start + |), + M.read (| + i + |) + |) + |) in + let + r_next := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::evaluation::get_rotation_idx", + [] + |), + [ + M.read (| + idx + |); + Value.Integer + 1; + M.read (| + rot_scale + |); + M.read (| + isize + |) + ] + |) + |) in + let + r_last := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::evaluation::get_rotation_idx", + [] + |), + [ + M.read (| + idx + |); + M.read (| + M.SubPointer.get_struct_tuple_field (| + last_rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + |); + M.read (| + rot_scale + |); + M.read (| + isize + |) + ] + |) + |) in + let + _ := + M.write (| + M.read (| + value + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + M.read (| + value + |) + |); + M.read (| + y + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ + Ty.associated + ], + "sub", + [] + |), + [ + M.read (| + one + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + first_set + |), + "halo2_proofs::plonk::permutation::prover::CommittedSet", + "permutation_product_coset" + |); + M.read (| + idx + |) + ] + |) + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + l0 + |); + M.read (| + idx + |) + ] + |) + |) + ] + |) + ] + |) + |) in + let + _ := + M.write (| + M.read (| + value + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + M.read (| + value + |) + |); + M.read (| + y + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ + Ty.associated + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + last_set + |), + "halo2_proofs::plonk::permutation::prover::CommittedSet", + "permutation_product_coset" + |); + M.read (| + idx + |) + ] + |) + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + last_set + |), + "halo2_proofs::plonk::permutation::prover::CommittedSet", + "permutation_product_coset" + |); + M.read (| + idx + |) + ] + |) + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + last_set + |), + "halo2_proofs::plonk::permutation::prover::CommittedSet", + "permutation_product_coset" + |); + M.read (| + idx + |) + ] + |) + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + l_last + |); + M.read (| + idx + |) + ] + |) + |) + ] + |) + ] + |) + |) in + let + _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + sets + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ] + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + set_idx := + M.copy (| + γ1_0 + |) in + let + set := + M.copy (| + γ1_1 + |) in + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.read (| + set_idx + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + let + _ := + M.write (| + M.read (| + value + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + M.read (| + value + |) + |); + M.read (| + y + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ + Ty.associated + ], + "sub", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + set + |), + "halo2_proofs::plonk::permutation::prover::CommittedSet", + "permutation_product_coset" + |); + M.read (| + idx + |) + ] + |) + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + permutation + |), + "halo2_proofs::plonk::permutation::prover::Committed", + "sets" + |); + BinOp.Panic.sub (| + Integer.Usize, + M.read (| + set_idx + |), + Value.Integer + 1 + |) + ] + |), + "halo2_proofs::plonk::permutation::prover::CommittedSet", + "permutation_product_coset" + |); + M.read (| + r_last + |) + ] + |) + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + l0 + |); + M.read (| + idx + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple + [] + |))) + ] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + let + current_delta := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + delta_start + |); + M.read (| + beta_term + |) + ] + |) + |) in + let + _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Chunks") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Chunks") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Chunks") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Chunks") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Chunks") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + sets + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "chunks", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + p + |), + "halo2_proofs::plonk::permutation::Argument", + "columns" + |) + ] + |); + M.read (| + chunk_len + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + ], + "chunks", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "permutation" + |), + "halo2_proofs::plonk::permutation::ProvingKey", + "cosets" + |) + ] + |); + M.read (| + chunk_len + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Chunks") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Chunks") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + γ2_0 := + M.SubPointer.get_tuple_field (| + γ1_0, + 0 + |) in + let + γ2_1 := + M.SubPointer.get_tuple_field (| + γ1_0, + 1 + |) in + let + set := + M.copy (| + γ2_0 + |) in + let + columns := + M.copy (| + γ2_1 + |) in + let + cosets := + M.copy (| + γ1_1 + |) in + let + left := + M.copy (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + set + |), + "halo2_proofs::plonk::permutation::prover::CommittedSet", + "permutation_product_coset" + |); + M.read (| + r_next + |) + ] + |) + |) in + let + _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + ]) + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + ]) + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "iter", + [] + |), + [ + M.read (| + columns + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.read (| + γ + |) in + let + column := + M.copy (| + γ + |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "column_type", + [] + |), + [ + column + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.read (| + γ + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + M.read (| + advice + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "index", + [] + |), + [ + column + ] + |) + ] + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ := + M.read (| + γ + |) in + M.alloc (| + M.SubPointer.get_array_field (| + M.read (| + fixed + |), + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "index", + [] + |), + [ + column + ] + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ := + M.read (| + γ + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + M.read (| + instance + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "index", + [] + |), + [ + column + ] + |) + ] + |) + |))) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + ], + "iter", + [] + |), + [ + M.read (| + cosets + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + ]) + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + values := + M.copy (| + γ1_0 + |) in + let + permutation := + M.copy (| + γ1_1 + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ + Ty.associated + ], + "mul_assign", + [] + |), + [ + left; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + values + |); + M.read (| + idx + |) + ] + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + beta + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + permutation + |); + M.read (| + idx + |) + ] + |) + |) + ] + |) + ] + |); + M.read (| + gamma + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + let + right := + M.copy (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + set + |), + "halo2_proofs::plonk::permutation::prover::CommittedSet", + "permutation_product_coset" + |); + M.read (| + idx + |) + ] + |) + |) in + let + _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + ]) + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "iter", + [] + |), + [ + M.read (| + columns + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.read (| + γ + |) in + let + column := + M.copy (| + γ + |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "column_type", + [] + |), + [ + column + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.read (| + γ + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + M.read (| + advice + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "index", + [] + |), + [ + column + ] + |) + ] + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ := + M.read (| + γ + |) in + M.alloc (| + M.SubPointer.get_array_field (| + M.read (| + fixed + |), + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "index", + [] + |), + [ + column + ] + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ := + M.read (| + γ + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + M.read (| + instance + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "index", + [] + |), + [ + column + ] + |) + ] + |) + |))) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + ]) + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + values := + M.copy (| + γ0_0 + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ + Ty.associated + ], + "mul_assign", + [] + |), + [ + right; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + values + |); + M.read (| + idx + |) + ] + |) + |); + M.read (| + current_delta + |) + ] + |); + M.read (| + gamma + |) + ] + |) + ] + |) + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "mul_assign", + [] + |), + [ + current_delta; + M.get_constant (| + "pairing_bn256::arithmetic::fields::FieldExt::DELTA" + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + let + _ := + M.write (| + M.read (| + value + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + M.read (| + value + |) + |); + M.read (| + y + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ + Ty.associated + ], + "sub", + [] + |), + [ + M.read (| + left + |); + M.read (| + right + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + l_active_row + |); + M.read (| + idx + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "mul_assign", + [] + |), + [ + beta_term; + extended_omega + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ C ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ C ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ C ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| lookups |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ C ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let lookup_idx := + M.copy (| + γ1_0 + |) in + let lookup := + M.copy (| + γ1_1 + |) in + let table := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "usize" + ] + ], + "index", + [] + |), + [ + lookup_values; + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + BinOp.Panic.mul (| + Integer.Usize, + M.read (| + lookup_idx + |), + M.read (| + size + |) + |)); + ("end_", + BinOp.Panic.mul (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.read (| + lookup_idx + |), + Value.Integer + 1 + |), + M.read (| + size + |) + |)) + ] + ] + |) + |) in + let + product_coset := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "coeff_to_extended", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + lookup + |), + "halo2_proofs::plonk::lookup::prover::Committed", + "product_poly" + |) + ] + |) + ] + |) + |) in + let + permuted_input_coset := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "coeff_to_extended", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + lookup + |), + "halo2_proofs::plonk::lookup::prover::Committed", + "permuted_input_poly" + |) + ] + |) + ] + |) + |) in + let + permuted_table_coset := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "coeff_to_extended", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + lookup + |), + "halo2_proofs::plonk::lookup::prover::Committed", + "permuted_table_poly" + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ] + ]; + Ty.path + "usize" + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [], + "deref_mut", + [] + |), + [ values + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + values := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + start := + M.copy (| + γ + |) in + M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ], + "iter_mut", + [] + |), + [ + M.read (| + values + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + i := + M.copy (| + γ1_0 + |) in + let + value := + M.copy (| + γ1_1 + |) in + let + idx := + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.read (| + start + |), + M.read (| + i + |) + |) + |) in + let + r_next := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::evaluation::get_rotation_idx", + [] + |), + [ + M.read (| + idx + |); + Value.Integer + 1; + M.read (| + rot_scale + |); + M.read (| + isize + |) + ] + |) + |) in + let + r_prev := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::evaluation::get_rotation_idx", + [] + |), + [ + M.read (| + idx + |); + Value.Integer + (-1); + M.read (| + rot_scale + |); + M.read (| + isize + |) + ] + |) + |) in + let + a_minus_s := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ + Ty.associated + ], + "sub", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + permuted_input_coset; + M.read (| + idx + |) + ] + |) + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + permuted_table_coset; + M.read (| + idx + |) + ] + |) + |) + ] + |) + |) in + let + _ := + M.write (| + M.read (| + value + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + M.read (| + value + |) + |); + M.read (| + y + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ + Ty.associated + ], + "sub", + [] + |), + [ + M.read (| + one + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + product_coset; + M.read (| + idx + |) + ] + |) + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + l0 + |); + M.read (| + idx + |) + ] + |) + |) + ] + |) + ] + |) + |) in + let + _ := + M.write (| + M.read (| + value + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + M.read (| + value + |) + |); + M.read (| + y + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ + Ty.associated + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + product_coset; + M.read (| + idx + |) + ] + |) + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + product_coset; + M.read (| + idx + |) + ] + |) + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + product_coset; + M.read (| + idx + |) + ] + |) + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + l_last + |); + M.read (| + idx + |) + ] + |) + |) + ] + |) + ] + |) + |) in + let + _ := + M.write (| + M.read (| + value + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + M.read (| + value + |) + |); + M.read (| + y + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ + Ty.associated + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + product_coset; + M.read (| + r_next + |) + ] + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + permuted_input_coset; + M.read (| + idx + |) + ] + |) + |); + M.read (| + beta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + permuted_table_coset; + M.read (| + idx + |) + ] + |) + |); + M.read (| + gamma + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + product_coset; + M.read (| + idx + |) + ] + |) + |); + M.read (| + M.SubPointer.get_array_field (| + M.read (| + table + |), + idx + |) + |) + ] + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + l_active_row + |); + M.read (| + idx + |) + ] + |) + |) + ] + |) + ] + |) + |) in + let + _ := + M.write (| + M.read (| + value + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + M.read (| + value + |) + |); + M.read (| + y + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + a_minus_s + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + l0 + |); + M.read (| + idx + |) + ] + |) + |) + ] + |) + ] + |) + |) in + let + _ := + M.write (| + M.read (| + value + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + M.read (| + value + |) + |); + M.read (| + y + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + a_minus_s + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ + Ty.associated + ], + "sub", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + permuted_input_coset; + M.read (| + idx + |) + ] + |) + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + permuted_input_coset; + M.read (| + r_prev + |) + ] + |) + |) + ] + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + l_active_row + |); + M.read (| + idx + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + |))) + ] + |)) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + values + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_evaluate_h : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "evaluate_h" (evaluate_h C). + End Impl_halo2_proofs_plonk_evaluation_Evaluator_C. + + (* StructTuple + { + name := "ThreadBox"; + ty_params := [ "T" ]; + fields := [ Ty.apply (Ty.path "*mut") [ T ]; Ty.path "usize" ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_T_for_halo2_proofs_plonk_evaluation_ThreadBox_T. + Definition Self (T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::ThreadBox") [ T ]. + + (* Clone *) + Definition clone (T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self T in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructTuple + "halo2_proofs::plonk::evaluation::ThreadBox" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "*mut") [ T ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::ThreadBox", + 0 + |) + ] + |); + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "usize", [], "clone", [] |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::ThreadBox", + 1 + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (T : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self T) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone T)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_T_for_halo2_proofs_plonk_evaluation_ThreadBox_T. + + Module Impl_core_marker_Copy_where_core_marker_Copy_T_for_halo2_proofs_plonk_evaluation_ThreadBox_T. + Definition Self (T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::ThreadBox") [ T ]. + + Axiom Implements : + forall (T : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self T) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_T_for_halo2_proofs_plonk_evaluation_ThreadBox_T. + + Module Impl_core_marker_Send_for_halo2_proofs_plonk_evaluation_ThreadBox_T. + Definition Self (T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::ThreadBox") [ T ]. + + Axiom Implements : + forall (T : Ty.t), + M.IsTraitInstance + "core::marker::Send" + (Self T) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Send_for_halo2_proofs_plonk_evaluation_ThreadBox_T. + + Module Impl_core_marker_Sync_for_halo2_proofs_plonk_evaluation_ThreadBox_T. + Definition Self (T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::ThreadBox") [ T ]. + + Axiom Implements : + forall (T : Ty.t), + M.IsTraitInstance + "core::marker::Sync" + (Self T) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Sync_for_halo2_proofs_plonk_evaluation_ThreadBox_T. + + Module Impl_halo2_proofs_plonk_evaluation_ThreadBox_T. + Definition Self (T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation::ThreadBox") [ T ]. + + (* + fn wrap(data: &mut [T]) -> Self { + Self(data.as_mut_ptr(), data.len()) + } + *) + Definition wrap (T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self T in + match τ, α with + | [], [ data ] => + ltac:(M.monadic + (let data := M.alloc (| data |) in + Value.StructTuple + "halo2_proofs::plonk::evaluation::ThreadBox" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ T ], + "as_mut_ptr", + [] + |), + [ M.read (| data |) ] + |); + M.call_closure (| + M.get_associated_function (| Ty.apply (Ty.path "slice") [ T ], "len", [] |), + [ M.read (| data |) ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_wrap : + forall (T : Ty.t), + M.IsAssociatedFunction (Self T) "wrap" (wrap T). + + (* + fn unwrap(&mut self) -> &mut [T] { + #[allow(unsafe_code)] + unsafe { + slice::from_raw_parts_mut(self.0, self.1) + } + } + *) + Definition unwrap (T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self T in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_function (| "core::slice::raw::from_raw_parts_mut", [ T ] |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::ThreadBox", + 0 + |) + |); + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation::ThreadBox", + 1 + |) + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_unwrap : + forall (T : Ty.t), + M.IsAssociatedFunction (Self T) "unwrap" (unwrap T). + End Impl_halo2_proofs_plonk_evaluation_ThreadBox_T. + + (* + pub fn evaluate( + expression: &Expression, + size: usize, + rot_scale: i32, + fixed: &[Polynomial], + advice: &[Polynomial], + instance: &[Polynomial], + _theta: F, + ) -> Vec { + if let Some(idx) = expression.is_pure_fixed() { + return fixed[idx].to_vec(); + } + + if let Some(idx) = expression.is_pure_advice() { + return advice[idx].to_vec(); + } + + if let Some(idx) = expression.is_pure_instance() { + return instance[idx].to_vec(); + } + + #[cfg(not(feature = "cuda"))] + { + let mut values = vec![F::zero(); size]; + let isize = size as i32; + parallelize(&mut values, |values, start| { + for (i, value) in values.iter_mut().enumerate() { + let idx = start + i; + *value = expression.evaluate( + &|scalar| scalar, + &|_| panic!("virtual selectors are removed during optimization"), + &|_, column_index, rotation| { + fixed[column_index][get_rotation_idx(idx, rotation.0, rot_scale, isize)] + }, + &|_, column_index, rotation| { + advice[column_index][get_rotation_idx(idx, rotation.0, rot_scale, isize)] + }, + &|_, column_index, rotation| { + instance[column_index][get_rotation_idx(idx, rotation.0, rot_scale, isize)] + }, + &|a| -a, + &|a, b| a + &b, + &|a, b| { + let a = a(); + + if a == F::zero() { + a + } else { + a * b() + } + }, + &|a, scalar| a * scalar, + ); + } + }); + return values; + } + + #[cfg(feature = "cuda")] + { + return evaluate_gpu( + &[expression.clone()], + size, + rot_scale, + fixed, + advice, + instance, + _theta, + ); + } + } + *) + Definition evaluate (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F; B ], [ expression; size; rot_scale; fixed; advice; instance; _theta ] => + ltac:(M.monadic + (let expression := M.alloc (| expression |) in + let size := M.alloc (| size |) in + let rot_scale := M.alloc (| rot_scale |) in + let fixed := M.alloc (| fixed |) in + let advice := M.alloc (| advice |) in + let instance := M.alloc (| instance |) in + let _theta := M.alloc (| _theta |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "is_pure_fixed", + [] + |), + [ M.read (| expression |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let idx := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "to_vec", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ F; B ], + [], + "deref", + [] + |), + [ M.SubPointer.get_array_field (| M.read (| fixed |), idx |) + ] + |) + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "is_pure_advice", + [] + |), + [ M.read (| expression |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let idx := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "to_vec", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ F; B ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| advice |), + idx + |) + ] + |) + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + "is_pure_instance", + [] + |), + [ M.read (| expression |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let idx := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "to_vec", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ F; B ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| instance |), + idx + |) + ] + |) + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let values := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ F ] |), + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "zero", [] |), + [] + |); + M.read (| size |) + ] + |) + |) in + let isize := M.alloc (| M.rust_cast (M.read (| size |)) |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + F; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "slice") [ F ] ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ values ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let values := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let start := M.copy (| γ |) in + M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ F ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ F ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ F ], + "iter_mut", + [] + |), + [ M.read (| values |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ F ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let i := + M.copy (| + γ1_0 + |) in + let value := + M.copy (| + γ1_1 + |) in + let idx := + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.read (| + start + |), + M.read (| i |) + |) + |) in + let _ := + M.write (| + M.read (| + value + |), + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + "evaluate", + [ + F; + Ty.function + [ + Ty.tuple + [ F + ] + ] + F; + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ] + ] + F; + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + F; + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + F; + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + F; + Ty.function + [ + Ty.tuple + [ F + ] + ] + F; + Ty.function + [ + Ty.tuple + [ + F; + F + ] + ] + F; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ] + ] + ] + ] + F; + Ty.function + [ + Ty.tuple + [ + F; + F + ] + ] + F + ] + |), + [ + M.read (| + expression + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + scalar := + M.copy (| + γ + |) in + M.read (| + scalar + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.never_to_any (| + M.call_closure (| + M.get_function (| + "std::panicking::begin_panic", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + Value.String + "virtual selectors are removed during optimization" + |) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1; + α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + column_index := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (let + rotation := + M.copy (| + γ + |) in + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + F; + B + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| + fixed + |), + column_index + |); + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::evaluation::get_rotation_idx", + [] + |), + [ + M.read (| + idx + |); + M.read (| + M.SubPointer.get_struct_tuple_field (| + rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + |); + M.read (| + rot_scale + |); + M.read (| + isize + |) + ] + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1; + α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + column_index := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (let + rotation := + M.copy (| + γ + |) in + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + F; + B + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| + advice + |), + column_index + |); + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::evaluation::get_rotation_idx", + [] + |), + [ + M.read (| + idx + |); + M.read (| + M.SubPointer.get_struct_tuple_field (| + rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + |); + M.read (| + rot_scale + |); + M.read (| + isize + |) + ] + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1; + α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + column_index := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (let + rotation := + M.copy (| + γ + |) in + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + F; + B + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| + instance + |), + column_index + |); + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::evaluation::get_rotation_idx", + [] + |), + [ + M.read (| + idx + |); + M.read (| + M.SubPointer.get_struct_tuple_field (| + rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + |); + M.read (| + rot_scale + |); + M.read (| + isize + |) + ] + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Neg", + F, + [], + "neg", + [] + |), + [ + M.read (| + a + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + b := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + F, + [ + Ty.apply + (Ty.path + "&") + [ + F + ] + ], + "add", + [] + |), + [ + M.read (| + a + |); + b + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + b := + M.copy (| + γ + |) in + M.read (| + let + a := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ], + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.read (| + a + |); + Value.Tuple + [] + ] + |) + |) in + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + F, + [ + F + ], + "eq", + [] + |), + [ + a; + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + |) + ] + |) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + a)); + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ + F + ], + "mul", + [] + |), + [ + M.read (| + a + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ], + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.read (| + b + |); + Value.Tuple + [] + ] + |) + ] + |) + |))) + ] + |) + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + scalar := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ + F + ], + "mul", + [] + |), + [ + M.read (| + a + |); + M.read (| + scalar + |) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.return_ (| M.read (| values |) |) + |) + |) + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + pub fn evaluate_with_theta( + expressions: &[Expression], + size: usize, + rot_scale: i32, + fixed: &[Polynomial], + advice: &[Polynomial], + instance: &[Polynomial], + theta: F, + ) -> Vec { + if expressions.len() == 1 { + evaluate( + &expressions[0], + size, + rot_scale, + fixed, + advice, + instance, + theta, + ) + } else { + #[cfg(not(feature = "cuda"))] + { + let mut values = vec![F::zero(); size]; + let isize = size as i32; + parallelize(&mut values, |values, start| { + for (i, value) in values.iter_mut().enumerate() { + let idx = start + i; + for expression in expressions { + *value = *value * theta; + *value += expression.evaluate( + &|scalar| scalar, + &|_| panic!("virtual selectors are removed during optimization"), + &|_, column_index, rotation| { + fixed[column_index] + [get_rotation_idx(idx, rotation.0, rot_scale, isize)] + }, + &|_, column_index, rotation| { + advice[column_index] + [get_rotation_idx(idx, rotation.0, rot_scale, isize)] + }, + &|_, column_index, rotation| { + instance[column_index] + [get_rotation_idx(idx, rotation.0, rot_scale, isize)] + }, + &|a| -a, + &|a, b| a + &b, + &|a, b| { + let a = a(); + + if a == F::zero() { + a + } else { + a * b() + } + }, + &|a, scalar| a * scalar, + ); + } + } + }); + return values; + } + + #[cfg(feature = "cuda")] + { + return evaluate_gpu(expressions, size, rot_scale, fixed, advice, instance, theta); + } + } + } + *) + Definition evaluate_with_theta (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F; B ], [ expressions; size; rot_scale; fixed; advice; instance; theta ] => + ltac:(M.monadic + (let expressions := M.alloc (| expressions |) in + let size := M.alloc (| size |) in + let rot_scale := M.alloc (| rot_scale |) in + let fixed := M.alloc (| fixed |) in + let advice := M.alloc (| advice |) in + let instance := M.alloc (| instance |) in + let theta := M.alloc (| theta |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "len", + [] + |), + [ M.read (| expressions |) ] + |)) + (Value.Integer 1) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::evaluation::evaluate", + [ F; B ] + |), + [ + M.SubPointer.get_array_field (| + M.read (| expressions |), + M.alloc (| Value.Integer 0 |) + |); + M.read (| size |); + M.read (| rot_scale |); + M.read (| fixed |); + M.read (| advice |); + M.read (| instance |); + M.read (| theta |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + let values := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ F ] |), + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "zero", [] |), + [] + |); + M.read (| size |) + ] + |) + |) in + let isize := M.alloc (| M.rust_cast (M.read (| size |)) |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + F; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "slice") [ F ] ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ values ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let values := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let start := M.copy (| γ |) in + M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ F ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ F ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ F ], + "iter_mut", + [] + |), + [ + M.read (| + values + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := + M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ F ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let i := + M.copy (| + γ1_0 + |) in + let value := + M.copy (| + γ1_1 + |) in + let idx := + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.read (| + start + |), + M.read (| + i + |) + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.read (| + expressions + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + expression := + M.copy (| + γ0_0 + |) in + let + _ := + M.write (| + M.read (| + value + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ + F + ], + "mul", + [] + |), + [ + M.read (| + M.read (| + value + |) + |); + M.read (| + theta + |) + ] + |) + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::AddAssign", + F, + [ + F + ], + "add_assign", + [] + |), + [ + M.read (| + value + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + "evaluate", + [ + F; + Ty.function + [ + Ty.tuple + [ + F + ] + ] + F; + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ] + ] + F; + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + F; + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + F; + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + F; + Ty.function + [ + Ty.tuple + [ + F + ] + ] + F; + Ty.function + [ + Ty.tuple + [ + F; + F + ] + ] + F; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ] + ] + ] + ] + F; + Ty.function + [ + Ty.tuple + [ + F; + F + ] + ] + F + ] + |), + [ + M.read (| + expression + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + scalar := + M.copy (| + γ + |) in + M.read (| + scalar + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.never_to_any (| + M.call_closure (| + M.get_function (| + "std::panicking::begin_panic", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + Value.String + "virtual selectors are removed during optimization" + |) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1; + α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + column_index := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (let + rotation := + M.copy (| + γ + |) in + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + F; + B + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| + fixed + |), + column_index + |); + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::evaluation::get_rotation_idx", + [] + |), + [ + M.read (| + idx + |); + M.read (| + M.SubPointer.get_struct_tuple_field (| + rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + |); + M.read (| + rot_scale + |); + M.read (| + isize + |) + ] + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1; + α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + column_index := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (let + rotation := + M.copy (| + γ + |) in + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + F; + B + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| + advice + |), + column_index + |); + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::evaluation::get_rotation_idx", + [] + |), + [ + M.read (| + idx + |); + M.read (| + M.SubPointer.get_struct_tuple_field (| + rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + |); + M.read (| + rot_scale + |); + M.read (| + isize + |) + ] + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1; + α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + column_index := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (let + rotation := + M.copy (| + γ + |) in + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + F; + B + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| + instance + |), + column_index + |); + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::evaluation::get_rotation_idx", + [] + |), + [ + M.read (| + idx + |); + M.read (| + M.SubPointer.get_struct_tuple_field (| + rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + |); + M.read (| + rot_scale + |); + M.read (| + isize + |) + ] + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Neg", + F, + [], + "neg", + [] + |), + [ + M.read (| + a + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + b := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + F, + [ + Ty.apply + (Ty.path + "&") + [ + F + ] + ], + "add", + [] + |), + [ + M.read (| + a + |); + b + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + b := + M.copy (| + γ + |) in + M.read (| + let + a := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ], + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.read (| + a + |); + Value.Tuple + [] + ] + |) + |) in + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + F, + [ + F + ], + "eq", + [] + |), + [ + a; + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + |) + ] + |) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + a)); + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ + F + ], + "mul", + [] + |), + [ + M.read (| + a + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ], + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.read (| + b + |); + Value.Tuple + [] + ] + |) + ] + |) + |))) + ] + |) + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + scalar := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ + F + ], + "mul", + [] + |), + [ + M.read (| + a + |); + M.read (| + scalar + |) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + |))) + ] + |)) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.return_ (| M.read (| values |) |) + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + End evaluation. +End plonk. diff --git a/CoqOfRust/halo2_proofs/plonk/evaluation_gpu.v b/CoqOfRust/halo2_proofs/plonk/evaluation_gpu.v new file mode 100644 index 000000000..a27a0d194 --- /dev/null +++ b/CoqOfRust/halo2_proofs/plonk/evaluation_gpu.v @@ -0,0 +1,9321 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module plonk. + Module evaluation_gpu. + (* + Enum ProveExpressionUnit + { + ty_params := []; + variants := + [ + { + name := "Fixed"; + item := + StructRecord + [ + ("column_index", Ty.path "usize"); + ("rotation", Ty.path "halo2_proofs::poly::Rotation") + ]; + discriminant := None; + }; + { + name := "Advice"; + item := + StructRecord + [ + ("column_index", Ty.path "usize"); + ("rotation", Ty.path "halo2_proofs::poly::Rotation") + ]; + discriminant := None; + }; + { + name := "Instance"; + item := + StructRecord + [ + ("column_index", Ty.path "usize"); + ("rotation", Ty.path "halo2_proofs::poly::Rotation") + ]; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_clone_Clone_for_halo2_proofs_plonk_evaluation_gpu_ProveExpressionUnit. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Fixed", + "column_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Fixed", + "rotation" + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Fixed" + [ + ("column_index", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "usize", + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |)); + ("rotation", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::poly::Rotation", + [], + "clone", + [] + |), + [ M.read (| __self_1 |) ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Advice", + "column_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Advice", + "rotation" + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Advice" + [ + ("column_index", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "usize", + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |)); + ("rotation", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::poly::Rotation", + [], + "clone", + [] + |), + [ M.read (| __self_1 |) ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Instance", + "column_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Instance", + "rotation" + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Instance" + [ + ("column_index", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "usize", + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |)); + ("rotation", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::poly::Rotation", + [], + "clone", + [] + |), + [ M.read (| __self_1 |) ] + |)) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_plonk_evaluation_gpu_ProveExpressionUnit. + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_evaluation_gpu_ProveExpressionUnit. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Fixed", + "column_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Fixed", + "rotation" + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Fixed" |); + M.read (| Value.String "column_index" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + M.read (| Value.String "rotation" |); + (* Unsize *) M.pointer_coercion __self_1 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Advice", + "column_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Advice", + "rotation" + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Advice" |); + M.read (| Value.String "column_index" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + M.read (| Value.String "rotation" |); + (* Unsize *) M.pointer_coercion __self_1 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Instance", + "column_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Instance", + "rotation" + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Instance" |); + M.read (| Value.String "column_index" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + M.read (| Value.String "rotation" |); + (* Unsize *) M.pointer_coercion __self_1 + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_evaluation_gpu_ProveExpressionUnit. + + Module Impl_core_marker_StructuralEq_for_halo2_proofs_plonk_evaluation_gpu_ProveExpressionUnit. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralEq_for_halo2_proofs_plonk_evaluation_gpu_ProveExpressionUnit. + + Module Impl_core_cmp_Eq_for_halo2_proofs_plonk_evaluation_gpu_ProveExpressionUnit. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit". + + (* Eq *) + Definition assert_receiver_is_total_eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Eq" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("assert_receiver_is_total_eq", InstanceField.Method assert_receiver_is_total_eq) ]. + End Impl_core_cmp_Eq_for_halo2_proofs_plonk_evaluation_gpu_ProveExpressionUnit. + + Module Impl_core_cmp_Ord_for_halo2_proofs_plonk_evaluation_gpu_ProveExpressionUnit. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit". + + (* Ord *) + Definition cmp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" ] + |), + [ M.read (| other |) ] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::cmp::Ord", Ty.path "isize", [], "cmp", [] |), + [ __self_tag; __arg1_tag ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| other |) ] |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Fixed", + "column_index" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Fixed", + "rotation" + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Fixed", + "column_index" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Fixed", + "rotation" + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path "usize", + [], + "cmp", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path "halo2_proofs::poly::Rotation", + [], + "cmp", + [] + |), + [ M.read (| __self_1 |); M.read (| __arg1_1 |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let cmp := M.copy (| γ |) in + cmp)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Advice", + "column_index" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Advice", + "rotation" + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Advice", + "column_index" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Advice", + "rotation" + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path "usize", + [], + "cmp", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path "halo2_proofs::poly::Rotation", + [], + "cmp", + [] + |), + [ M.read (| __self_1 |); M.read (| __arg1_1 |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let cmp := M.copy (| γ |) in + cmp)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Instance", + "column_index" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Instance", + "rotation" + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Instance", + "column_index" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Instance", + "rotation" + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path "usize", + [], + "cmp", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path "halo2_proofs::poly::Rotation", + [], + "cmp", + [] + |), + [ M.read (| __self_1 |); M.read (| __arg1_1 |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let cmp := M.copy (| γ |) in + cmp)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::intrinsics::unreachable", [] |), + [] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let cmp := M.copy (| γ |) in + cmp)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Ord" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("cmp", InstanceField.Method cmp) ]. + End Impl_core_cmp_Ord_for_halo2_proofs_plonk_evaluation_gpu_ProveExpressionUnit. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_plonk_evaluation_gpu_ProveExpressionUnit. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_plonk_evaluation_gpu_ProveExpressionUnit. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_plonk_evaluation_gpu_ProveExpressionUnit. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" ] + |), + [ M.read (| other |) ] + |) + |) in + M.alloc (| + LogicalOp.and (| + BinOp.Pure.eq (M.read (| __self_tag |)) (M.read (| __arg1_tag |)), + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| other |) ] |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Fixed", + "column_index" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Fixed", + "rotation" + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Fixed", + "column_index" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Fixed", + "rotation" + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.alloc (| + LogicalOp.and (| + BinOp.Pure.eq + (M.read (| M.read (| __self_0 |) |)) + (M.read (| M.read (| __arg1_0 |) |)), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::poly::Rotation", + [ Ty.path "halo2_proofs::poly::Rotation" ], + "eq", + [] + |), + [ M.read (| __self_1 |); M.read (| __arg1_1 |) ] + |))) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Advice", + "column_index" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Advice", + "rotation" + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Advice", + "column_index" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Advice", + "rotation" + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.alloc (| + LogicalOp.and (| + BinOp.Pure.eq + (M.read (| M.read (| __self_0 |) |)) + (M.read (| M.read (| __arg1_0 |) |)), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::poly::Rotation", + [ Ty.path "halo2_proofs::poly::Rotation" ], + "eq", + [] + |), + [ M.read (| __self_1 |); M.read (| __arg1_1 |) ] + |))) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Instance", + "column_index" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Instance", + "rotation" + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Instance", + "column_index" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Instance", + "rotation" + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.alloc (| + LogicalOp.and (| + BinOp.Pure.eq + (M.read (| M.read (| __self_0 |) |)) + (M.read (| M.read (| __arg1_0 |) |)), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "halo2_proofs::poly::Rotation", + [ Ty.path "halo2_proofs::poly::Rotation" ], + "eq", + [] + |), + [ M.read (| __self_1 |); M.read (| __arg1_1 |) ] + |))) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::intrinsics::unreachable", [] |), + [] + |) + |) + |))) + ] + |) + |))) + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_plonk_evaluation_gpu_ProveExpressionUnit. + + Module Impl_core_cmp_PartialOrd_for_halo2_proofs_plonk_evaluation_gpu_ProveExpressionUnit. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit". + + (* PartialOrd *) + Definition partial_cmp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" ] + |), + [ M.read (| other |) ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| other |) ] |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Fixed", + "column_index" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Fixed", + "rotation" + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Fixed", + "column_index" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Fixed", + "rotation" + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "usize", + [ Ty.path "usize" ], + "partial_cmp", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "halo2_proofs::poly::Rotation", + [ Ty.path "halo2_proofs::poly::Rotation" ], + "partial_cmp", + [] + |), + [ M.read (| __self_1 |); M.read (| __arg1_1 |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let cmp := M.copy (| γ |) in + cmp)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Advice", + "column_index" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Advice", + "rotation" + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Advice", + "column_index" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Advice", + "rotation" + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "usize", + [ Ty.path "usize" ], + "partial_cmp", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "halo2_proofs::poly::Rotation", + [ Ty.path "halo2_proofs::poly::Rotation" ], + "partial_cmp", + [] + |), + [ M.read (| __self_1 |); M.read (| __arg1_1 |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let cmp := M.copy (| γ |) in + cmp)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Instance", + "column_index" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Instance", + "rotation" + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let __self_1 := M.alloc (| γ2_1 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Instance", + "column_index" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_1, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Instance", + "rotation" + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + let __arg1_1 := M.alloc (| γ2_1 |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "usize", + [ Ty.path "usize" ], + "partial_cmp", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "halo2_proofs::poly::Rotation", + [ Ty.path "halo2_proofs::poly::Rotation" ], + "partial_cmp", + [] + |), + [ M.read (| __self_1 |); M.read (| __arg1_1 |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let cmp := M.copy (| γ |) in + cmp)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "isize", + [ Ty.path "isize" ], + "partial_cmp", + [] + |), + [ __self_tag; __arg1_tag ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialOrd" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("partial_cmp", InstanceField.Method partial_cmp) ]. + End Impl_core_cmp_PartialOrd_for_halo2_proofs_plonk_evaluation_gpu_ProveExpressionUnit. + + Module Impl_halo2_proofs_plonk_evaluation_gpu_ProveExpressionUnit. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit". + + (* + pub fn get_group(&self) -> usize { + match self { + ProveExpressionUnit::Fixed { column_index, .. } => column_index << 2, + ProveExpressionUnit::Advice { column_index, .. } => (column_index << 2) + 1, + ProveExpressionUnit::Instance { column_index, .. } => (column_index << 2) + 2, + } + } + *) + Definition get_group (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Fixed", + "column_index" + |) in + let column_index := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.apply (Ty.path "&") [ Ty.path "usize" ], + [ Ty.path "i32" ], + "shl", + [] + |), + [ M.read (| column_index |); Value.Integer 2 ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Advice", + "column_index" + |) in + let column_index := M.alloc (| γ1_0 |) in + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.apply (Ty.path "&") [ Ty.path "usize" ], + [ Ty.path "i32" ], + "shl", + [] + |), + [ M.read (| column_index |); Value.Integer 2 ] + |), + Value.Integer 1 + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Instance", + "column_index" + |) in + let column_index := M.alloc (| γ1_0 |) in + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.apply (Ty.path "&") [ Ty.path "usize" ], + [ Ty.path "i32" ], + "shl", + [] + |), + [ M.read (| column_index |); Value.Integer 2 ] + |), + Value.Integer 2 + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get_group : M.IsAssociatedFunction Self "get_group" get_group. + End Impl_halo2_proofs_plonk_evaluation_gpu_ProveExpressionUnit. + + (* + Enum Bop + { + ty_params := []; + variants := + [ + { + name := "Sum"; + item := StructTuple []; + discriminant := None; + }; + { + name := "Product"; + item := StructTuple []; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_clone_Clone_for_halo2_proofs_plonk_evaluation_gpu_Bop. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation_gpu::Bop". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + Value.StructTuple "halo2_proofs::plonk::evaluation_gpu::Bop::Sum" [] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + Value.StructTuple "halo2_proofs::plonk::evaluation_gpu::Bop::Product" [] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_plonk_evaluation_gpu_Bop. + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_evaluation_gpu_Bop. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation_gpu::Bop". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ + M.read (| f |); + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| M.read (| Value.String "Sum" |) |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| M.read (| Value.String "Product" |) |))) + ] + |) + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_evaluation_gpu_Bop. + + (* + Enum ProveExpression + { + ty_params := [ "F" ]; + variants := + [ + { + name := "Unit"; + item := + StructTuple [ Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" ]; + discriminant := None; + }; + { + name := "Op"; + item := + StructTuple + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::evaluation_gpu::Bop" + ]; + discriminant := None; + }; + { + name := "Y"; + item := + StructTuple + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ]; + discriminant := None; + }; + { + name := "Scale"; + item := + StructTuple + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ]; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_for_halo2_proofs_plonk_evaluation_gpu_ProveExpression_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Unit", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Unit" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit", + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op", + 1 + |) in + let γ1_2 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op", + 2 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + let __self_2 := M.alloc (| γ1_2 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ M.read (| __self_1 |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::evaluation_gpu::Bop", + [], + "clone", + [] + |), + [ M.read (| __self_2 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Y", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Y" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Scale", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Scale", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Scale" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ M.read (| __self_1 |) ] + |) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_for_halo2_proofs_plonk_evaluation_gpu_ProveExpression_F. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_for_halo2_proofs_plonk_evaluation_gpu_ProveExpression_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Unit", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Unit" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op", + 1 + |) in + let γ1_2 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op", + 2 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + let __self_2 := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Op" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + (* Unsize *) M.pointer_coercion (M.read (| __self_1 |)); + (* Unsize *) M.pointer_coercion __self_2 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Y", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Y" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Scale", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Scale", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Scale" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + (* Unsize *) M.pointer_coercion __self_1 + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_for_halo2_proofs_plonk_evaluation_gpu_ProveExpression_F. + + (* + Enum LookupProveExpression + { + ty_params := [ "F" ]; + variants := + [ + { + name := "Expression"; + item := + StructTuple + [ Ty.apply (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") [ F ] ]; + discriminant := None; + }; + { + name := "LcTheta"; + item := + StructTuple + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ]; + discriminant := None; + }; + { + name := "LcBeta"; + item := + StructTuple + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ]; + discriminant := None; + }; + { + name := "AddGamma"; + item := + StructTuple + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ]; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_for_halo2_proofs_plonk_evaluation_gpu_LookupProveExpression_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression::Expression", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression::Expression" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression::LcTheta", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression::LcTheta", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression::LcTheta" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ M.read (| __self_1 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression::LcBeta", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression::LcBeta", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression::LcBeta" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ M.read (| __self_1 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression::AddGamma", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression::AddGamma" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_for_halo2_proofs_plonk_evaluation_gpu_LookupProveExpression_F. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_for_halo2_proofs_plonk_evaluation_gpu_LookupProveExpression_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression::Expression", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Expression" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression::LcTheta", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression::LcTheta", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "LcTheta" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + (* Unsize *) M.pointer_coercion __self_1 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression::LcBeta", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression::LcBeta", + 1 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "LcBeta" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + (* Unsize *) M.pointer_coercion __self_1 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::LookupProveExpression::AddGamma", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AddGamma" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_for_halo2_proofs_plonk_evaluation_gpu_LookupProveExpression_F. + + (* StructRecord + { + name := "ComplexityProfiler"; + ty_params := []; + fields := + [ + ("mul", Ty.path "usize"); + ("sum", Ty.path "usize"); + ("scale", Ty.path "usize"); + ("unit_", Ty.path "usize"); + ("y", Ty.path "usize"); + ("ref_cnt", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ Ty.path "usize"; Ty.path "u32"; Ty.path "std::hash::random::RandomState" ]) + ]; + } *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_evaluation_gpu_ComplexityProfiler. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let names := + M.alloc (| + M.alloc (| + Value.Array + [ + M.read (| Value.String "mul" |); + M.read (| Value.String "sum" |); + M.read (| Value.String "scale" |); + M.read (| Value.String "unit" |); + M.read (| Value.String "y" |); + M.read (| Value.String "ref_cnt" |) + ] + |) + |) in + let values := + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "mul" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "sum" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "scale" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "unit" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "y" + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "ref_cnt" + |) + |)) + ] + |)) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_fields_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "ComplexityProfiler" |); + (* Unsize *) M.pointer_coercion (M.read (| names |)); + M.read (| values |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_evaluation_gpu_ComplexityProfiler. + + Module Impl_halo2_proofs_plonk_evaluation_gpu_ProveExpression_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") [ F ]. + + (* + pub(crate) fn new() -> Self { + ProveExpression::Y(BTreeMap::from_iter(vec![(0, F::zero())].into_iter())) + } + *) + Definition new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [] => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Y" + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::FromIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ], + [ Ty.tuple [ Ty.path "u32"; F ] ], + "from_iter", + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ Ty.tuple [ Ty.path "u32"; F ]; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.tuple [ Ty.path "u32"; F ]; Ty.path "alloc::alloc::Global" ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.tuple [ Ty.path "u32"; F ] ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.tuple [ Ty.path "u32"; F ] ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + Value.Integer 0; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + ] + |) + ] + |) + |)) + ] + |) + ] + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "new" (new F). + + (* + pub fn from_expr(e: &Expression) -> Self { + match e { + Expression::Constant(x) => { + ProveExpression::Y(BTreeMap::from_iter(vec![(0, *x)].into_iter())) + } + Expression::Selector(_) => unreachable!(), + Expression::Fixed { + column_index, + rotation, + .. + } => Self::Unit(ProveExpressionUnit::Fixed { + column_index: *column_index, + rotation: *rotation, + }), + Expression::Advice { + column_index, + rotation, + .. + } => Self::Unit(ProveExpressionUnit::Advice { + column_index: *column_index, + rotation: *rotation, + }), + Expression::Instance { + column_index, + rotation, + .. + } => Self::Unit(ProveExpressionUnit::Instance { + column_index: *column_index, + rotation: *rotation, + }), + Expression::Negated(e) => ProveExpression::Op( + Box::new(Self::from_expr(e)), + Box::new(ProveExpression::Y(BTreeMap::from_iter( + vec![(0, -F::one())].into_iter(), + ))), + Bop::Product, + ), + Expression::Sum(l, r) => ProveExpression::Op( + Box::new(Self::from_expr(l)), + Box::new(Self::from_expr(r)), + Bop::Sum, + ), + Expression::Product(l, r) => ProveExpression::Op( + Box::new(Self::from_expr(l)), + Box::new(Self::from_expr(r)), + Bop::Product, + ), + Expression::Scaled(l, r) => ProveExpression::Op( + Box::new(Self::from_expr(l)), + Box::new(ProveExpression::Y(BTreeMap::from_iter( + vec![(0, *r)].into_iter(), + ))), + Bop::Product, + ), + } + } + *) + Definition from_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ e ] => + ltac:(M.monadic + (let e := M.alloc (| e |) in + M.read (| + M.match_operator (| + e, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Constant", + 0 + |) in + let x := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Y" + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::FromIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ], + [ Ty.tuple [ Ty.path "u32"; F ] ], + "from_iter", + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ Ty.tuple [ Ty.path "u32"; F ]; Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.tuple [ Ty.path "u32"; F ] ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.tuple [ Ty.path "u32"; F ] ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + Value.Integer 0; + M.read (| M.read (| x |) |) + ] + ] + |) + ] + |) + |)) + ] + |) + ] + |) + ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Selector", + 0 + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "internal error: entered unreachable code" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "column_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Fixed", + "rotation" + |) in + let column_index := M.alloc (| γ1_0 |) in + let rotation := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Unit" + [ + Value.StructRecord + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Fixed" + [ + ("column_index", M.read (| M.read (| column_index |) |)); + ("rotation", M.read (| M.read (| rotation |) |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "column_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Advice", + "rotation" + |) in + let column_index := M.alloc (| γ1_0 |) in + let rotation := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Unit" + [ + Value.StructRecord + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Advice" + [ + ("column_index", M.read (| M.read (| column_index |) |)); + ("rotation", M.read (| M.read (| rotation |) |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "column_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Instance", + "rotation" + |) in + let column_index := M.alloc (| γ1_0 |) in + let rotation := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Unit" + [ + Value.StructRecord + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit::Instance" + [ + ("column_index", M.read (| M.read (| column_index |) |)); + ("rotation", M.read (| M.read (| rotation |) |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Negated", + 0 + |) in + let e := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "from_expr", + [] + |), + [ M.read (| M.read (| e |) |) ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Y" + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::FromIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ], + [ Ty.tuple [ Ty.path "u32"; F ] ], + "from_iter", + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple [ Ty.path "u32"; F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.tuple [ Ty.path "u32"; F ] ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.tuple [ Ty.path "u32"; F ] ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + Value.Integer 0; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Neg", + F, + [], + "neg", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + ] + |) + ] + |) + |)) + ] + |) + ] + |) + ] + |) + ] + ] + |); + Value.StructTuple "halo2_proofs::plonk::evaluation_gpu::Bop::Product" [] + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Sum", + 1 + |) in + let l := M.alloc (| γ1_0 |) in + let r := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "from_expr", + [] + |), + [ M.read (| M.read (| l |) |) ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "from_expr", + [] + |), + [ M.read (| M.read (| r |) |) ] + |) + ] + |); + Value.StructTuple "halo2_proofs::plonk::evaluation_gpu::Bop::Sum" [] + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Product", + 1 + |) in + let l := M.alloc (| γ1_0 |) in + let r := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "from_expr", + [] + |), + [ M.read (| M.read (| l |) |) ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "from_expr", + [] + |), + [ M.read (| M.read (| r |) |) ] + |) + ] + |); + Value.StructTuple "halo2_proofs::plonk::evaluation_gpu::Bop::Product" [] + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::circuit::Expression::Scaled", + 1 + |) in + let l := M.alloc (| γ1_0 |) in + let r := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "from_expr", + [] + |), + [ M.read (| M.read (| l |) |) ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Y" + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::FromIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ], + [ Ty.tuple [ Ty.path "u32"; F ] ], + "from_iter", + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple [ Ty.path "u32"; F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.tuple [ Ty.path "u32"; F ] ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.tuple [ Ty.path "u32"; F ] ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + Value.Integer 0; + M.read (| M.read (| r |) |) + ] + ] + |) + ] + |) + |)) + ] + |) + ] + |) + ] + |) + ] + ] + |); + Value.StructTuple "halo2_proofs::plonk::evaluation_gpu::Bop::Product" [] + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_from_expr : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "from_expr" (from_expr F). + + (* + pub(crate) fn add_gate(self, e: &Expression) -> Self { + Self::Op( + Box::new(Self::Op( + Box::new(self), + Box::new(ProveExpression::Y(BTreeMap::from_iter( + vec![(1, F::one())].into_iter(), + ))), + Bop::Product, + )), + Box::new(Self::from_expr(e)), + Bop::Sum, + ) + } + *) + Definition add_gate (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; e ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let e := M.alloc (| e |) in + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| self |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Y" + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::FromIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ], + [ Ty.tuple [ Ty.path "u32"; F ] ], + "from_iter", + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple [ Ty.path "u32"; F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.tuple [ Ty.path "u32"; F ] ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.tuple [ Ty.path "u32"; F ] ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + Value.Integer 1; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + ] + |) + ] + |) + |)) + ] + |) + ] + |) + ] + |) + ] + ] + |); + Value.StructTuple "halo2_proofs::plonk::evaluation_gpu::Bop::Product" [] + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "from_expr", + [] + |), + [ M.read (| e |) ] + |) + ] + |); + Value.StructTuple "halo2_proofs::plonk::evaluation_gpu::Bop::Sum" [] + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_add_gate : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "add_gate" (add_gate F). + + (* + fn reconstruct_coeff(coeff: BTreeMap) -> Self { + ProveExpression::Y(coeff) + } + *) + Definition reconstruct_coeff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ coeff ] => + ltac:(M.monadic + (let coeff := M.alloc (| coeff |) in + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Y" + [ M.read (| coeff |) ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_reconstruct_coeff : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "reconstruct_coeff" (reconstruct_coeff F). + + (* + fn reconstruct_unit(u: ProveExpressionUnit, c: u32) -> Self { + if c >= 3 { + println!("find large c {}", c); + } + + if c == 1 { + Self::Unit(u) + } else { + Self::Op( + Box::new(Self::reconstruct_unit(u.clone(), c - 1)), + Box::new(Self::Unit(u)), + Bop::Product, + ) + } + } + *) + Definition reconstruct_unit (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ u; c ] => + ltac:(M.monadic + (let u := M.alloc (| u |) in + let c := M.alloc (| c |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use (M.alloc (| BinOp.Pure.ge (M.read (| c |)) (Value.Integer 3) |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| "std::io::stdio::_print", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "find large c " |); + M.read (| Value.String " +" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "u32" ] + |), + [ c ] + |) + ] + |)) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use (M.alloc (| BinOp.Pure.eq (M.read (| c |)) (Value.Integer 1) |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Unit" + [ M.read (| u |) ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "reconstruct_unit", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit", + [], + "clone", + [] + |), + [ u ] + |); + BinOp.Panic.sub (| + Integer.U32, + M.read (| c |), + Value.Integer 1 + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Unit" + [ M.read (| u |) ] + ] + |); + Value.StructTuple "halo2_proofs::plonk::evaluation_gpu::Bop::Product" [] + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_reconstruct_unit : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "reconstruct_unit" (reconstruct_unit F). + + (* + fn reconstruct_units(mut us: BTreeMap) -> Self { + let u = us.pop_first().unwrap(); + + let mut l = Self::reconstruct_unit(u.0, u.1); + + for (u, c) in us { + for _ in 0..c { + l = Self::Op(Box::new(l), Box::new(Self::Unit(u.clone())), Bop::Product); + } + } + + l + } + *) + Definition reconstruct_units (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ us ] => + ltac:(M.monadic + (let us := M.alloc (| us |) in + M.read (| + let u := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ], + "pop_first", + [] + |), + [ us ] + |) + ] + |) + |) in + let l := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "reconstruct_unit", + [] + |), + [ + M.read (| M.SubPointer.get_tuple_field (| u, 0 |) |); + M.read (| M.SubPointer.get_tuple_field (| u, 1 |) |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| us |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::IntoIter") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let u := M.copy (| γ1_0 |) in + let c := M.copy (| γ1_1 |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", M.read (| c |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let _ := + M.write (| + l, + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| l |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Unit" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit", + [], + "clone", + [] + |), + [ u ] + |) + ] + ] + |); + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::Bop::Product" + [] + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + l + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_reconstruct_units : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "reconstruct_units" (reconstruct_units F). + + (* + fn reconstruct_units_coeff( + us: BTreeMap, + coeff: BTreeMap, + ) -> Self { + let res = if us.len() == 0 { + Self::reconstruct_coeff(coeff) + } else { + Self::Scale(Box::new(Self::reconstruct_units(us)), coeff) + }; + + assert!(res.get_r_deep() <= 1); + res + } + *) + Definition reconstruct_units_coeff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ us; coeff ] => + ltac:(M.monadic + (let us := M.alloc (| us |) in + let coeff := M.alloc (| coeff |) in + M.read (| + let res := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ us ] + |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "reconstruct_coeff", + [] + |), + [ M.read (| coeff |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Scale" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "reconstruct_units", + [] + |), + [ M.read (| us |) ] + |) + ] + |); + M.read (| coeff |) + ] + |))) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.le + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "get_r_deep", + [] + |), + [ res ] + |)) + (Value.Integer 1)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "assertion failed: res.get_r_deep() <= 1" |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + res + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_reconstruct_units_coeff : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "reconstruct_units_coeff" (reconstruct_units_coeff F). + + (* + fn reconstruct_tree( + mut tree: Vec<(BTreeMap, BTreeMap)>, + r_deep_limit: u32, + ) -> Self { + if tree.len() == 1 { + let u = tree.pop().unwrap(); + return Self::reconstruct_units_coeff(u.0, u.1); + } + + if r_deep_limit > 2 { + // find max + let mut map = BTreeMap::new(); + + for (us, _) in tree.iter() { + for (u, _) in us { + if let Some(c) = map.get_mut(u) { + *c = *c + 1; + } else { + map.insert(u, 1); + } + } + } + + let mut max_u = ( *map.first_entry().unwrap().key()).clone(); + let mut max_c = 0; + + for (u, c) in map { + if c > max_c { + max_c = c; + max_u = u.clone(); + } + } + + if max_c > 1 { + let mut picked = vec![]; + let mut other = vec![]; + + for (mut k, v) in tree { + let c = k.remove(&max_u); + match c { + Some(1) => { + picked.push((k, v)); + } + Some(c) => { + k.insert(max_u.clone(), c - 1); + picked.push((k, v)); + } + None => { + other.push((k, v)); + } + } + } + + let picked = Self::reconstruct_tree(picked, r_deep_limit - 1); + let mut r = Self::Op(Box::new(picked), Box::new(Self::Unit(max_u)), Bop::Product); + + if other.len() > 0 { + r = Self::Op( + Box::new(Self::reconstruct_tree(other, r_deep_limit)), + Box::new(r), + Bop::Sum, + ); + } + + return r; + } + } + + return tree + .into_iter() + .map(|(k, ys)| Self::reconstruct_units_coeff(k, ys)) + .reduce(|acc, x| Self::Op(Box::new(acc), Box::new(x), Bop::Sum)) + .unwrap(); + } + *) + Definition reconstruct_tree (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ tree; r_deep_limit ] => + ltac:(M.monadic + (let tree := M.alloc (| tree |) in + let r_deep_limit := M.alloc (| r_deep_limit |) in + M.catch_return (| + ltac:(M.monadic + (M.never_to_any (| + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ tree ] + |)) + (Value.Integer 1) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let u := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "pop", + [] + |), + [ tree ] + |) + ] + |) + |) in + M.return_ (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "reconstruct_units_coeff", + [] + |), + [ + M.read (| M.SubPointer.get_tuple_field (| u, 0 |) |); + M.read (| M.SubPointer.get_tuple_field (| u, 1 |) |) + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt (M.read (| r_deep_limit |)) (Value.Integer 2) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let map := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" + ]; + Ty.path "i32"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ tree ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ2_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let us := M.alloc (| γ2_0 |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path + "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ M.read (| us |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::collections::btree::map::Iter") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let u := + M.copy (| + γ1_0 + |) in + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" + ]; + Ty.path + "i32"; + Ty.path + "alloc::alloc::Global" + ], + "get_mut", + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" + ] + |), + [ + map; + M.read (| + u + |) + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let c := + M.copy (| + γ0_0 + |) in + let _ := + M.write (| + M.read (| + c + |), + BinOp.Panic.add (| + Integer.I32, + M.read (| + M.read (| + c + |) + |), + Value.Integer + 1 + |) + |) in + M.alloc (| + Value.Tuple + [] + |))); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" + ]; + Ty.path + "i32"; + Ty.path + "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + map; + M.read (| + u + |); + Value.Integer + 1 + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let max_u := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit", + [], + "clone", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::entry::OccupiedEntry") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" + ]; + Ty.path "i32"; + Ty.path "alloc::alloc::Global" + ], + "key", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::entry::OccupiedEntry") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" + ]; + Ty.path "i32"; + Ty.path "alloc::alloc::Global" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" + ]; + Ty.path "i32"; + Ty.path "alloc::alloc::Global" + ], + "first_entry", + [] + |), + [ map ] + |) + ] + |) + |) + ] + |) + |) + ] + |) + |) in + let max_c := M.alloc (| Value.Integer 0 |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" + ]; + Ty.path "i32"; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| map |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::collections::btree::map::IntoIter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" + ]; + Ty.path "i32"; + Ty.path "alloc::alloc::Global" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let u := M.copy (| γ1_0 |) in + let c := M.copy (| γ1_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| c |)) + (M.read (| max_c |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.write (| + max_c, + M.read (| c |) + |) in + let _ := + M.write (| + max_u, + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit", + [], + "clone", + [] + |), + [ M.read (| u |) ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt (M.read (| max_c |)) (Value.Integer 1) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let picked := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let other := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| tree |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let k := M.copy (| γ1_0 |) in + let v := M.copy (| γ1_1 |) in + let c := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path + "alloc::alloc::Global" + ], + "remove", + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" + ] + |), + [ k; max_u ] + |) + |) in + M.match_operator (| + c, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ0_0 |), + Value.Integer 1 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path + "u32"; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "u32"; + F; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + picked; + Value.Tuple + [ + M.read (| + k + |); + M.read (| + v + |) + ] + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let c := + M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path + "u32"; + Ty.path + "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + k; + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit", + [], + "clone", + [] + |), + [ max_u ] + |); + BinOp.Panic.sub (| + Integer.U32, + M.read (| + c + |), + Value.Integer + 1 + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path + "u32"; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "u32"; + F; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + picked; + Value.Tuple + [ + M.read (| + k + |); + M.read (| + v + |) + ] + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path + "u32"; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "u32"; + F; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + other; + Value.Tuple + [ + M.read (| + k + |); + M.read (| + v + |) + ] + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let picked := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "reconstruct_tree", + [] + |), + [ + M.read (| picked |); + BinOp.Panic.sub (| + Integer.U32, + M.read (| r_deep_limit |), + Value.Integer 1 + |) + ] + |) + |) in + let r := + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| picked |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Unit" + [ M.read (| max_u |) ] + ] + |); + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::Bop::Product" + [] + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ other ] + |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.write (| + r, + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "reconstruct_tree", + [] + |), + [ + M.read (| other |); + M.read (| r_deep_limit |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| r |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::Bop::Sum" + [] + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.return_ (| M.read (| r |) |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.return_ (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]) + ], + [], + "reduce", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| tree |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let k := M.copy (| γ0_0 |) in + let ys := M.copy (| γ0_1 |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "reconstruct_units_coeff", + [] + |), + [ M.read (| k |); M.read (| ys |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| acc |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| x |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::Bop::Sum" + [] + ])) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_reconstruct_tree : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "reconstruct_tree" (reconstruct_tree F). + + (* + pub(crate) fn reconstruct(tree: &[(Vec, BTreeMap)]) -> Self { + let tree = tree + .into_iter() + .map(|(us, v)| { + let mut map = BTreeMap::new(); + for u in us { + if let Some(c) = map.get_mut(u) { + *c = *c + 1; + } else { + map.insert(u.clone(), 1); + } + } + (map, v.clone()) + }) + .collect(); + + let r_deep = std::env::var("HALO2_PROOF_GPU_EVAL_R_DEEP").unwrap_or("6".to_owned()); + let r_deep = u32::from_str_radix(&r_deep, 10).expect("Invalid HALO2_PROOF_GPU_EVAL_R_DEEP"); + Self::reconstruct_tree(tree, r_deep) + } + *) + Definition reconstruct (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ tree ] => + ltac:(M.monadic + (let tree := M.alloc (| tree |) in + M.read (| + let tree := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ] + ], + [], + "map", + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ] + ] + ], + [], + "into_iter", + [] + |), + [ M.read (| tree |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let us := M.alloc (| γ1_0 |) in + let v := M.alloc (| γ1_1 |) in + M.read (| + let map := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ M.read (| us |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let u := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path + "u32"; + Ty.path + "alloc::alloc::Global" + ], + "get_mut", + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" + ] + |), + [ + map; + M.read (| u |) + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let c := + M.copy (| γ0_0 |) in + let _ := + M.write (| + M.read (| c |), + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.read (| c |) + |), + Value.Integer 1 + |) + |) in + M.alloc (| + Value.Tuple [] + |))); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path + "u32"; + Ty.path + "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + map; + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit", + [], + "clone", + [] + |), + [ + M.read (| + u + |) + ] + |); + Value.Integer + 1 + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.Tuple + [ + M.read (| map |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ M.read (| v |) ] + |) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let r_deep := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "alloc::string::String"; Ty.path "std::env::VarError" ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_function (| + "std::env::var", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ M.read (| Value.String "HALO2_PROOF_GPU_EVAL_R_DEEP" |) ] + |); + M.call_closure (| + M.get_trait_method (| + "alloc::borrow::ToOwned", + Ty.path "str", + [], + "to_owned", + [] + |), + [ M.read (| Value.String "6" |) ] + |) + ] + |) + |) in + let r_deep := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "core::num::error::ParseIntError" ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "from_str_radix", [] |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "alloc::string::String", + [], + "deref", + [] + |), + [ r_deep ] + |); + Value.Integer 10 + ] + |); + M.read (| Value.String "Invalid HALO2_PROOF_GPU_EVAL_R_DEEP" |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") [ F ], + "reconstruct_tree", + [] + |), + [ M.read (| tree |); M.read (| r_deep |) ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_reconstruct : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "reconstruct" (reconstruct F). + + (* + pub(crate) fn get_complexity(&self) -> ComplexityProfiler { + match self { + ProveExpression::Unit(u) => ComplexityProfiler { + mul: 0, + sum: 0, + scale: 0, + unit: 1, + y: 0, + ref_cnt: HashMap::from_iter(vec![(u.get_group(), 1)]), + }, + ProveExpression::Op(l, r, op) => { + let mut l = l.get_complexity(); + let r = r.get_complexity(); + for (k, v) in r.ref_cnt { + if let Some(lv) = l.ref_cnt.get_mut(&k) { + *lv += v; + } else { + l.ref_cnt.insert(k, v); + } + } + l.scale += r.scale; + l.mul += r.mul; + l.sum += r.sum; + l.y += r.y; + l.unit += r.unit; + match op { + Bop::Sum => l.sum += 1, + Bop::Product => l.mul += 1, + }; + l + } + ProveExpression::Y(_) => ComplexityProfiler { + mul: 0, + sum: 0, + scale: 0, + unit: 0, + y: 1, + ref_cnt: HashMap::from_iter(vec![]), + }, + ProveExpression::Scale(l, _) => { + let mut l = l.get_complexity(); + l.scale += 1; + l + } + } + } + *) + Definition get_complexity (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Unit", + 0 + |) in + let u := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler" + [ + ("mul", Value.Integer 0); + ("sum", Value.Integer 0); + ("scale", Value.Integer 0); + ("unit_", Value.Integer 1); + ("y", Value.Integer 0); + ("ref_cnt", + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::FromIterator", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "u32"; + Ty.path "std::hash::random::RandomState" + ], + [ Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] ], + "from_iter", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit", + "get_group", + [] + |), + [ M.read (| u |) ] + |); + Value.Integer 1 + ] + ] + |) + ] + |) + |)) + ] + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op", + 1 + |) in + let γ1_2 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op", + 2 + |) in + let l := M.alloc (| γ1_0 |) in + let r := M.alloc (| γ1_1 |) in + let op := M.alloc (| γ1_2 |) in + let l := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "get_complexity", + [] + |), + [ M.read (| M.read (| l |) |) ] + |) + |) in + let r := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "get_complexity", + [] + |), + [ M.read (| M.read (| r |) |) ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "u32"; + Ty.path "std::hash::random::RandomState" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + r, + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "ref_cnt" + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "std::collections::hash::map::IntoIter") + [ Ty.path "usize"; Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let k := M.copy (| γ1_0 |) in + let v := M.copy (| γ1_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "u32"; + Ty.path + "std::hash::random::RandomState" + ], + "get_mut", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + l, + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "ref_cnt" + |); + k + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let lv := M.copy (| γ0_0 |) in + let _ := + let β := M.read (| lv |) in + M.write (| + β, + BinOp.Panic.add (| + Integer.U32, + M.read (| β |), + M.read (| v |) + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "u32"; + Ty.path + "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + l, + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "ref_cnt" + |); + M.read (| k |); + M.read (| v |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + let β := + M.SubPointer.get_struct_record_field (| + l, + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "scale" + |) in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + M.read (| + M.SubPointer.get_struct_record_field (| + r, + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "scale" + |) + |) + |) + |) in + let _ := + let β := + M.SubPointer.get_struct_record_field (| + l, + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "mul" + |) in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + M.read (| + M.SubPointer.get_struct_record_field (| + r, + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "mul" + |) + |) + |) + |) in + let _ := + let β := + M.SubPointer.get_struct_record_field (| + l, + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "sum" + |) in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + M.read (| + M.SubPointer.get_struct_record_field (| + r, + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "sum" + |) + |) + |) + |) in + let _ := + let β := + M.SubPointer.get_struct_record_field (| + l, + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "y" + |) in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + M.read (| + M.SubPointer.get_struct_record_field (| + r, + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "y" + |) + |) + |) + |) in + let _ := + let β := + M.SubPointer.get_struct_record_field (| + l, + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "unit" + |) in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + M.read (| + M.SubPointer.get_struct_record_field (| + r, + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "unit" + |) + |) + |) + |) in + let _ := + M.match_operator (| + op, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let β := + M.SubPointer.get_struct_record_field (| + l, + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "sum" + |) in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let β := + M.SubPointer.get_struct_record_field (| + l, + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "mul" + |) in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |))) + ] + |) in + l)); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Y", + 0 + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler" + [ + ("mul", Value.Integer 0); + ("sum", Value.Integer 0); + ("scale", Value.Integer 0); + ("unit_", Value.Integer 0); + ("y", Value.Integer 1); + ("ref_cnt", + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::FromIterator", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "u32"; + Ty.path "std::hash::random::RandomState" + ], + [ Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] ], + "from_iter", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Scale", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Scale", + 1 + |) in + let l := M.alloc (| γ1_0 |) in + let l := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "get_complexity", + [] + |), + [ M.read (| M.read (| l |) |) ] + |) + |) in + let _ := + let β := + M.SubPointer.get_struct_record_field (| + l, + "halo2_proofs::plonk::evaluation_gpu::ComplexityProfiler", + "scale" + |) in + M.write (| + β, + BinOp.Panic.add (| Integer.Usize, M.read (| β |), Value.Integer 1 |) + |) in + l)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get_complexity : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "get_complexity" (get_complexity F). + + (* + pub(crate) fn get_r_deep(&self) -> u32 { + match self { + ProveExpression::Unit(_) => 0, + ProveExpression::Op(l, r, _) => { + let l = l.get_r_deep(); + let r = r.get_r_deep(); + u32::max(l, r + 1) + } + ProveExpression::Y(_) => 0, + ProveExpression::Scale(l, _) => { + let l = l.get_r_deep(); + u32::max(l, 1) + } + } + } + *) + Definition get_r_deep (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Unit", + 0 + |) in + M.alloc (| Value.Integer 0 |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op", + 1 + |) in + let γ1_2 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op", + 2 + |) in + let l := M.alloc (| γ1_0 |) in + let r := M.alloc (| γ1_1 |) in + let l := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "get_r_deep", + [] + |), + [ M.read (| M.read (| l |) |) ] + |) + |) in + let r := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "get_r_deep", + [] + |), + [ M.read (| M.read (| r |) |) ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::cmp::Ord", Ty.path "u32", [], "max", [] |), + [ + M.read (| l |); + BinOp.Panic.add (| Integer.U32, M.read (| r |), Value.Integer 1 |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Y", + 0 + |) in + M.alloc (| Value.Integer 0 |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Scale", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Scale", + 1 + |) in + let l := M.alloc (| γ1_0 |) in + let l := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "get_r_deep", + [] + |), + [ M.read (| M.read (| l |) |) ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::cmp::Ord", Ty.path "u32", [], "max", [] |), + [ M.read (| l |); Value.Integer 1 ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get_r_deep : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "get_r_deep" (get_r_deep F). + + (* + fn ys_add_assign(l: &mut BTreeMap, r: BTreeMap) { + for r in r { + if let Some(f) = l.get_mut(&r.0) { + *f = r.1 + &*f; + } else { + l.insert(r.0, r.1); + } + } + } + *) + Definition ys_add_assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ l; r ] => + ltac:(M.monadic + (let l := M.alloc (| l |) in + let r := M.alloc (| r |) in + M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ], + [], + "into_iter", + [] + |), + [ M.read (| r |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::IntoIter") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let r := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ], + "get_mut", + [ Ty.path "u32" ] + |), + [ + M.read (| l |); + M.SubPointer.get_tuple_field (| r, 0 |) + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let f := M.copy (| γ0_0 |) in + let _ := + M.write (| + M.read (| f |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + F, + [ Ty.apply (Ty.path "&") [ F ] ], + "add", + [] + |), + [ + M.read (| + M.SubPointer.get_tuple_field (| r, 1 |) + |); + M.read (| f |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + M.read (| l |); + M.read (| + M.SubPointer.get_tuple_field (| r, 0 |) + |); + M.read (| + M.SubPointer.get_tuple_field (| r, 1 |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_ys_add_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "ys_add_assign" (ys_add_assign F). + + (* + fn ys_mul(l: &BTreeMap, r: &BTreeMap) -> BTreeMap { + let mut res = BTreeMap::new(); + + for l in l { + for r in r { + let order = l.0 + r.0; + let f = *l.1 * r.1; + if let Some(origin_f) = res.get_mut(&order) { + *origin_f = f + &*origin_f; + } else { + res.insert(order, f); + } + } + } + + res + } + *) + Definition ys_mul (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ l; r ] => + ltac:(M.monadic + (let l := M.alloc (| l |) in + let r := M.alloc (| r |) in + M.read (| + let res := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ], + [], + "into_iter", + [] + |), + [ M.read (| l |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::Iter") + [ Ty.path "u32"; F ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let l := M.copy (| γ0_0 |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ M.read (| r |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::collections::btree::map::Iter") + [ Ty.path "u32"; F ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let r := M.copy (| γ0_0 |) in + let order := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path "&") + [ Ty.path "u32" ], + [ + Ty.apply + (Ty.path "&") + [ Ty.path "u32" ] + ], + "add", + [] + |), + [ + M.read (| + M.SubPointer.get_tuple_field (| + l, + 0 + |) + |); + M.read (| + M.SubPointer.get_tuple_field (| + r, + 0 + |) + |) + ] + |) + |) in + let f := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ + Ty.apply + (Ty.path "&") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| + M.read (| + M.SubPointer.get_tuple_field (| + l, + 1 + |) + |) + |); + M.read (| + M.SubPointer.get_tuple_field (| + r, + 1 + |) + |) + ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path + "alloc::alloc::Global" + ], + "get_mut", + [ Ty.path "u32" ] + |), + [ res; order ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let origin_f := + M.copy (| γ0_0 |) in + let _ := + M.write (| + M.read (| origin_f |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + F, + [ + Ty.apply + (Ty.path "&") + [ F ] + ], + "add", + [] + |), + [ + M.read (| f |); + M.read (| + origin_f + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path + "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + res; + M.read (| order |); + M.read (| f |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + res + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_ys_mul : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "ys_mul" (ys_mul F). + + (* + pub fn flatten(self) -> BTreeMap, BTreeMap> { + match self { + ProveExpression::Unit(u) => BTreeMap::from_iter( + vec![( + vec![u], + BTreeMap::from_iter(vec![(0, F::one())].into_iter()), + )] + .into_iter(), + ), + ProveExpression::Op(l, r, Bop::Sum) => { + let mut l = l.flatten(); + let r = r.flatten(); + + for (rk, rys) in r.into_iter() { + if let Some(lys) = l.get_mut(&rk) { + Self::ys_add_assign(lys, rys); + } else { + l.insert(rk, rys); + } + } + l + } + ProveExpression::Op(l, r, Bop::Product) => { + let l = l.flatten(); + let r = r.flatten(); + + let mut res = BTreeMap::new(); + + for (lk, lys) in l.into_iter() { + for (rk, rys) in r.clone().into_iter() { + let mut k = vec![lk.clone(), rk.clone()].concat(); + k.sort(); + let ys = Self::ys_mul(&lys, &rys); + if let Some(origin_ys) = res.get_mut(&k) { + Self::ys_add_assign(origin_ys, ys); + } else { + res.insert(k, ys); + } + } + } + res + } + ProveExpression::Y(ys) => BTreeMap::from_iter(vec![(vec![], ys)].into_iter()), + ProveExpression::Scale(x, ys) => { + // as Product + ProveExpression::Op(x, Box::new(ProveExpression::Y(ys)), Bop::Product).flatten() + } + } + } + *) + Definition flatten (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Unit", + 0 + |) in + let u := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::FromIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ] + ], + "from_iter", + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array [ M.read (| u |) ] + |) + ] + |) + |)) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::FromIterator", + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ], + [ Ty.tuple [ Ty.path "u32"; F ] ], + "from_iter", + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple [ Ty.path "u32"; F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.tuple [ Ty.path "u32"; F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.path "u32"; + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + Value.Integer 0; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + ] + |) + ] + |) + |)) + ] + |) + ] + |) + ] + |) + ] + ] + |) + ] + |) + |)) + ] + |) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op", + 0 + |) in + let γ0_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op", + 1 + |) in + let γ0_2 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op", + 2 + |) in + let l := M.copy (| γ0_0 |) in + let r := M.copy (| γ0_1 |) in + let l := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "flatten", + [] + |), + [ M.read (| M.read (| l |) |) ] + |) + |) in + let r := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "flatten", + [] + |), + [ M.read (| M.read (| r |) |) ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| r |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::collections::btree::map::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let rk := M.copy (| γ1_0 |) in + let rys := M.copy (| γ1_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "get_mut", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ l; rk ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let lys := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "ys_add_assign", + [] + |), + [ M.read (| lys |); M.read (| rys |) ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ l; M.read (| rk |); M.read (| rys |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + l)); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op", + 0 + |) in + let γ0_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op", + 1 + |) in + let γ0_2 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op", + 2 + |) in + let l := M.copy (| γ0_0 |) in + let r := M.copy (| γ0_1 |) in + let l := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "flatten", + [] + |), + [ M.read (| M.read (| l |) |) ] + |) + |) in + let r := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "flatten", + [] + |), + [ M.read (| M.read (| r |) |) ] + |) + |) in + let res := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| l |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::collections::btree::map::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let lk := M.copy (| γ1_0 |) in + let lys := M.copy (| γ1_1 |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::collections::btree::map::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ r ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::collections::btree::map::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let rk := + M.copy (| γ1_0 |) in + let rys := + M.copy (| γ1_1 |) in + let k := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path + "alloc::alloc::Global" + ] + ], + "concat", + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path + "alloc::alloc::Global" + ] + ], + "into_vec", + [ + Ty.path + "alloc::alloc::Global" + ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path + "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + lk + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path + "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + rk + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit" + ], + "sort", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ k ] + |) + ] + |) + |) in + let ys := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "ys_mul", + [] + |), + [ lys; rys ] + |) + |) in + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "u32"; + F; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + "get_mut", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ res; k ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let origin_ys := + M.copy (| + γ0_0 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "ys_add_assign", + [] + |), + [ + M.read (| + origin_ys + |); + M.read (| + ys + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "u32"; + F; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + res; + M.read (| + k + |); + M.read (| + ys + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + res)); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Y", + 0 + |) in + let ys := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::FromIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ] + ], + "from_iter", + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "u32"; F; Ty.path "alloc::alloc::Global" ] + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "u32"; + F; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpressionUnit"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |); + M.read (| ys |) + ] + ] + |) + ] + |) + |)) + ] + |) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Scale", + 0 + |) in + let γ0_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Scale", + 1 + |) in + let x := M.copy (| γ0_0 |) in + let ys := M.copy (| γ0_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ], + "flatten", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Op" + [ + M.read (| x |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation_gpu::ProveExpression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::ProveExpression::Y" + [ M.read (| ys |) ] + ] + |); + Value.StructTuple + "halo2_proofs::plonk::evaluation_gpu::Bop::Product" + [] + ] + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_flatten : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "flatten" (flatten F). + End Impl_halo2_proofs_plonk_evaluation_gpu_ProveExpression_F. + End evaluation_gpu. +End plonk. diff --git a/CoqOfRust/halo2_proofs/plonk/keygen.v b/CoqOfRust/halo2_proofs/plonk/keygen.v new file mode 100644 index 000000000..5d6cfdac2 --- /dev/null +++ b/CoqOfRust/halo2_proofs/plonk/keygen.v @@ -0,0 +1,9026 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module plonk. + Module keygen. + (* + pub(crate) fn create_domain( + params: &Params, + ) -> ( + EvaluationDomain, + ConstraintSystem, + ConcreteCircuit::Config, + ) + where + C: CurveAffine, + ConcreteCircuit: Circuit, + { + let mut cs = ConstraintSystem::default(); + let config = ConcreteCircuit::configure(&mut cs); + + let degree = cs.degree(); + + let domain = EvaluationDomain::new(degree as u32, params.k); + + (domain, cs, config) + } + *) + Definition create_domain (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; ConcreteCircuit ], [ params ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + M.read (| + let cs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + [], + "default", + [] + |), + [] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Circuit", + ConcreteCircuit, + [ Ty.associated ], + "configure", + [] + |), + [ cs ] + |) + |) in + let degree := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "degree", + [] + |), + [ cs ] + |) + |) in + let domain := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "new", + [] + |), + [ + M.rust_cast (M.read (| degree |)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "k" + |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [ M.read (| domain |); M.read (| cs |); M.read (| config |) ] |) + |))) + | _, _ => M.impossible + end. + + (* StructRecord + { + name := "Assembly"; + ty_params := [ "F" ]; + fields := + [ + ("k", Ty.path "u32"); + ("fixed", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ]); + ("permutation", Ty.path "halo2_proofs::plonk::permutation::keygen::Assembly"); + ("selectors", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]); + ("usable_rows", Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ]); + ("_marker", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_plonk_keygen_Assembly_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::keygen::Assembly") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let names := + M.alloc (| + M.alloc (| + Value.Array + [ + M.read (| Value.String "k" |); + M.read (| Value.String "fixed" |); + M.read (| Value.String "permutation" |); + M.read (| Value.String "selectors" |); + M.read (| Value.String "usable_rows" |); + M.read (| Value.String "_marker" |) + ] + |) + |) in + let values := + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::Assembly", + "k" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::Assembly", + "fixed" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::Assembly", + "permutation" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::Assembly", + "selectors" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::Assembly", + "usable_rows" + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::Assembly", + "_marker" + |) + |)) + ] + |)) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_fields_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Assembly" |); + (* Unsize *) M.pointer_coercion (M.read (| names |)); + M.read (| values |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_plonk_keygen_Assembly_F. + + (* StructRecord + { + name := "AssemblyAssigner"; + ty_params := [ "F" ]; + fields := + [ + ("k", Ty.path "u32"); + ("fixed", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]); + ("permutation", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ Ty.path "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" ]; + Ty.path "alloc::alloc::Global" + ]); + ("selectors", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]); + ("usable_rows", Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ]); + ("_marker", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_for_halo2_proofs_plonk_keygen_AssemblyAssigner_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::keygen::AssemblyAssigner") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::plonk::keygen::AssemblyAssigner" + [ + ("k", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "k" + |) + ] + |)); + ("fixed", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "fixed" + |) + ] + |)); + ("permutation", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ Ty.path "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "permutation" + |) + ] + |)); + ("selectors", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "selectors" + |) + ] + |)); + ("usable_rows", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "usable_rows" + |) + ] + |)); + ("_marker", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "_marker" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_for_halo2_proofs_plonk_keygen_AssemblyAssigner_F. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_plonk_keygen_AssemblyAssigner_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::keygen::AssemblyAssigner") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let names := + M.alloc (| + M.alloc (| + Value.Array + [ + M.read (| Value.String "k" |); + M.read (| Value.String "fixed" |); + M.read (| Value.String "permutation" |); + M.read (| Value.String "selectors" |); + M.read (| Value.String "usable_rows" |); + M.read (| Value.String "_marker" |) + ] + |) + |) in + let values := + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "k" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "fixed" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "permutation" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "selectors" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "usable_rows" + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "_marker" + |) + |)) + ] + |)) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_fields_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AssemblyAssigner" |); + (* Unsize *) M.pointer_coercion (M.read (| names |)); + M.read (| values |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_plonk_keygen_AssemblyAssigner_F. + + Module Impl_core_convert_Into_where_pairing_bn256_arithmetic_fields_FieldExt_F_halo2_proofs_plonk_keygen_Assembly_F_for_halo2_proofs_plonk_keygen_AssemblyAssigner_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::keygen::AssemblyAssigner") [ F ]. + + (* + fn into(self) -> Assembly { + Assembly { + k: self.k, + fixed: Arc::try_unwrap(self.fixed).unwrap().into_inner().unwrap(), + permutation: permutation::keygen::Assembly::from( + Arc::try_unwrap(self.permutation) + .unwrap() + .into_inner() + .unwrap(), + ), + selectors: Arc::try_unwrap(self.selectors) + .unwrap() + .into_inner() + .unwrap(), + usable_rows: self.usable_rows, + _marker: PhantomData, + } + } + *) + Definition into (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::plonk::keygen::Assembly" + [ + ("k", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "k" + |) + |)); + ("fixed", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "into_inner", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "try_unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "fixed" + |) + |) + ] + |) + ] + |) + ] + |) + ] + |)); + ("permutation", + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "halo2_proofs::plonk::permutation::keygen::Assembly", + [ Ty.path "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" ], + "from", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "halo2_proofs::plonk::permutation::keygen::ParallelAssembly"; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.path + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.path + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" + ], + "into_inner", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.path + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" + ]; + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.path + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.path + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" + ]; + Ty.path "alloc::alloc::Global" + ], + "try_unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "permutation" + |) + |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |)); + ("selectors", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ], + "into_inner", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "try_unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "selectors" + |) + |) + ] + |) + ] + |) + ] + |) + ] + |)); + ("usable_rows", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "usable_rows" + |) + |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::convert::Into" + (Self F) + (* Trait polymorphic types *) + [ (* T *) Ty.apply (Ty.path "halo2_proofs::plonk::keygen::Assembly") [ F ] ] + (* Instance *) [ ("into", InstanceField.Method (into F)) ]. + End Impl_core_convert_Into_where_pairing_bn256_arithmetic_fields_FieldExt_F_halo2_proofs_plonk_keygen_Assembly_F_for_halo2_proofs_plonk_keygen_AssemblyAssigner_F. + + Module Impl_halo2_proofs_plonk_circuit_Assignment_where_ff_Field_F_F_for_halo2_proofs_plonk_keygen_AssemblyAssigner_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::keygen::AssemblyAssigner") [ F ]. + + (* + fn is_in_prove_mode(&self) -> bool { + false + } + *) + Definition is_in_prove_mode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.Bool false)) + | _, _ => M.impossible + end. + + (* + fn enter_region(&self, _: N) + where + NR: Into, + N: FnOnce() -> NR, + { + // Do nothing; we don't care about regions in this context. + } + *) + Definition enter_region (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ NR; N ], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Tuple [])) ] |))) + | _, _ => M.impossible + end. + + (* + fn exit_region(&self) { + // Do nothing; we don't care about regions in this context. + } + *) + Definition exit_region (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.Tuple [])) + | _, _ => M.impossible + end. + + (* + fn enable_selector(&self, _: A, selector: &Selector, row: usize) -> Result<(), Error> + where + A: FnOnce() -> AR, + AR: Into, + { + if !self.usable_rows.contains(&row) { + return Err(Error::not_enough_rows_available(self.k)); + } + + let mut selectors = self.selectors.lock().unwrap(); + selectors[selector.0][row] = true; + + Ok(()) + } + *) + Definition enable_selector (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ A; AR ], [ self; β1; selector; row ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let selector := M.alloc (| selector |) in + let row := M.alloc (| row |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + "contains", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "usable_rows" + |); + row + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::error::Error", + "not_enough_rows_available", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "k" + |) + |) + ] + |) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let selectors := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "selectors" + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref_mut", + [] + |), + [ selectors ] + |); + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| selector |), + "halo2_proofs::plonk::circuit::Selector", + 0 + |) + |) + ] + |); + M.read (| row |) + ] + |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |) + |))) + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn query_instance(&self, _: Column, row: usize) -> Result, Error> { + if !self.usable_rows.contains(&row) { + return Err(Error::not_enough_rows_available(self.k)); + } + + // There is no instance in this context. + Ok(None) + } + *) + Definition query_instance (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1; row ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let row := M.alloc (| row |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + "contains", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "usable_rows" + |); + row + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::error::Error", + "not_enough_rows_available", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "k" + |) + |) + ] + |) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.StructTuple "core::option::Option::None" [] ] + |) + |))) + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign_advice( + &self, + _: A, + _: Column, + _: usize, + _: V, + ) -> Result<(), Error> + where + V: FnOnce() -> Result, + VR: Into>, + A: FnOnce() -> AR, + AR: Into, + { + // We only care about fixed columns here + Ok(()) + } + *) + Definition assign_advice (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ V; VR; A; AR ], [ self; β1; β2; β3; β4 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let β2 := M.alloc (| β2 |) in + let β3 := M.alloc (| β3 |) in + let β4 := M.alloc (| β4 |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β2, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β3, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β4, + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ])) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign_fixed( + &self, + _: A, + column: Column, + row: usize, + to: V, + ) -> Result<(), Error> + where + V: FnOnce() -> Result, + VR: Into>, + A: FnOnce() -> AR, + AR: Into, + { + if !self.usable_rows.contains(&row) { + return Err(Error::not_enough_rows_available(self.k)); + } + + let mut fixed = self.fixed.lock().unwrap(); + *fixed + .get_mut(column.index()) + .and_then(|v| v.get_mut(row)) + .ok_or(Error::BoundsFailure)? = to()?.into(); + + Ok(()) + } + *) + Definition assign_fixed (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ V; VR; A; AR ], [ self; β1; column; row; to ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let column := M.alloc (| column |) in + let row := M.alloc (| row |) in + let to := M.alloc (| to |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + "contains", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "usable_rows" + |); + row + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::error::Error", + "not_enough_rows_available", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "k" + |) + |) + ] + |) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let fixed := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "fixed" + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.write (| + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ], + "ok_or", + [ Ty.path "halo2_proofs::plonk::error::Error" ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ], + "and_then", + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ], + "get_mut", + [ Ty.path "usize" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref_mut", + [] + |), + [ fixed ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ], + "index", + [] + |), + [ column ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let v := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ], + "get_mut", + [ Ty.path "usize" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [], + "deref_mut", + [] + |), + [ M.read (| v |) ] + |); + M.read (| row |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::error::Error::BoundsFailure" + [] + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |), + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + VR, + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ], + "into", + [] + |), + [ + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ VR; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + V, + [ Ty.tuple [] ], + "call_once", + [] + |), + [ M.read (| to |); Value.Tuple [] ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |) + |))) + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn copy( + &self, + left_column: Column, + left_row: usize, + right_column: Column, + right_row: usize, + ) -> Result<(), Error> { + if !self.usable_rows.contains(&left_row) || !self.usable_rows.contains(&right_row) { + return Err(Error::not_enough_rows_available(self.k)); + } + + let mut permutation = self.permutation.lock().unwrap(); + permutation.copy(left_column, left_row, right_column, right_row) + } + *) + Definition copy (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; left_column; left_row; right_column; right_row ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let left_column := M.alloc (| left_column |) in + let left_row := M.alloc (| left_row |) in + let right_column := M.alloc (| right_column |) in + let right_row := M.alloc (| right_row |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.or (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + "contains", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "usable_rows" + |); + left_row + ] + |)), + ltac:(M.monadic + (UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + "contains", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "usable_rows" + |); + right_row + ] + |)))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::error::Error", + "not_enough_rows_available", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "k" + |) + |) + ] + |) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let permutation := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.path + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.path + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.path + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" + ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.path + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "permutation" + |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "copy", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.path "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" + ], + [], + "deref_mut", + [] + |), + [ permutation ] + |); + M.read (| left_column |); + M.read (| left_row |); + M.read (| right_column |); + M.read (| right_row |) + ] + |) + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn fill_from_row( + &self, + column: Column, + from_row: usize, + to: Option>, + ) -> Result<(), Error> { + if !self.usable_rows.contains(&from_row) { + return Err(Error::not_enough_rows_available(self.k)); + } + + let mut fixed = self.fixed.lock().unwrap(); + let col = fixed.get_mut(column.index()).ok_or(Error::BoundsFailure)?; + + for row in self.usable_rows.clone().skip(from_row) { + col[row] = to.ok_or(Error::Synthesis)?; + } + + Ok(()) + } + *) + Definition fill_from_row (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; column; from_row; to ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + let from_row := M.alloc (| from_row |) in + let to := M.alloc (| to |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + "contains", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "usable_rows" + |); + from_row + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::error::Error", + "not_enough_rows_available", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "k" + |) + |) + ] + |) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let fixed := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "fixed" + |) + ] + |) + ] + |) + ] + |) + |) in + let col := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ], + "ok_or", + [ Ty.path "halo2_proofs::plonk::error::Error" ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ], + "get_mut", + [ Ty.path "usize" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref_mut", + [] + |), + [ fixed ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + "index", + [] + |), + [ column ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::error::Error::BoundsFailure" + [] + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::skip::Skip") + [ Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "skip", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::keygen::AssemblyAssigner", + "usable_rows" + |) + ] + |); + M.read (| from_row |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let row := M.copy (| γ0_0 |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ M.read (| col |); M.read (| row |) ] + |), + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ], + "ok_or", + [ + Ty.path + "halo2_proofs::plonk::error::Error" + ] + |), + [ + M.read (| to |); + Value.StructTuple + "halo2_proofs::plonk::error::Error::Synthesis" + [] + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn push_namespace(&self, _: N) + where + NR: Into, + N: FnOnce() -> NR, + { + // Do nothing; we don't care about namespaces in this context. + } + *) + Definition push_namespace (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ NR; N ], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Tuple [])) ] |))) + | _, _ => M.impossible + end. + + (* + fn pop_namespace(&self, _: Option) { + // Do nothing; we don't care about namespaces in this context. + } + *) + Definition pop_namespace (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Tuple [])) ] |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "halo2_proofs::plonk::circuit::Assignment" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("is_in_prove_mode", InstanceField.Method (is_in_prove_mode F)); + ("enter_region", InstanceField.Method (enter_region F)); + ("exit_region", InstanceField.Method (exit_region F)); + ("enable_selector", InstanceField.Method (enable_selector F)); + ("query_instance", InstanceField.Method (query_instance F)); + ("assign_advice", InstanceField.Method (assign_advice F)); + ("assign_fixed", InstanceField.Method (assign_fixed F)); + ("copy", InstanceField.Method (copy F)); + ("fill_from_row", InstanceField.Method (fill_from_row F)); + ("push_namespace", InstanceField.Method (push_namespace F)); + ("pop_namespace", InstanceField.Method (pop_namespace F)) + ]. + End Impl_halo2_proofs_plonk_circuit_Assignment_where_ff_Field_F_F_for_halo2_proofs_plonk_keygen_AssemblyAssigner_F. + + (* + pub fn keygen_vk( + params: &Params, + circuit: &ConcreteCircuit, + ) -> Result, Error> + where + C: CurveAffine, + ConcreteCircuit: Circuit, + { + let (domain, cs, config) = create_domain::(params); + + if (params.n as usize) < cs.minimum_rows() { + return Err(Error::not_enough_rows_available(params.k)); + } + + let mut assembly: AssemblyAssigner = AssemblyAssigner { + k: params.k, + fixed: Arc::new(Mutex::new(vec![ + domain.empty_lagrange_assigned(); + cs.num_fixed_columns + ])), + permutation: Arc::new(Mutex::new(permutation::keygen::ParallelAssembly::new( + params.n as usize, + &cs.permutation, + ))), + selectors: Arc::new(Mutex::new(vec![ + vec![false; params.n as usize]; + cs.num_selectors + ])), + usable_rows: 0..params.n as usize - (cs.blinding_factors() + 1), + _marker: PhantomData, + }; + + // Synthesize the circuit to obtain URS + ConcreteCircuit::FloorPlanner::synthesize( + &mut assembly, + circuit, + config, + cs.constants.clone(), + )?; + + let assembly: Assembly = assembly.into(); + + let mut fixed = batch_invert_assigned(assembly.fixed); + let (cs, selector_polys) = cs.compress_selectors(assembly.selectors); + fixed.extend( + selector_polys + .into_iter() + .map(|poly| domain.lagrange_from_vec(poly)), + ); + + let permutation_vk = assembly + .permutation + .build_vk(params, &domain, &cs.permutation); + + let fixed_commitments = fixed + .iter() + .map(|poly| params.commit_lagrange(poly).to_affine()) + .collect(); + + Ok(VerifyingKey { + domain, + fixed_commitments, + permutation: permutation_vk, + cs, + }) + } + *) + Definition keygen_vk (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; ConcreteCircuit ], [ params; circuit ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let circuit := M.alloc (| circuit |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::keygen::create_domain", + [ C; ConcreteCircuit ] + |), + [ M.read (| params |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_2 := M.SubPointer.get_tuple_field (| γ, 2 |) in + let domain := M.copy (| γ0_0 |) in + let cs := M.copy (| γ0_1 |) in + let config := M.copy (| γ0_2 |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |))) + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "minimum_rows", + [] + |), + [ cs ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::error::Error", + "not_enough_rows_available", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "k" + |) + |) + ] + |) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let assembly := + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::keygen::AssemblyAssigner" + [ + ("k", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "k" + |) + |)); + ("fixed", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "empty_lagrange_assigned", + [] + |), + [ domain ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_fixed_columns" + |) + |) + ] + |) + ] + |) + ] + |)); + ("permutation", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.path + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.path + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "new", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)); + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |) + ] + |) + ] + |) + ] + |)); + ("selectors", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ Ty.path "bool" ] + |), + [ + Value.Bool false; + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)) + ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_selectors" + |) + |) + ] + |) + ] + |) + ] + |)); + ("usable_rows", + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + BinOp.Panic.sub (| + Integer.Usize, + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)), + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "blinding_factors", + [] + |), + [ cs ] + |), + Value.Integer 1 + |) + |)) + ]); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::FloorPlanner", + Ty.associated, + [], + "synthesize", + [ + Ty.associated; + Ty.apply + (Ty.path "halo2_proofs::plonk::keygen::AssemblyAssigner") + [ Ty.associated ]; + ConcreteCircuit + ] + |), + [ + assembly; + M.read (| circuit |); + M.read (| config |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "constants" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::VerifyingKey") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let assembly := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::keygen::AssemblyAssigner") + [ Ty.associated ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::keygen::Assembly") + [ Ty.associated ] + ], + "into", + [] + |), + [ M.read (| assembly |) ] + |) + |) in + let fixed := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::poly::batch_invert_assigned", + [ Ty.associated ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + assembly, + "halo2_proofs::plonk::keygen::Assembly", + "fixed" + |) + |) + ] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "compress_selectors", + [] + |), + [ + M.read (| cs |); + M.read (| + M.SubPointer.get_struct_record_field (| + assembly, + "halo2_proofs::plonk::keygen::Assembly", + "selectors" + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let cs := M.copy (| γ0_0 |) in + let selector_polys := M.copy (| γ0_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::Extend", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ], + "extend", + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]) + ] + ] + |), + [ + fixed; + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| selector_polys |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let poly := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "lagrange_from_vec", + [] + |), + [ domain; M.read (| poly |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let permutation_vk := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::plonk::permutation::keygen::Assembly", + "build_vk", + [ C ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + assembly, + "halo2_proofs::plonk::keygen::Assembly", + "permutation" + |) + |); + M.read (| params |); + domain; + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |) + ] + |) + |) in + let fixed_commitments := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + C + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ], + [], + "map", + [ + C; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + C + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ fixed ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let poly := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "group::Curve", + Ty.associated, + [], + "to_affine", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::Params") + [ C ], + "commit_lagrange", + [] + |), + [ + M.read (| params |); + M.read (| poly |) + ] + |) + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::VerifyingKey" + [ + ("domain", M.read (| domain |)); + ("fixed_commitments", M.read (| fixed_commitments |)); + ("permutation", M.read (| permutation_vk |)); + ("cs", M.read (| cs |)) + ] + ] + |))) + ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + pub fn keygen_pk( + params: &Params, + vk: VerifyingKey, + circuit: &ConcreteCircuit, + ) -> Result, Error> + where + C: CurveAffine, + ConcreteCircuit: Circuit, + { + let mut cs = ConstraintSystem::default(); + let config = ConcreteCircuit::configure(&mut cs); + + let cs = cs; + + if (params.n as usize) < cs.minimum_rows() { + return Err(Error::not_enough_rows_available(params.k)); + } + + let mut assembly: AssemblyAssigner = AssemblyAssigner { + k: params.k, + fixed: Arc::new(Mutex::new(vec![ + vk.domain.empty_lagrange_assigned(); + cs.num_fixed_columns + ])), + permutation: Arc::new(Mutex::new(permutation::keygen::ParallelAssembly::new( + params.n as usize, + &cs.permutation, + ))), + selectors: Arc::new(Mutex::new(vec![ + vec![false; params.n as usize]; + cs.num_selectors + ])), + usable_rows: 0..params.n as usize - (cs.blinding_factors() + 1), + _marker: std::marker::PhantomData, + }; + + // Synthesize the circuit to obtain URS + ConcreteCircuit::FloorPlanner::synthesize( + &mut assembly, + circuit, + config, + cs.constants.clone(), + )?; + + let assembly: Assembly = assembly.into(); + + let timer = start_timer!(|| "unnecessary part"); + let (cs, fixed) = if false { + let mut fixed = batch_invert_assigned(assembly.fixed); + let (cs, selector_polys) = cs.compress_selectors(assembly.selectors); + fixed.extend( + selector_polys + .into_iter() + .map(|poly| vk.domain.lagrange_from_vec(poly)), + ); + (cs, fixed) + } else { + assert!(assembly.selectors.len() == 0); + ( + cs, + assembly + .fixed + .into_par_iter() + .map(|x| Polynomial { + values: x + .into_iter() + .map(|x| { + assert!(x.denominator().is_none()); + x.numerator() + }) + .collect(), + _marker: std::marker::PhantomData, + }) + .collect::>(), + ) + }; + end_timer!(timer); + + let timer = start_timer!(|| "fix poly"); + let fixed_polys: Vec<_> = fixed + .par_iter() + .map(|poly| vk.domain.lagrange_to_coeff_st(poly.clone())) + .collect(); + end_timer!(timer); + + #[cfg(not(feature = "cuda"))] + let fixed_cosets = fixed_polys + .iter() + .map(|poly| vk.domain.coeff_to_extended(poly.clone())) + .collect(); + + let timer = start_timer!(|| "assembly build pkey"); + let permutation_pk = assembly + .permutation + .build_pk(params, &vk.domain, &cs.permutation); + end_timer!(timer); + + let timer = start_timer!(|| "l poly"); + // Compute l_0(X) + // TODO: this can be done more efficiently + let mut l0 = vk.domain.empty_lagrange(); + l0[0] = C::Scalar::one(); + let l0 = vk.domain.lagrange_to_coeff(l0); + #[cfg(not(feature = "cuda"))] + let l0 = vk.domain.coeff_to_extended(l0); + + // Compute l_blind(X) which evaluates to 1 for each blinding factor row + // and 0 otherwise over the domain. + let mut l_blind = vk.domain.empty_lagrange(); + for evaluation in l_blind[..].iter_mut().rev().take(cs.blinding_factors()) { + *evaluation = C::Scalar::one(); + } + let l_blind = vk.domain.lagrange_to_coeff(l_blind); + let l_blind_extended = vk.domain.coeff_to_extended(l_blind); + + // Compute l_last(X) which evaluates to 1 on the first inactive row (just + // before the blinding factors) and 0 otherwise over the domain + let mut l_last = vk.domain.empty_lagrange(); + l_last[params.n as usize - cs.blinding_factors() - 1] = C::Scalar::one(); + let l_last = vk.domain.lagrange_to_coeff(l_last); + let l_last_extended = vk.domain.coeff_to_extended(l_last.clone()); + + // Compute l_active_row(X) + let one = C::Scalar::one(); + + let mut l_active_row = vk.domain.empty_extended(); + parallelize(&mut l_active_row, |values, start| { + for (i, value) in values.iter_mut().enumerate() { + let idx = i + start; + *value = one - (l_last_extended[idx] + l_blind_extended[idx]); + } + }); + end_timer!(timer); + + let timer = start_timer!(|| "prepare ev"); + // Compute the optimized evaluation data structure + let ev = Evaluator::new(&vk.cs); + end_timer!(timer); + + #[cfg(not(feature = "cuda"))] + let l_last = l_last_extended; + + Ok(ProvingKey { + vk, + l0, + l_last, + l_active_row, + fixed_values: fixed, + fixed_polys, + + #[cfg(not(feature = "cuda"))] + fixed_cosets, + permutation: permutation_pk, + ev, + }) + } + *) + Definition keygen_pk (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; ConcreteCircuit ], [ params; vk; circuit ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let vk := M.alloc (| vk |) in + let circuit := M.alloc (| circuit |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let cs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + [], + "default", + [] + |), + [] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Circuit", + ConcreteCircuit, + [ Ty.associated ], + "configure", + [] + |), + [ cs ] + |) + |) in + let cs := M.copy (| cs |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |))) + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "minimum_rows", + [] + |), + [ cs ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::error::Error", + "not_enough_rows_available", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "k" + |) + |) + ] + |) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let assembly := + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::keygen::AssemblyAssigner" + [ + ("k", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "k" + |) + |)); + ("fixed", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "empty_lagrange_assigned", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + vk, + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_fixed_columns" + |) + |) + ] + |) + ] + |) + ] + |)); + ("permutation", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.path + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.path + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "new", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)); + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |) + ] + |) + ] + |) + ] + |)); + ("selectors", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ Ty.path "bool" ] + |), + [ + Value.Bool false; + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)) + ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_selectors" + |) + |) + ] + |) + ] + |) + ] + |)); + ("usable_rows", + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + BinOp.Panic.sub (| + Integer.Usize, + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)), + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "blinding_factors", + [] + |), + [ cs ] + |), + Value.Integer 1 + |) + |)) + ]); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::FloorPlanner", + Ty.associated, + [], + "synthesize", + [ + Ty.associated; + Ty.apply + (Ty.path "halo2_proofs::plonk::keygen::AssemblyAssigner") + [ Ty.associated ]; + ConcreteCircuit + ] + |), + [ + assembly; + M.read (| circuit |); + M.read (| config |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "constants" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::ProvingKey") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let assembly := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::keygen::AssemblyAssigner") + [ Ty.associated ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::keygen::Assembly") + [ Ty.associated ] + ], + "into", + [] + |), + [ M.read (| assembly |) ] + |) + |) in + let timer := + M.alloc (| Value.StructTuple "ark_std::perf_trace::inner::TimerInfo" [] |) in + M.match_operator (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use (M.alloc (| Value.Bool false |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let fixed := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::poly::batch_invert_assigned", + [ Ty.associated ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + assembly, + "halo2_proofs::plonk::keygen::Assembly", + "fixed" + |) + |) + ] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "compress_selectors", + [] + |), + [ + M.read (| cs |); + M.read (| + M.SubPointer.get_struct_record_field (| + assembly, + "halo2_proofs::plonk::keygen::Assembly", + "selectors" + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let cs := M.copy (| γ0_0 |) in + let selector_polys := M.copy (| γ0_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::Extend", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ], + "extend", + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]) + ] + ] + |), + [ + fixed; + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| selector_polys |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let poly := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "lagrange_from_vec", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + vk, + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| poly |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [ M.read (| cs |); M.read (| fixed |) ] + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "bool"; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + assembly, + "halo2_proofs::plonk::keygen::Assembly", + "selectors" + |) + ] + |)) + (Value.Integer 0)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "assertion failed: assembly.selectors.len() == 0" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + Value.Tuple + [ + M.read (| cs |); + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path "rayon::vec::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::vec::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]); + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_par_iter", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + assembly, + "halo2_proofs::plonk::keygen::Assembly", + "fixed" + |) + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated + ] + ] + ] + ] + Ty.associated + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ] + ], + [], + "map", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ + Ty.associated + ] + ] + ] + ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated + ]; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [], + "deref", + [] + |), + [ x ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := + M.copy (| + γ + |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.associated + ], + "is_none", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ + Ty.associated + ], + "denominator", + [] + |), + [ + M.read (| + x + |) + ] + |) + |) + ] + |)) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic", + [] + |), + [ + M.read (| + Value.String + "assertion failed: x.denominator().is_none()" + |) + ] + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ + Ty.associated + ], + "numerator", + [] + |), + [ + M.read (| + x + |) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |)); + ("_marker", + Value.StructTuple + "core::marker::PhantomData" + []) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |))) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let cs := M.copy (| γ0_0 |) in + let fixed := M.copy (| γ0_1 |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple "ark_std::perf_trace::inner::TimerInfo" [] + |) in + let fixed_polys := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ]); + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelRefIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "par_iter", + [] + |), + [ fixed ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let poly := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "lagrange_to_coeff_st", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + vk, + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [], + "clone", + [] + |), + [ M.read (| poly |) ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let fixed_cosets := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ fixed_polys ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let poly := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "coeff_to_extended", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + vk, + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [], + "clone", + [] + |), + [ M.read (| poly |) ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let permutation_pk := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::plonk::permutation::keygen::Assembly", + "build_pk", + [ C ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + assembly, + "halo2_proofs::plonk::keygen::Assembly", + "permutation" + |) + |); + M.read (| params |); + M.SubPointer.get_struct_record_field (| + vk, + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let l0 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "empty_lagrange", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + vk, + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |) + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ l0; Value.Integer 0 ] + |), + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |) + |) in + let l0 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "lagrange_to_coeff", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + vk, + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| l0 |) + ] + |) + |) in + let l0 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "coeff_to_extended", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + vk, + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| l0 |) + ] + |) + |) in + let l_blind := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "empty_lagrange", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + vk, + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::take::Take") + [ + Ty.apply + (Ty.path + "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ] + ], + [], + "take", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "rev", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [ + Ty.path + "core::ops::range::RangeFull" + ], + "index_mut", + [] + |), + [ + l_blind; + Value.StructTuple + "core::ops::range::RangeFull" + [] + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "blinding_factors", + [] + |), + [ cs ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::take::Take") + [ + Ty.apply + (Ty.path + "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let evaluation := + M.copy (| γ0_0 |) in + let _ := + M.write (| + M.read (| + evaluation + |), + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let l_blind := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "lagrange_to_coeff", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + vk, + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| l_blind |) + ] + |) + |) in + let l_blind_extended := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "coeff_to_extended", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + vk, + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| l_blind |) + ] + |) + |) in + let l_last := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "empty_lagrange", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + vk, + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |) + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + l_last; + BinOp.Panic.sub (| + Integer.Usize, + BinOp.Panic.sub (| + Integer.Usize, + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)), + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "blinding_factors", + [] + |), + [ cs ] + |) + |), + Value.Integer 1 + |) + ] + |), + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |) + |) in + let l_last := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "lagrange_to_coeff", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + vk, + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| l_last |) + ] + |) + |) in + let l_last_extended := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "coeff_to_extended", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + vk, + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ], + [], + "clone", + [] + |), + [ l_last ] + |) + ] + |) + |) in + let one := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |) + |) in + let l_active_row := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "empty_extended", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + vk, + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [], + "deref_mut", + [] + |), + [ l_active_row ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let values := + M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let start := + M.copy (| γ |) in + M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ], + "iter_mut", + [] + |), + [ + M.read (| + values + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + i := + M.copy (| + γ1_0 + |) in + let + value := + M.copy (| + γ1_1 + |) in + let + idx := + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.read (| + i + |), + M.read (| + start + |) + |) + |) in + let + _ := + M.write (| + M.read (| + value + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ + Ty.associated + ], + "sub", + [] + |), + [ + M.read (| + one + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + l_last_extended; + M.read (| + idx + |) + ] + |) + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + l_blind_extended; + M.read (| + idx + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let ev := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "new", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + vk, + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let l_last := + M.copy (| l_last_extended |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::ProvingKey" + [ + ("vk", M.read (| vk |)); + ("l0", M.read (| l0 |)); + ("l_last", + M.read (| l_last |)); + ("l_active_row", + M.read (| + l_active_row + |)); + ("fixed_values", + M.read (| fixed |)); + ("fixed_polys", + M.read (| + fixed_polys + |)); + ("fixed_cosets", + M.read (| + fixed_cosets + |)); + ("permutation", + M.read (| + permutation_pk + |)); + ("ev", M.read (| ev |)) + ] + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + pub(crate) fn keygen_pk_from_info( + params: &Params, + vk: &VerifyingKey, + fixed: Vec>, + permutation: permutation::keygen::Assembly, + ) -> Result, Error> + where + C: CurveAffine, + { + let cs = vk.cs.clone(); + assert!(cs.num_selectors == 0); + //We do not support the case when selectors exists + //let selectors = vec![vec![false; params.n as usize]; cs.num_selectors]; + let selectors = vec![]; + use ark_std::{end_timer, start_timer}; + + let timer = start_timer!(|| "compress selectors ..."); + let (cs, _) = cs.compress_selectors(selectors); + end_timer!(timer); + let timer = start_timer!(|| "fixed polys ..."); + + let fixed_polys: Vec<_> = fixed + .iter() + .map(|poly| vk.domain.lagrange_to_coeff_st(poly.clone())) + .collect(); + end_timer!(timer); + + #[cfg(not(feature = "cuda"))] + let fixed_cosets = fixed_polys + .iter() + .map(|poly| vk.domain.coeff_to_extended(poly.clone())) + .collect(); + + let timer = start_timer!(|| "build pk time..."); + let permutation_pk = permutation.build_pk(params, &vk.domain, &cs.permutation); + end_timer!(timer); + + let timer = start_timer!(|| "l poly"); + // Compute l_0(X) + // TODO: this can be done more efficiently + let mut l0 = vk.domain.empty_lagrange(); + l0[0] = C::Scalar::one(); + let l0 = vk.domain.lagrange_to_coeff(l0); + #[cfg(not(feature = "cuda"))] + let l0 = vk.domain.coeff_to_extended(l0); + + // Compute l_blind(X) which evaluates to 1 for each blinding factor row + // and 0 otherwise over the domain. + let mut l_blind = vk.domain.empty_lagrange(); + for evaluation in l_blind[..].iter_mut().rev().take(cs.blinding_factors()) { + *evaluation = C::Scalar::one(); + } + let l_blind = vk.domain.lagrange_to_coeff(l_blind); + let l_blind_extended = vk.domain.coeff_to_extended(l_blind); + + // Compute l_last(X) which evaluates to 1 on the first inactive row (just + // before the blinding factors) and 0 otherwise over the domain + let mut l_last = vk.domain.empty_lagrange(); + l_last[params.n as usize - cs.blinding_factors() - 1] = C::Scalar::one(); + let l_last = vk.domain.lagrange_to_coeff(l_last); + let l_last_extended = vk.domain.coeff_to_extended(l_last.clone()); + + // Compute l_active_row(X) + let one = C::Scalar::one(); + + let mut l_active_row = vk.domain.empty_extended(); + parallelize(&mut l_active_row, |values, start| { + for (i, value) in values.iter_mut().enumerate() { + let idx = i + start; + *value = one - (l_last_extended[idx] + l_blind_extended[idx]); + } + }); + end_timer!(timer); + + let timer = start_timer!(|| "prepare ev"); + // Compute the optimized evaluation data structure + let ev = Evaluator::new(&vk.cs); + end_timer!(timer); + + #[cfg(not(feature = "cuda"))] + let l_last = l_last_extended; + + Ok(ProvingKey { + vk: vk.clone(), + l0, + l_last, + l_active_row, + fixed_values: fixed, + fixed_polys, + + #[cfg(not(feature = "cuda"))] + fixed_cosets, + permutation: permutation_pk, + ev, + }) + } + *) + Definition keygen_pk_from_info (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C ], [ params; vk; fixed; permutation ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let vk := M.alloc (| vk |) in + let fixed := M.alloc (| fixed |) in + let permutation := M.alloc (| permutation |) in + M.read (| + let cs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_selectors" + |) + |)) + (Value.Integer 0)) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "assertion failed: cs.num_selectors == 0" |) ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let selectors := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let timer := + M.alloc (| Value.StructTuple "ark_std::perf_trace::inner::TimerInfo" [] |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "compress_selectors", + [] + |), + [ M.read (| cs |); M.read (| selectors |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let cs := M.copy (| γ0_0 |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple "ark_std::perf_trace::inner::TimerInfo" [] + |) in + let fixed_polys := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ fixed ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let poly := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "lagrange_to_coeff_st", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [], + "clone", + [] + |), + [ M.read (| poly |) ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let fixed_cosets := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ fixed_polys ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let poly := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "coeff_to_extended", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [], + "clone", + [] + |), + [ M.read (| poly |) ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let timer := + M.alloc (| + Value.StructTuple "ark_std::perf_trace::inner::TimerInfo" [] + |) in + let permutation_pk := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::plonk::permutation::keygen::Assembly", + "build_pk", + [ C ] + |), + [ + M.read (| permutation |); + M.read (| params |); + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let l0 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "empty_lagrange", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |) + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ l0; Value.Integer 0 ] + |), + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |) + |) in + let l0 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "lagrange_to_coeff", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| l0 |) + ] + |) + |) in + let l0 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "coeff_to_extended", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| l0 |) + ] + |) + |) in + let l_blind := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "empty_lagrange", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::take::Take") + [ + Ty.apply + (Ty.path + "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ] + ], + [], + "take", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "rev", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [ + Ty.path + "core::ops::range::RangeFull" + ], + "index_mut", + [] + |), + [ + l_blind; + Value.StructTuple + "core::ops::range::RangeFull" + [] + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "blinding_factors", + [] + |), + [ cs ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::take::Take") + [ + Ty.apply + (Ty.path + "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let evaluation := + M.copy (| γ0_0 |) in + let _ := + M.write (| + M.read (| evaluation |), + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let l_blind := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "lagrange_to_coeff", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| l_blind |) + ] + |) + |) in + let l_blind_extended := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "coeff_to_extended", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| l_blind |) + ] + |) + |) in + let l_last := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "empty_lagrange", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |) + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + l_last; + BinOp.Panic.sub (| + Integer.Usize, + BinOp.Panic.sub (| + Integer.Usize, + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)), + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "blinding_factors", + [] + |), + [ cs ] + |) + |), + Value.Integer 1 + |) + ] + |), + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |) + |) in + let l_last := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "lagrange_to_coeff", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| l_last |) + ] + |) + |) in + let l_last_extended := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "coeff_to_extended", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ], + [], + "clone", + [] + |), + [ l_last ] + |) + ] + |) + |) in + let one := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |) + |) in + let l_active_row := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "empty_extended", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [], + "deref_mut", + [] + |), + [ l_active_row ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let values := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let start := + M.copy (| γ |) in + M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ], + "iter_mut", + [] + |), + [ + M.read (| + values + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + i := + M.copy (| + γ1_0 + |) in + let + value := + M.copy (| + γ1_1 + |) in + let + idx := + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.read (| + i + |), + M.read (| + start + |) + |) + |) in + let + _ := + M.write (| + M.read (| + value + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ + Ty.associated + ], + "sub", + [] + |), + [ + M.read (| + one + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + l_last_extended; + M.read (| + idx + |) + ] + |) + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + l_blind_extended; + M.read (| + idx + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let ev := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "new", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let l_last := + M.copy (| l_last_extended |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::ProvingKey" + [ + ("vk", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::VerifyingKey") + [ C ], + [], + "clone", + [] + |), + [ M.read (| vk |) ] + |)); + ("l0", M.read (| l0 |)); + ("l_last", + M.read (| l_last |)); + ("l_active_row", + M.read (| l_active_row |)); + ("fixed_values", + M.read (| fixed |)); + ("fixed_polys", + M.read (| fixed_polys |)); + ("fixed_cosets", + M.read (| fixed_cosets |)); + ("permutation", + M.read (| + permutation_pk + |)); + ("ev", M.read (| ev |)) + ] + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + pub(crate) fn generate_pk_info( + params: &Params, + vk: &VerifyingKey, + circuit: &ConcreteCircuit, + ) -> Result< + ( + Vec>, + permutation::keygen::Assembly, + ), + Error, + > + where + C: CurveAffine, + ConcreteCircuit: Circuit, + { + let mut cs = ConstraintSystem::default(); + let config = ConcreteCircuit::configure(&mut cs); + + if (params.n as usize) < cs.minimum_rows() { + return Err(Error::not_enough_rows_available(params.k)); + } + + let mut assembly: AssemblyAssigner = AssemblyAssigner { + k: params.k, + fixed: Arc::new(Mutex::new(vec![ + vk.domain.empty_lagrange_assigned(); + cs.num_fixed_columns + ])), + permutation: Arc::new(Mutex::new(permutation::keygen::ParallelAssembly::new( + params.n as usize, + &cs.permutation, + ))), + selectors: Arc::new(Mutex::new(vec![ + vec![false; params.n as usize]; + cs.num_selectors + ])), + usable_rows: 0..params.n as usize - (cs.blinding_factors() + 1), + _marker: std::marker::PhantomData, + }; + + // Synthesize the circuit to obtain URS + ConcreteCircuit::FloorPlanner::synthesize( + &mut assembly, + circuit, + config, + cs.constants.clone(), + )?; + + let assembly: Assembly = assembly.into(); + + let fixed = batch_invert_assigned(assembly.fixed); + Ok((fixed, assembly.permutation)) + } + *) + Definition generate_pk_info (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; ConcreteCircuit ], [ params; vk; circuit ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let vk := M.alloc (| vk |) in + let circuit := M.alloc (| circuit |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let cs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + [], + "default", + [] + |), + [] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Circuit", + ConcreteCircuit, + [ Ty.associated ], + "configure", + [] + |), + [ cs ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |))) + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "minimum_rows", + [] + |), + [ cs ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::plonk::error::Error", + "not_enough_rows_available", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "k" + |) + |) + ] + |) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let assembly := + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::keygen::AssemblyAssigner" + [ + ("k", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "k" + |) + |)); + ("fixed", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "empty_lagrange_assigned", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_fixed_columns" + |) + |) + ] + |) + ] + |) + ] + |)); + ("permutation", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.path + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.path + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "new", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)); + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |) + ] + |) + ] + |) + ] + |)); + ("selectors", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "bool"; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ Ty.path "bool" ] + |), + [ + Value.Bool false; + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)) + ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_selectors" + |) + |) + ] + |) + ] + |) + ] + |)); + ("usable_rows", + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + BinOp.Panic.sub (| + Integer.Usize, + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)), + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "blinding_factors", + [] + |), + [ cs ] + |), + Value.Integer 1 + |) + |)) + ]); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::FloorPlanner", + Ty.associated, + [], + "synthesize", + [ + Ty.associated; + Ty.apply + (Ty.path "halo2_proofs::plonk::keygen::AssemblyAssigner") + [ Ty.associated ]; + ConcreteCircuit + ] + |), + [ + assembly; + M.read (| circuit |); + M.read (| config |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cs, + "halo2_proofs::plonk::circuit::ConstraintSystem", + "constants" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::permutation::keygen::Assembly" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let assembly := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "halo2_proofs::plonk::keygen::AssemblyAssigner") + [ Ty.associated ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::keygen::Assembly") + [ Ty.associated ] + ], + "into", + [] + |), + [ M.read (| assembly |) ] + |) + |) in + let fixed := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::poly::batch_invert_assigned", + [ Ty.associated ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + assembly, + "halo2_proofs::plonk::keygen::Assembly", + "fixed" + |) + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.Tuple + [ + M.read (| fixed |); + M.read (| + M.SubPointer.get_struct_record_field (| + assembly, + "halo2_proofs::plonk::keygen::Assembly", + "permutation" + |) + |) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + End keygen. +End plonk. diff --git a/CoqOfRust/halo2_proofs/plonk/lookup.v b/CoqOfRust/halo2_proofs/plonk/lookup.v new file mode 100644 index 000000000..b154a345e --- /dev/null +++ b/CoqOfRust/halo2_proofs/plonk/lookup.v @@ -0,0 +1,735 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module plonk. + Module lookup. + (* StructRecord + { + name := "Argument"; + ty_params := [ "F" ]; + fields := + [ + ("name", Ty.apply (Ty.path "&") [ Ty.path "str" ]); + ("input_expressions", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]); + ("table_expressions", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_for_halo2_proofs_plonk_lookup_Argument_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::plonk::lookup::Argument" + [ + ("name", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::Argument", + "name" + |) + ] + |)); + ("input_expressions", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::Argument", + "input_expressions" + |) + ] + |)); + ("table_expressions", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::Argument", + "table_expressions" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_for_halo2_proofs_plonk_lookup_Argument_F. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_plonk_lookup_Argument_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Argument" |); + M.read (| Value.String "name" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::Argument", + "name" + |)); + M.read (| Value.String "input_expressions" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::Argument", + "input_expressions" + |)); + M.read (| Value.String "table_expressions" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::Argument", + "table_expressions" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_ff_Field_F_for_halo2_proofs_plonk_lookup_Argument_F. + + Module Impl_halo2_proofs_plonk_lookup_Argument_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ]. + + (* + pub fn new(name: &'static str, table_map: Vec<(Expression, Expression)>) -> Self { + let (input_expressions, table_expressions) = table_map.into_iter().unzip(); + Argument { + name, + input_expressions, + table_expressions, + } + } + *) + Definition new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ name; table_map ] => + ltac:(M.monadic + (let name := M.alloc (| name |) in + let table_map := M.alloc (| table_map |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "unzip", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| table_map |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let input_expressions := M.copy (| γ0_0 |) in + let table_expressions := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::lookup::Argument" + [ + ("name", M.read (| name |)); + ("input_expressions", M.read (| input_expressions |)); + ("table_expressions", M.read (| table_expressions |)) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "new" (new F). + + (* + pub(crate) fn required_degree(&self) -> usize { + assert_eq!(self.input_expressions.len(), self.table_expressions.len()); + + // The first value in the permutation poly should be one. + // degree 2: + // l_0(X) * (1 - z(X)) = 0 + // + // The "last" value in the permutation poly should be a boolean, for + // completeness and soundness. + // degree 3: + // l_last(X) * (z(X)^2 - z(X)) = 0 + // + // Enable the permutation argument for only the rows involved. + // degree (2 + input_degree + table_degree) or 4, whichever is larger: + // (1 - (l_last(X) + l_blind(X))) * ( + // z(\omega X) (a'(X) + \beta) (s'(X) + \gamma) + // - z(X) (\theta^{m-1} a_0(X) + ... + a_{m-1}(X) + \beta) (\theta^{m-1} s_0(X) + ... + s_{m-1}(X) + \gamma) + // ) = 0 + // + // The first two values of a' and s' should be the same. + // degree 2: + // l_0(X) * (a'(X) - s'(X)) = 0 + // + // Either the two values are the same, or the previous + // value of a' is the same as the current value. + // degree 3: + // (1 - (l_last(X) + l_blind(X))) * (a′(X) − s′(X))⋅(a′(X) − a′(\omega^{-1} X)) = 0 + let mut input_degree = 1; + for expr in self.input_expressions.iter() { + input_degree = std::cmp::max(input_degree, expr.degree()); + } + let mut table_degree = 1; + for expr in self.table_expressions.iter() { + table_degree = std::cmp::max(table_degree, expr.degree()); + } + + // In practice because input_degree and table_degree are initialized to + // one, the latter half of this max() invocation is at least 4 always, + // rendering this call pointless except to be explicit in case we change + // the initialization of input_degree/table_degree in the future. + std::cmp::max( + // (1 - (l_last + l_blind)) z(\omega X) (a'(X) + \beta) (s'(X) + \gamma) + 4, + // (1 - (l_last + l_blind)) z(X) (\theta^{m-1} a_0(X) + ... + a_{m-1}(X) + \beta) (\theta^{m-1} s_0(X) + ... + s_{m-1}(X) + \gamma) + 2 + input_degree + table_degree, + ) + } + *) + Definition required_degree (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::Argument", + "input_expressions" + |) + ] + |) + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::Argument", + "table_expressions" + |) + ] + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let input_degree := M.alloc (| Value.Integer 1 |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::Argument", + "input_expressions" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let expr := M.copy (| γ0_0 |) in + let _ := + M.write (| + input_degree, + M.call_closure (| + M.get_function (| + "core::cmp::max", + [ Ty.path "usize" ] + |), + [ + M.read (| input_degree |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + "degree", + [] + |), + [ M.read (| expr |) ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let table_degree := M.alloc (| Value.Integer 1 |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::Argument", + "table_expressions" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let expr := M.copy (| γ0_0 |) in + let _ := + M.write (| + table_degree, + M.call_closure (| + M.get_function (| + "core::cmp::max", + [ Ty.path "usize" ] + |), + [ + M.read (| table_degree |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + "degree", + [] + |), + [ M.read (| expr |) ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + M.call_closure (| + M.get_function (| "core::cmp::max", [ Ty.path "usize" ] |), + [ + Value.Integer 4; + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + Value.Integer 2, + M.read (| input_degree |) + |), + M.read (| table_degree |) + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_required_degree : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "required_degree" (required_degree F). + End Impl_halo2_proofs_plonk_lookup_Argument_F. + End lookup. +End plonk. diff --git a/CoqOfRust/halo2_proofs/plonk/lookup/prover.v b/CoqOfRust/halo2_proofs/plonk/lookup/prover.v new file mode 100644 index 000000000..038773dfb --- /dev/null +++ b/CoqOfRust/halo2_proofs/plonk/lookup/prover.v @@ -0,0 +1,5672 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module plonk. + Module lookup. + Module prover. + (* StructRecord + { + name := "Permuted"; + ty_params := [ "C" ]; + fields := + [ + ("compressed_input_expression", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]); + ("permuted_input_expression", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]); + ("compressed_table_expression", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]); + ("permuted_table_expression", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_lookup_prover_Permuted_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::prover::Permuted") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field4_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Permuted" |); + M.read (| Value.String "compressed_input_expression" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::prover::Permuted", + "compressed_input_expression" + |)); + M.read (| Value.String "permuted_input_expression" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::prover::Permuted", + "permuted_input_expression" + |)); + M.read (| Value.String "compressed_table_expression" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::prover::Permuted", + "compressed_table_expression" + |)); + M.read (| Value.String "permuted_table_expression" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::prover::Permuted", + "permuted_table_expression" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_lookup_prover_Permuted_C. + + (* StructRecord + { + name := "Committed"; + ty_params := [ "C" ]; + fields := + [ + ("permuted_input_poly", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]); + ("permuted_table_poly", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]); + ("product_poly", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_lookup_prover_Committed_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::prover::Committed") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Committed" |); + M.read (| Value.String "permuted_input_poly" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::prover::Committed", + "permuted_input_poly" + |)); + M.read (| Value.String "permuted_table_poly" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::prover::Committed", + "permuted_table_poly" + |)); + M.read (| Value.String "product_poly" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::prover::Committed", + "product_poly" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_lookup_prover_Committed_C. + + (* StructRecord + { + name := "Evaluated"; + ty_params := [ "C" ]; + fields := + [ + ("constructed", + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::prover::Committed") [ C ]) + ]; + } *) + + Module Impl_halo2_proofs_plonk_lookup_Argument_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ]. + + (* + pub(in crate::plonk) fn commit_permuted<'a, C, R: RngCore>( + &self, + pk: &ProvingKey, + params: &Params, + domain: &EvaluationDomain, + theta: ChallengeTheta, + advice_values: &'a [Polynomial], + fixed_values: &'a [Polynomial], + instance_values: &'a [Polynomial], + mut rng: R, + ) -> Result<(Permuted, [C; 2]), Error> + where + C: CurveAffine, + C::Curve: Mul + MulAssign, + { + // Closure to get values of expressions and compress them + let compress_expressions = |expressions: &[Expression]| { + pk.vk.domain.lagrange_from_vec(evaluate_with_theta( + expressions, + params.n as usize, + 1, + fixed_values, + advice_values, + instance_values, + *theta, + )) + }; + + // Closure to construct commitment to vector of values + let commit_values = |values: &Polynomial, max_bits: usize| { + params + .commit_lagrange_with_bound(values, max_bits) + .to_affine() + }; + + // Get values of input expressions involved in the lookup and compress them + let compressed_input_expression = compress_expressions(&self.input_expressions); + + // Get values of table expressions involved in the lookup and compress them + let compressed_table_expression = compress_expressions(&self.table_expressions); + + // Permute compressed (InputExpression, TableExpression) pair + let ( + permuted_input_expression, + permuted_table_expression, + permuted_input_expression_max_bits, + permuted_table_expression_max_bits, + ) = permute_expression_pair::( + pk, + params, + domain, + &mut rng, + &compressed_input_expression, + &compressed_table_expression, + )?; + + // Commit to permuted input expression + let permuted_input_commitment = commit_values( + &permuted_input_expression, + permuted_input_expression_max_bits, + ); + + // Commit to permuted table expression + let permuted_table_commitment = commit_values( + &permuted_table_expression, + permuted_table_expression_max_bits, + ); + + Ok(( + Permuted { + compressed_input_expression, + permuted_input_expression, + compressed_table_expression, + permuted_table_expression, + }, + [permuted_input_commitment, permuted_table_commitment], + )) + } + *) + Definition commit_permuted (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ C; R ], + [ self; pk; params; domain; theta; advice_values; fixed_values; instance_values; rng + ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let pk := M.alloc (| pk |) in + let params := M.alloc (| params |) in + let domain := M.alloc (| domain |) in + let theta := M.alloc (| theta |) in + let advice_values := M.alloc (| advice_values |) in + let fixed_values := M.alloc (| fixed_values |) in + let instance_values := M.alloc (| instance_values |) in + let rng := M.alloc (| rng |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let compress_expressions := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let expressions := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ F ], + "lagrange_from_vec", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::evaluation::evaluate_with_theta", + [ F; Ty.path "halo2_proofs::poly::LagrangeCoeff" ] + |), + [ + M.read (| expressions |); + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)); + Value.Integer 1; + M.read (| fixed_values |); + M.read (| advice_values |); + M.read (| instance_values |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::Theta" ], + [], + "deref", + [] + |), + [ theta ] + |) + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let commit_values := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let values := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let max_bits := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "group::Curve", + Ty.associated, + [], + "to_affine", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::Params") + [ C ], + "commit_lagrange_with_bound", + [] + |), + [ + M.read (| params |); + M.read (| values |); + M.read (| max_bits |) + ] + |) + |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let compressed_input_expression := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ F; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ], + "call", + [] + |), + [ + compress_expressions; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::Argument", + "input_expressions" + |) + ] + |) + ] + ] + |) + |) in + let compressed_table_expression := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ F; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + ] + ], + "call", + [] + |), + [ + compress_expressions; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::Argument", + "table_expressions" + |) + ] + |) + ] + ] + |) + |) in + M.match_operator (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ F; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]; + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ F; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]; + Ty.path "usize"; + Ty.path "usize" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::lookup::prover::permute_expression_pair", + [ C; Ty.apply (Ty.path "&mut") [ R ] ] + |), + [ + M.read (| pk |); + M.read (| params |); + M.read (| domain |); + rng; + compressed_input_expression; + compressed_table_expression + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.apply (Ty.path "array") [ C ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_2 := M.SubPointer.get_tuple_field (| γ, 2 |) in + let γ0_3 := M.SubPointer.get_tuple_field (| γ, 3 |) in + let permuted_input_expression := M.copy (| γ0_0 |) in + let permuted_table_expression := M.copy (| γ0_1 |) in + let permuted_input_expression_max_bits := M.copy (| γ0_2 |) in + let permuted_table_expression_max_bits := M.copy (| γ0_3 |) in + let permuted_input_commitment := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ F; Ty.path "halo2_proofs::poly::LagrangeCoeff" ] + ]; + Ty.path "usize" + ] + ] + C, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ F; Ty.path "halo2_proofs::poly::LagrangeCoeff" ] + ]; + Ty.path "usize" + ] + ], + "call", + [] + |), + [ + commit_values; + Value.Tuple + [ + permuted_input_expression; + M.read (| permuted_input_expression_max_bits |) + ] + ] + |) + |) in + let permuted_table_commitment := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ F; Ty.path "halo2_proofs::poly::LagrangeCoeff" ] + ]; + Ty.path "usize" + ] + ] + C, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ F; Ty.path "halo2_proofs::poly::LagrangeCoeff" ] + ]; + Ty.path "usize" + ] + ], + "call", + [] + |), + [ + commit_values; + Value.Tuple + [ + permuted_table_expression; + M.read (| permuted_table_expression_max_bits |) + ] + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.Tuple + [ + Value.StructRecord + "halo2_proofs::plonk::lookup::prover::Permuted" + [ + ("compressed_input_expression", + M.read (| compressed_input_expression |)); + ("permuted_input_expression", + M.read (| permuted_input_expression |)); + ("compressed_table_expression", + M.read (| compressed_table_expression |)); + ("permuted_table_expression", + M.read (| permuted_table_expression |)) + ]; + Value.Array + [ + M.read (| permuted_input_commitment |); + M.read (| permuted_table_commitment |) + ] + ] + ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_commit_permuted : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "commit_permuted" (commit_permuted F). + End Impl_halo2_proofs_plonk_lookup_Argument_F. + + Module Impl_halo2_proofs_plonk_lookup_prover_Permuted_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::prover::Permuted") [ C ]. + + (* + pub(in crate::plonk) fn commit_product( + self, + pk: &ProvingKey, + params: &Params, + beta: ChallengeBeta, + gamma: ChallengeGamma, + ) -> Result< + ( + Polynomial, + Polynomial, + Vec, + ), + Error, + > { + let blinding_factors = pk.vk.cs.blinding_factors(); + + // Goal is to compute the products of fractions + // + // Numerator: (\theta^{m-1} a_0(\omega^i) + \theta^{m-2} a_1(\omega^i) + ... + \theta a_{m-2}(\omega^i) + a_{m-1}(\omega^i) + \beta) + // * (\theta^{m-1} s_0(\omega^i) + \theta^{m-2} s_1(\omega^i) + ... + \theta s_{m-2}(\omega^i) + s_{m-1}(\omega^i) + \gamma) + // Denominator: (a'(\omega^i) + \beta) (s'(\omega^i) + \gamma) + // + // where a_j(X) is the jth input expression in this lookup, + // where a'(X) is the compression of the permuted input expressions, + // s_j(X) is the jth table expression in this lookup, + // s'(X) is the compression of the permuted table expressions, + // and i is the ith row of the expression. + let mut lookup_product = vec![C::Scalar::zero(); params.n as usize]; + + #[cfg(not(feature = "cuda"))] + { + // Denominator uses the permuted input expression and permuted table expression + parallelize(&mut lookup_product, |lookup_product, start| { + for ((lookup_product, permuted_input_value), permuted_table_value) in lookup_product + .iter_mut() + .zip(self.permuted_input_expression[start..].iter()) + .zip(self.permuted_table_expression[start..].iter()) + { + *lookup_product = + ( *beta + permuted_input_value) * &( *gamma + permuted_table_value); + } + }); + + // Batch invert to obtain the denominators for the lookup product + // polynomials + batch_invert(&mut lookup_product); + + // Finish the computation of the entire fraction by computing the numerators + // (\theta^{m-1} a_0(\omega^i) + \theta^{m-2} a_1(\omega^i) + ... + \theta a_{m-2}(\omega^i) + a_{m-1}(\omega^i) + \beta) + // * (\theta^{m-1} s_0(\omega^i) + \theta^{m-2} s_1(\omega^i) + ... + \theta s_{m-2}(\omega^i) + s_{m-1}(\omega^i) + \gamma) + parallelize(&mut lookup_product, |product, start| { + for (i, product) in product.iter_mut().enumerate() { + let i = i + start; + + *product *= &(self.compressed_input_expression[i] + &*beta); + *product *= &(self.compressed_table_expression[i] + &*gamma); + } + }); + } + + // Denominator uses the permuted input expression and permuted table expression + for ((lookup_product, permuted_input_value), permuted_table_value) in lookup_product + .iter_mut() + .zip(self.permuted_input_expression.iter()) + .zip(self.permuted_table_expression.iter()) + { + *lookup_product = ( *beta + permuted_input_value) * &( *gamma + permuted_table_value); + } + + // Batch invert to obtain the denominators for the lookup product + // polynomials + lookup_product.batch_invert(); + + // Finish the computation of the entire fraction by computing the numerators + // (\theta^{m-1} a_0(\omega^i) + \theta^{m-2} a_1(\omega^i) + ... + \theta a_{m-2}(\omega^i) + a_{m-1}(\omega^i) + \beta) + // * (\theta^{m-1} s_0(\omega^i) + \theta^{m-2} s_1(\omega^i) + ... + \theta s_{m-2}(\omega^i) + s_{m-1}(\omega^i) + \gamma) + for ((lookup_product, compressed_input_value), compressed_table_value) in lookup_product + .iter_mut() + .zip(self.compressed_input_expression.iter()) + .zip(self.compressed_table_expression.iter()) + { + *lookup_product *= + ( *beta + compressed_input_value) * &( *gamma + compressed_table_value); + } + + /* + #[cfg(feature = "cuda")] + { + use ec_gpu_gen::fft::FftKernel; + use ec_gpu_gen::rust_gpu_tools::program_closures; + use ec_gpu_gen::rust_gpu_tools::Device; + use ec_gpu_gen::threadpool::Worker; + use ec_gpu_gen::EcResult; + use group::Curve; + use pairing::bn256::Fr; + + let device = Device::all()[_gpu_idx]; + let program = ec_gpu_gen::program!(device).expect("Cannot create programs!"); + let kern = FftKernel::::create(vec![program]).expect("Cannot initialize kernel!"); + + let compute_units = device.compute_units() as usize; + let local_work_size = 128usize; + let work_units = + (compute_units * local_work_size * 2) / local_work_size * local_work_size as usize; + let len = self.permuted_input_expression.len(); + let slot_len = ((len + work_units - 1) / work_units) as usize; + + let closures = program_closures!(|program, + input: (&[Fr], &[Fr], &[Fr], &[Fr], &mut [Fr])| + -> EcResult<()> { + let permuted_input = program.create_buffer_from_slice(input.0)?; + let permuted_table = program.create_buffer_from_slice(input.1)?; + let compressed_input = program.create_buffer_from_slice(input.2)?; + let compressed_table = program.create_buffer_from_slice(input.3)?; + let beta_gamma = program.create_buffer_from_slice(&vec![*beta, *gamma])?; + + let global_work_size = work_units / local_work_size; + + let kernel_name = format!("{}_calc_lookup_z", "Bn256_Fr"); + let kernel = program.create_kernel( + &kernel_name, + global_work_size as usize, + local_work_size as usize, + )?; + kernel + .arg(&permuted_input) + .arg(&permuted_table) + .arg(&compressed_input) + .arg(&compressed_table) + .arg(&beta_gamma) + .arg(&(len as u32)) + .arg(&(slot_len as u32)) + .run()?; + + let mut lookup_product_to_inv = vec![Fr::one(); params.n as usize]; + let mut lookup_product_to_inv_packed = vec![Fr::zero(); work_units]; + program.read_into_buffer(&permuted_input, input.4)?; + program.read_into_buffer(&permuted_table, &mut lookup_product_to_inv)?; + + for i in 0..work_units.min((len + slot_len - 1) / slot_len) { + lookup_product_to_inv_packed[i] = lookup_product_to_inv[i * slot_len]; + } + + lookup_product_to_inv_packed.iter_mut().batch_invert(); + + for (i, lookup_product_to_inv) in + lookup_product_to_inv_packed.into_iter().enumerate() + { + for j in i * slot_len..((i + 1) * slot_len).min(len) { + input.4[j] *= lookup_product_to_inv; + } + } + + Ok(()) + }); + + kern.kernels[0] + .program + .run(closures, unsafe { + ( + std::mem::transmute::<_, &[Fr]>(&self.permuted_input_expression[..]), + std::mem::transmute::<_, &[Fr]>(&self.permuted_table_expression[..]), + std::mem::transmute::<_, &[Fr]>(&self.compressed_input_expression[..]), + std::mem::transmute::<_, &[Fr]>(&self.compressed_table_expression[..]), + std::mem::transmute::<_, &mut [Fr]>(&mut lookup_product[..]), + ) + }) + .unwrap(); + } + */ + + // The product vector is a vector of products of fractions of the form + // + // Numerator: (\theta^{m-1} a_0(\omega^i) + \theta^{m-2} a_1(\omega^i) + ... + \theta a_{m-2}(\omega^i) + a_{m-1}(\omega^i) + \beta) + // * (\theta^{m-1} s_0(\omega^i) + \theta^{m-2} s_1(\omega^i) + ... + \theta s_{m-2}(\omega^i) + s_{m-1}(\omega^i) + \gamma) + // Denominator: (a'(\omega^i) + \beta) (s'(\omega^i) + \gamma) + // + // where there are m input expressions and m table expressions, + // a_j(\omega^i) is the jth input expression in this lookup, + // a'j(\omega^i) is the permuted input expression, + // s_j(\omega^i) is the jth table expression in this lookup, + // s'(\omega^i) is the permuted table expression, + // and i is the ith row of the expression. + // Compute the evaluations of the lookup product polynomial + // over our domain, starting with z[0] = 1 + let z = iter::once(C::Scalar::one()) + .chain(lookup_product) + .scan(C::Scalar::one(), |state, cur| { + *state *= &cur; + Some( *state) + }) + // Take all rows including the "last" row which should + // be a boolean (and ideally 1, else soundness is broken) + .take(params.n as usize - blinding_factors) + .collect::>(); + + #[cfg(feature = "sanity-checks")] + // This test works only with intermediate representations in this method. + // It can be used for debugging purposes. + { + // While in Lagrange basis, check that product is correctly constructed + let u = (params.n as usize) - (blinding_factors + 1); + + // l_0(X) * (1 - z(X)) = 0 + assert_eq!(z[0], C::Scalar::one()); + + // z(\omega X) (a'(X) + \beta) (s'(X) + \gamma) + // - z(X) (\theta^{m-1} a_0(X) + ... + a_{m-1}(X) + \beta) (\theta^{m-1} s_0(X) + ... + s_{m-1}(X) + \gamma) + for i in 0..u { + let mut left = z[i + 1]; + let permuted_input_value = &self.permuted_input_expression[i]; + + let permuted_table_value = &self.permuted_table_expression[i]; + + left *= &( *beta + permuted_input_value); + left *= &( *gamma + permuted_table_value); + + let mut right = z[i]; + let mut input_term = self.compressed_input_expression[i]; + let mut table_term = self.compressed_table_expression[i]; + + input_term += &( *beta); + table_term += &( *gamma); + right *= &(input_term * &table_term); + + assert_eq!(left, right); + } + + // l_last(X) * (z(X)^2 - z(X)) = 0 + // Assertion will fail only when soundness is broken, in which + // case this z[u] value will be zero. (bad!) + assert_eq!(z[u], C::Scalar::one()); + } + + Ok(( + self.permuted_input_expression, + self.permuted_table_expression, + z, + )) + } + *) + Definition commit_product (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; pk; params; beta; gamma ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let pk := M.alloc (| pk |) in + let params := M.alloc (| params |) in + let beta := M.alloc (| beta |) in + let gamma := M.alloc (| gamma |) in + M.read (| + let blinding_factors := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "blinding_factors", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |) + |) in + let lookup_product := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ Ty.associated ] |), + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "zero", [] |), + [] + |); + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)) + ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ lookup_product ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let lookup_product := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let start := M.copy (| γ |) in + M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.associated ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.associated ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.associated ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "iter_mut", + [] + |), + [ + M.read (| + lookup_product + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [ + Ty.apply + (Ty.path + "core::ops::range::RangeFrom") + [ Ty.path "usize" + ] + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::lookup::prover::Permuted", + "permuted_input_expression" + |); + Value.StructRecord + "core::ops::range::RangeFrom" + [ + ("start", + M.read (| + start + |)) + ] + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [ + Ty.apply + (Ty.path + "core::ops::range::RangeFrom") + [ Ty.path "usize" ] + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::lookup::prover::Permuted", + "permuted_table_expression" + |); + Value.StructRecord + "core::ops::range::RangeFrom" + [ + ("start", + M.read (| start |)) + ] + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.associated + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.associated ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let γ2_0 := + M.SubPointer.get_tuple_field (| + γ1_0, + 0 + |) in + let γ2_1 := + M.SubPointer.get_tuple_field (| + γ1_0, + 1 + |) in + let lookup_product := + M.copy (| γ2_0 |) in + let + permuted_input_value := + M.copy (| γ2_1 |) in + let + permuted_table_value := + M.copy (| γ1_1 |) in + let _ := + M.write (| + M.read (| + lookup_product + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "add", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Beta" + ], + [], + "deref", + [] + |), + [ beta ] + |) + |); + M.read (| + permuted_input_value + |) + ] + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "add", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Gamma" + ], + [], + "deref", + [] + |), + [ + gamma + ] + |) + |); + M.read (| + permuted_table_value + |) + ] + |) + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::batch_invert", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ lookup_product ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ lookup_product ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let product := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let start := M.copy (| γ |) in + M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "iter_mut", + [] + |), + [ M.read (| product |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let i := + M.copy (| γ1_0 |) in + let product := + M.copy (| γ1_1 |) in + let i := + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.read (| i |), + M.read (| start |) + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "mul_assign", + [] + |), + [ + M.read (| + product + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "add", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::lookup::prover::Permuted", + "compressed_input_expression" + |); + M.read (| + i + |) + ] + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Beta" + ], + [], + "deref", + [] + |), + [ beta ] + |) + ] + |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "mul_assign", + [] + |), + [ + M.read (| + product + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "add", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::lookup::prover::Permuted", + "compressed_table_expression" + |); + M.read (| + i + |) + ] + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Gamma" + ], + [], + "deref", + [] + |), + [ gamma + ] + |) + ] + |) + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ]; + Ty.associated + ]; + Ty.associated + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ]; + Ty.associated + ], + [], + "zip", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "zip", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ lookup_product ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ], + "iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::lookup::prover::Permuted", + "permuted_input_expression" + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" + ], + "iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::lookup::prover::Permuted", + "permuted_table_expression" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ]; + Ty.associated + ]; + Ty.associated + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let γ2_0 := M.SubPointer.get_tuple_field (| γ1_0, 0 |) in + let γ2_1 := M.SubPointer.get_tuple_field (| γ1_0, 1 |) in + let lookup_product := M.copy (| γ2_0 |) in + let permuted_input_value := M.copy (| γ2_1 |) in + let permuted_table_value := M.copy (| γ1_1 |) in + let _ := + M.write (| + M.read (| lookup_product |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "add", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path "halo2_proofs::plonk::Beta" + ], + [], + "deref", + [] + |), + [ beta ] + |) + |); + M.read (| permuted_input_value |) + ] + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] + ], + "add", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Gamma" + ], + [], + "deref", + [] + |), + [ gamma ] + |) + |); + M.read (| permuted_table_value |) + ] + |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::batch::BatchInvert", + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ], + [ Ty.associated ], + "batch_invert", + [] + |), + [ lookup_product ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ]; + Ty.associated + ]; + Ty.associated + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ]; + Ty.associated + ], + [], + "zip", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "zip", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ lookup_product ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ], + "iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::lookup::prover::Permuted", + "compressed_input_expression" + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" + ], + "iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::lookup::prover::Permuted", + "compressed_table_expression" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ]; + Ty.associated + ]; + Ty.associated + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let γ2_0 := M.SubPointer.get_tuple_field (| γ1_0, 0 |) in + let γ2_1 := M.SubPointer.get_tuple_field (| γ1_0, 1 |) in + let lookup_product := M.copy (| γ2_0 |) in + let compressed_input_value := M.copy (| γ2_1 |) in + let compressed_table_value := M.copy (| γ1_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ Ty.associated ], + "mul_assign", + [] + |), + [ + M.read (| lookup_product |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] + ], + "add", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Beta" + ], + [], + "deref", + [] + |), + [ beta ] + |) + |); + M.read (| compressed_input_value |) + ] + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ], + "add", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Gamma" + ], + [], + "deref", + [] + |), + [ gamma ] + |) + |); + M.read (| compressed_table_value |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let z := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::take::Take") + [ + Ty.apply + (Ty.path "core::iter::adapters::scan::Scan") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::once::Once") + [ Ty.associated ]; + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ Ty.apply (Ty.path "&mut") [ Ty.associated ]; Ty.associated ] + ] + (Ty.apply (Ty.path "core::option::Option") [ Ty.associated ]) + ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::scan::Scan") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::once::Once") + [ Ty.associated ]; + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ Ty.apply (Ty.path "&mut") [ Ty.associated ]; Ty.associated ] + ] + (Ty.apply (Ty.path "core::option::Option") [ Ty.associated ]) + ], + [], + "take", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::once::Once") + [ Ty.associated ]; + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ], + [], + "scan", + [ + Ty.associated; + Ty.associated; + Ty.function + [ + Ty.tuple + [ Ty.apply (Ty.path "&mut") [ Ty.associated ]; Ty.associated + ] + ] + (Ty.apply (Ty.path "core::option::Option") [ Ty.associated ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::sources::once::Once") + [ Ty.associated ], + [], + "chain", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "core::iter::sources::once::once", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |) + ] + |); + M.read (| lookup_product |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let state := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let cur := M.copy (| γ |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ], + "mul_assign", + [] + |), + [ M.read (| state |); cur ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ M.read (| M.read (| state |) |) ] + |) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + BinOp.Panic.sub (| + Integer.Usize, + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)), + M.read (| blinding_factors |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.Tuple + [ + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::lookup::prover::Permuted", + "permuted_input_expression" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::lookup::prover::Permuted", + "permuted_table_expression" + |) + |); + M.read (| z |) + ] + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_commit_product : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "commit_product" (commit_product C). + End Impl_halo2_proofs_plonk_lookup_prover_Permuted_C. + + Module Impl_halo2_proofs_plonk_lookup_prover_Committed_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::prover::Committed") [ C ]. + + (* + pub(in crate::plonk) fn evaluate( + self, + pk: &ProvingKey, + x: ChallengeX, + ) -> (Evaluated, Vec) { + let domain = &pk.vk.domain; + let x_inv = domain.rotate_omega( *x, Rotation::prev()); + let x_next = domain.rotate_omega( *x, Rotation::next()); + + let evals = vec![ + (&self.product_poly, *x), + (&self.product_poly, x_next), + (&self.permuted_input_poly, *x), + (&self.permuted_input_poly, x_inv), + (&self.permuted_table_poly, *x), + ] + .into_par_iter() + .map(|(a, b)| eval_polynomial_st(a, b)) + .collect(); + + (Evaluated { constructed: self }, evals) + } + *) + Definition evaluate (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; pk; x ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let pk := M.alloc (| pk |) in + let x := M.alloc (| x |) in + M.read (| + let domain := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + |) in + let x_inv := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "rotate_omega", + [] + |), + [ + M.read (| domain |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "prev", + [] + |), + [] + |) + ] + |) + |) in + let x_next := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "rotate_omega", + [] + |), + [ + M.read (| domain |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "next", + [] + |), + [] + |) + ] + |) + |) in + let evals := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path "rayon::vec::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ]; + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ]; + Ty.associated + ] + ] + ] + Ty.associated + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::vec::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ]; + Ty.associated + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ] + ] + ] + Ty.associated; + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ]; + Ty.associated + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_par_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::lookup::prover::Committed", + "product_poly" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ x ] + |) + |) + ]; + Value.Tuple + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::lookup::prover::Committed", + "product_poly" + |); + M.read (| x_next |) + ]; + Value.Tuple + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::lookup::prover::Committed", + "permuted_input_poly" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ x ] + |) + |) + ]; + Value.Tuple + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::lookup::prover::Committed", + "permuted_input_poly" + |); + M.read (| x_inv |) + ]; + Value.Tuple + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::lookup::prover::Committed", + "permuted_table_poly" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ x ] + |) + |) + ] + ] + |) + ] + |) + |)) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let a := M.copy (| γ0_0 |) in + let b := M.copy (| γ0_1 |) in + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::eval_polynomial_st", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ], + [], + "deref", + [] + |), + [ M.read (| a |) ] + |); + M.read (| b |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [ + Value.StructRecord + "halo2_proofs::plonk::lookup::prover::Evaluated" + [ ("constructed", M.read (| self |)) ]; + M.read (| evals |) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_evaluate : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "evaluate" (evaluate C). + End Impl_halo2_proofs_plonk_lookup_prover_Committed_C. + + Module Impl_halo2_proofs_plonk_lookup_prover_Evaluated_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::prover::Evaluated") [ C ]. + + (* + pub(in crate::plonk) fn open<'a>( + &'a self, + pk: &'a ProvingKey, + x: ChallengeX, + ) -> impl Iterator> + Clone { + let x_inv = pk.vk.domain.rotate_omega( *x, Rotation::prev()); + let x_next = pk.vk.domain.rotate_omega( *x, Rotation::next()); + + iter::empty() + // Open lookup product commitments at x + .chain(Some(ProverQuery { + point: *x, + rotation: Rotation::cur(), + poly: &self.constructed.product_poly, + })) + // Open lookup input commitments at x + .chain(Some(ProverQuery { + point: *x, + rotation: Rotation::cur(), + poly: &self.constructed.permuted_input_poly, + })) + // Open lookup table commitments at x + .chain(Some(ProverQuery { + point: *x, + rotation: Rotation::cur(), + poly: &self.constructed.permuted_table_poly, + })) + // Open lookup input commitments at x_inv + .chain(Some(ProverQuery { + point: x_inv, + rotation: Rotation::prev(), + poly: &self.constructed.permuted_input_poly, + })) + // Open lookup product commitments at x_next + .chain(Some(ProverQuery { + point: x_next, + rotation: Rotation::next(), + poly: &self.constructed.product_poly, + })) + } + *) + Definition open (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; pk; x ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let pk := M.alloc (| pk |) in + let x := M.alloc (| x |) in + M.read (| + let x_inv := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "rotate_omega", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "prev", + [] + |), + [] + |) + ] + |) + |) in + let x_next := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "rotate_omega", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "next", + [] + |), + [] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") [ C ] + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") [ C ] ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "core::iter::sources::empty::empty", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + |), + [] + |); + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "halo2_proofs::poly::multiopen::ProverQuery" + [ + ("point", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |)); + ("rotation", + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |)); + ("poly", + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::prover::Evaluated", + "constructed" + |), + "halo2_proofs::plonk::lookup::prover::Committed", + "product_poly" + |)) + ] + ] + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "halo2_proofs::poly::multiopen::ProverQuery" + [ + ("point", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |)); + ("rotation", + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |)); + ("poly", + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::prover::Evaluated", + "constructed" + |), + "halo2_proofs::plonk::lookup::prover::Committed", + "permuted_input_poly" + |)) + ] + ] + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "halo2_proofs::poly::multiopen::ProverQuery" + [ + ("point", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |)); + ("rotation", + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |)); + ("poly", + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::prover::Evaluated", + "constructed" + |), + "halo2_proofs::plonk::lookup::prover::Committed", + "permuted_table_poly" + |)) + ] + ] + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "halo2_proofs::poly::multiopen::ProverQuery" + [ + ("point", M.read (| x_inv |)); + ("rotation", + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "prev", + [] + |), + [] + |)); + ("poly", + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::prover::Evaluated", + "constructed" + |), + "halo2_proofs::plonk::lookup::prover::Committed", + "permuted_input_poly" + |)) + ] + ] + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "halo2_proofs::poly::multiopen::ProverQuery" + [ + ("point", M.read (| x_next |)); + ("rotation", + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "next", + [] + |), + [] + |)); + ("poly", + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::prover::Evaluated", + "constructed" + |), + "halo2_proofs::plonk::lookup::prover::Committed", + "product_poly" + |)) + ] + ] + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_open : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "open" (open C). + End Impl_halo2_proofs_plonk_lookup_prover_Evaluated_C. + + Axiom ExpressionPair : + forall (F : Ty.t), + (Ty.apply (Ty.path "halo2_proofs::plonk::lookup::prover::ExpressionPair") [ F ]) = + (Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ F; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]; + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ F; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]; + Ty.path "usize"; + Ty.path "usize" + ]). + + (* + fn sort_get_max(value: &mut Vec) -> F { + let max = *value.iter().reduce(|a, b| a.max(b)).unwrap(); + + value.sort_unstable_by(|a, b| unsafe { + let a: &[u64; 4] = std::mem::transmute(a); + let b: &[u64; 4] = std::mem::transmute(b); + a.cmp(b) + }); + + max + } + *) + Definition sort_get_max (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ value ] => + ltac:(M.monadic + (let value := M.alloc (| value |) in + M.read (| + let max := + M.copy (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.apply (Ty.path "&") [ F ] ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ F ], + [], + "reduce", + [ + Ty.function + [ + Ty.tuple + [ Ty.apply (Ty.path "&") [ F ]; Ty.apply (Ty.path "&") [ F ] ] + ] + (Ty.apply (Ty.path "&") [ F ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ M.read (| value |) ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let b := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.apply (Ty.path "&") [ F ], + [], + "max", + [] + |), + [ M.read (| a |); M.read (| b |) ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "sort_unstable_by", + [ + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ F ]; Ty.apply (Ty.path "&") [ F ] ] + ] + (Ty.path "core::cmp::Ordering") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ M.read (| value |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let b := M.copy (| γ |) in + M.read (| + let a := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::transmute", + [ + Ty.apply (Ty.path "&") [ F ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "u64" ] + ] + ] + |), + [ M.read (| a |) ] + |) + |) in + let b := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::transmute", + [ + Ty.apply (Ty.path "&") [ F ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "u64" ] + ] + ] + |), + [ M.read (| b |) ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.apply (Ty.path "array") [ Ty.path "u64" ], + [], + "cmp", + [] + |), + [ M.read (| a |); M.read (| b |) ] + |) + |) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + max + |))) + | _, _ => M.impossible + end. + + (* + fn permute_expression_pair( + pk: &ProvingKey, + params: &Params, + domain: &EvaluationDomain, + mut rng: R, + input_expression: &Polynomial, + table_expression: &Polynomial, + ) -> Result, Error> { + let blinding_factors = pk.vk.cs.blinding_factors(); + let usable_rows = params.n as usize - (blinding_factors + 1); + + let mut permuted_input_expression: Vec = input_expression.to_vec(); + permuted_input_expression.truncate(usable_rows); + + let mut sorted_table_coeffs = table_expression.to_vec(); + sorted_table_coeffs.truncate(usable_rows); + + let max_input = sort_get_max(&mut permuted_input_expression); + let max_table = sort_get_max(&mut sorted_table_coeffs); + + let mut permuted_table_coeffs = vec![None; usable_rows]; + + let unique_input_values = permuted_input_expression + .iter() + .zip(permuted_table_coeffs.iter_mut()) + .enumerate() + .filter_map(|(row, (input_value, table_value))| { + // If this is the first occurrence of `input_value` in the input expression + if row == 0 || *input_value != permuted_input_expression[row - 1] { + *table_value = Some( *input_value); + Some( *input_value) + } else { + None + } + }) + .collect::>(); + + let mut i_unique_input_value = 0; + let mut i_sorted_table_coeffs = 0; + for v in permuted_table_coeffs.iter_mut() { + while i_unique_input_value < unique_input_values.len() + && unique_input_values[i_unique_input_value] + == sorted_table_coeffs[i_sorted_table_coeffs] + { + i_unique_input_value += 1; + i_sorted_table_coeffs += 1; + } + if v.is_none() { + *v = Some(sorted_table_coeffs[i_sorted_table_coeffs]); + i_sorted_table_coeffs += 1; + } + } + + while i_unique_input_value < unique_input_values.len() + && unique_input_values[i_unique_input_value] == sorted_table_coeffs[i_sorted_table_coeffs] + { + i_unique_input_value += 1; + i_sorted_table_coeffs += 1; + } + + //assert!(i_unique_input_value == unique_input_values.len()); + + let mut permuted_table_coeffs = permuted_table_coeffs + .iter() + .filter_map(|x| *x) + .collect::>(); + + permuted_input_expression + .extend((0..(blinding_factors + 1)).map(|_| C::Scalar::from(u16::rand(&mut rng) as u64))); + permuted_table_coeffs + .extend((0..(blinding_factors + 1)).map(|_| C::Scalar::from(u16::rand(&mut rng) as u64))); + assert_eq!(permuted_input_expression.len(), params.n as usize); + assert_eq!(permuted_table_coeffs.len(), params.n as usize); + + #[cfg(feature = "sanity-checks")] + { + let mut last = None; + for (a, b) in permuted_input_expression + .iter() + .zip(permuted_table_coeffs.iter()) + .take(usable_rows) + { + if *a != *b { + assert_eq!( *a, last.unwrap()); + } + last = Some( *a); + } + } + + let get_scalar_bits = |x: C::Scalar| { + let repr = x.to_repr(); + let max_scalar_repr_ref: &[u8] = repr.as_ref(); + max_scalar_repr_ref + .iter() + .enumerate() + .fold(0, |acc, (idx, v)| { + if *v == 0 { + acc + } else { + idx * 8 + 8 - v.leading_zeros() as usize + } + }) + }; + + Ok(( + domain.lagrange_from_vec(permuted_input_expression), + domain.lagrange_from_vec(permuted_table_coeffs), + 16.max(get_scalar_bits(max_input)), + 16.max(get_scalar_bits(max_table)), + )) + } + *) + Definition permute_expression_pair (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; R ], [ pk; params; domain; rng; input_expression; table_expression ] => + ltac:(M.monadic + (let pk := M.alloc (| pk |) in + let params := M.alloc (| params |) in + let domain := M.alloc (| domain |) in + let rng := M.alloc (| rng |) in + let input_expression := M.alloc (| input_expression |) in + let table_expression := M.alloc (| table_expression |) in + M.read (| + let blinding_factors := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "blinding_factors", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |) + |) in + let usable_rows := + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)), + BinOp.Panic.add (| + Integer.Usize, + M.read (| blinding_factors |), + Value.Integer 1 + |) + |) + |) in + let permuted_input_expression := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "to_vec", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ], + [], + "deref", + [] + |), + [ M.read (| input_expression |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "truncate", + [] + |), + [ permuted_input_expression; M.read (| usable_rows |) ] + |) + |) in + let sorted_table_coeffs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "to_vec", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ], + [], + "deref", + [] + |), + [ M.read (| table_expression |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "truncate", + [] + |), + [ sorted_table_coeffs; M.read (| usable_rows |) ] + |) + |) in + let max_input := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::lookup::prover::sort_get_max", + [ Ty.associated ] + |), + [ permuted_input_expression ] + |) + |) in + let max_table := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::lookup::prover::sort_get_max", + [ Ty.associated ] + |), + [ sorted_table_coeffs ] + |) + |) in + let permuted_table_coeffs := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ Ty.apply (Ty.path "core::option::Option") [ Ty.associated ] ] + |), + [ Value.StructTuple "core::option::Option::None" []; M.read (| usable_rows |) ] + |) + |) in + let unique_input_values := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.associated ]; + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.associated ] ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.associated ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.associated ] + ] + ] + ] + ] + ] + (Ty.apply (Ty.path "core::option::Option") [ Ty.associated ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.associated ]; + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.associated ] ] + ] + ], + [], + "filter_map", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.associated ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.associated ] + ] + ] + ] + ] + ] + (Ty.apply (Ty.path "core::option::Option") [ Ty.associated ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.associated ]; + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.associated ] ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.associated ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.associated ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ permuted_input_expression ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.associated ] + ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ permuted_table_coeffs ] + |) + ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let row := M.copy (| γ0_0 |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_1, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_1, 1 |) in + let input_value := M.copy (| γ1_0 |) in + let table_value := M.copy (| γ1_1 |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.or (| + BinOp.Pure.eq + (M.read (| row |)) + (Value.Integer 0), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ Ty.associated ], + "ne", + [] + |), + [ + M.read (| input_value |); + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + permuted_input_expression; + BinOp.Panic.sub (| + Integer.Usize, + M.read (| row |), + Value.Integer 1 + |) + ] + |) + ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.write (| + M.read (| table_value |), + Value.StructTuple + "core::option::Option::Some" + [ M.read (| M.read (| input_value |) |) ] + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ M.read (| M.read (| input_value |) |) ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let i_unique_input_value := M.alloc (| Value.Integer 0 |) in + let i_sorted_table_coeffs := M.alloc (| Value.Integer 0 |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.associated ] ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.associated ] ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "core::option::Option") [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ permuted_table_coeffs ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.associated ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let v := M.copy (| γ0_0 |) in + let _ := + M.loop (| + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + BinOp.Pure.lt + (M.read (| i_unique_input_value |)) + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ unique_input_values ] + |)), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ Ty.associated ], + "eq", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + unique_input_values; + M.read (| + i_unique_input_value + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + sorted_table_coeffs; + M.read (| + i_sorted_table_coeffs + |) + ] + |) + ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + let β := i_unique_input_value in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |) in + let _ := + let β := i_sorted_table_coeffs in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + let _ := + M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |) in + M.alloc (| Value.Tuple [] |) + |) + |) + |))) + ] + |))) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.associated ], + "is_none", + [] + |), + [ M.read (| v |) ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.write (| + M.read (| v |), + Value.StructTuple + "core::option::Option::Some" + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + sorted_table_coeffs; + M.read (| i_sorted_table_coeffs |) + ] + |) + |) + ] + |) in + let _ := + let β := i_sorted_table_coeffs in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.loop (| + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + BinOp.Pure.lt + (M.read (| i_unique_input_value |)) + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ unique_input_values ] + |)), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ Ty.associated ], + "eq", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ Ty.path "usize" ], + "index", + [] + |), + [ unique_input_values; M.read (| i_unique_input_value |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + sorted_table_coeffs; + M.read (| i_sorted_table_coeffs |) + ] + |) + ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let _ := + let β := i_unique_input_value in + M.write (| + β, + BinOp.Panic.add (| Integer.Usize, M.read (| β |), Value.Integer 1 |) + |) in + let _ := + let β := i_sorted_table_coeffs in + M.write (| + β, + BinOp.Panic.add (| Integer.Usize, M.read (| β |), Value.Integer 1 |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + let _ := + M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |) in + M.alloc (| Value.Tuple [] |) + |) + |) + |))) + ] + |))) + |) in + let permuted_table_coeffs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.associated ] ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.associated ] ] + ] + ] + (Ty.apply (Ty.path "core::option::Option") [ Ty.associated ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.associated ] ], + [], + "filter_map", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.associated ] + ] + ] + ] + (Ty.apply (Ty.path "core::option::Option") [ Ty.associated ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.associated ] ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "core::option::Option") [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ permuted_table_coeffs ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.read (| M.read (| x |) |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::Extend", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ Ty.associated ], + "extend", + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ]; + Ty.function [ Ty.tuple [ Ty.path "usize" ] ] Ty.associated + ] + ] + |), + [ + permuted_input_expression; + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "map", + [ + Ty.associated; + Ty.function [ Ty.tuple [ Ty.path "usize" ] ] Ty.associated + ] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + BinOp.Panic.add (| + Integer.Usize, + M.read (| blinding_factors |), + Value.Integer 1 + |)) + ]; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.associated, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_trait_method (| + "ark_std::rand_helper::UniformRand", + Ty.path "u16", + [], + "rand", + [ R ] + |), + [ rng ] + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::Extend", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ Ty.associated ], + "extend", + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ]; + Ty.function [ Ty.tuple [ Ty.path "usize" ] ] Ty.associated + ] + ] + |), + [ + permuted_table_coeffs; + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "map", + [ + Ty.associated; + Ty.function [ Ty.tuple [ Ty.path "usize" ] ] Ty.associated + ] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + BinOp.Panic.add (| + Integer.Usize, + M.read (| blinding_factors |), + Value.Integer 1 + |)) + ]; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.associated, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_trait_method (| + "ark_std::rand_helper::UniformRand", + Ty.path "u16", + [], + "rand", + [ R ] + |), + [ rng ] + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ permuted_input_expression ] + |) + |); + M.alloc (| + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ permuted_table_coeffs ] + |) + |); + M.alloc (| + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let get_scalar_bits := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.read (| + let repr := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::PrimeField", + Ty.associated, + [], + "to_repr", + [] + |), + [ x ] + |) + |) in + let max_scalar_repr_ref := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_ref", + [] + |), + [ repr ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "u8" ] + ], + [], + "fold", + [ + Ty.path "usize"; + Ty.function + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.tuple + [ + Ty.path "usize"; + Ty.apply (Ty.path "&") [ Ty.path "u8" ] + ] + ] + ] + (Ty.path "usize") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "u8" ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u8" ], + "iter", + [] + |), + [ M.read (| max_scalar_repr_ref |) ] + |) + ] + |); + Value.Integer 0; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let idx := M.copy (| γ0_0 |) in + let v := M.copy (| γ0_1 |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| + M.read (| v |) + |)) + (Value.Integer + 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + acc)); + fun γ => + ltac:(M.monadic + (M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.mul (| + Integer.Usize, + M.read (| + idx + |), + Value.Integer 8 + |), + Value.Integer 8 + |), + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path "u8", + "leading_zeros", + [] + |), + [ + M.read (| + M.read (| + v + |) + |) + ] + |)) + |) + |))) + ] + |) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "lagrange_from_vec", + [] + |), + [ M.read (| domain |); M.read (| permuted_input_expression |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "lagrange_from_vec", + [] + |), + [ M.read (| domain |); M.read (| permuted_table_coeffs |) ] + |); + M.call_closure (| + M.get_trait_method (| "core::cmp::Ord", Ty.path "usize", [], "max", [] |), + [ + Value.Integer 16; + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function [ Ty.tuple [ Ty.associated ] ] (Ty.path "usize"), + [ Ty.tuple [ Ty.associated ] ], + "call", + [] + |), + [ get_scalar_bits; Value.Tuple [ M.read (| max_input |) ] ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| "core::cmp::Ord", Ty.path "usize", [], "max", [] |), + [ + Value.Integer 16; + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function [ Ty.tuple [ Ty.associated ] ] (Ty.path "usize"), + [ Ty.tuple [ Ty.associated ] ], + "call", + [] + |), + [ get_scalar_bits; Value.Tuple [ M.read (| max_table |) ] ] + |) + ] + |) + ] + ] + |) + |))) + | _, _ => M.impossible + end. + End prover. + End lookup. +End plonk. diff --git a/CoqOfRust/halo2_proofs/plonk/lookup/verifier.v b/CoqOfRust/halo2_proofs/plonk/lookup/verifier.v new file mode 100644 index 000000000..e943070a4 --- /dev/null +++ b/CoqOfRust/halo2_proofs/plonk/lookup/verifier.v @@ -0,0 +1,3520 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module plonk. + Module lookup. + Module verifier. + (* StructRecord + { + name := "PermutationCommitments"; + ty_params := [ "C" ]; + fields := [ ("permuted_input_commitment", C); ("permuted_table_commitment", C) ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_plonk_lookup_verifier_PermutationCommitments_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "PermutationCommitments" |); + M.read (| Value.String "permuted_input_commitment" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments", + "permuted_input_commitment" + |)); + M.read (| Value.String "permuted_table_commitment" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments", + "permuted_table_commitment" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_plonk_lookup_verifier_PermutationCommitments_C. + + (* StructRecord + { + name := "Committed"; + ty_params := [ "C" ]; + fields := + [ + ("permuted", + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ C ]); + ("product_commitment", C) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_plonk_lookup_verifier_Committed_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::verifier::Committed") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Committed" |); + M.read (| Value.String "permuted" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Committed", + "permuted" + |)); + M.read (| Value.String "product_commitment" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Committed", + "product_commitment" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_plonk_lookup_verifier_Committed_C. + + (* StructRecord + { + name := "Evaluated"; + ty_params := [ "C" ]; + fields := + [ + ("committed", + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::verifier::Committed") [ C ]); + ("product_eval", Ty.associated); + ("product_next_eval", Ty.associated); + ("permuted_input_eval", Ty.associated); + ("permuted_input_inv_eval", Ty.associated); + ("permuted_table_eval", Ty.associated) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_lookup_verifier_Evaluated_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::verifier::Evaluated") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let names := + M.alloc (| + M.alloc (| + Value.Array + [ + M.read (| Value.String "committed" |); + M.read (| Value.String "product_eval" |); + M.read (| Value.String "product_next_eval" |); + M.read (| Value.String "permuted_input_eval" |); + M.read (| Value.String "permuted_input_inv_eval" |); + M.read (| Value.String "permuted_table_eval" |) + ] + |) + |) in + let values := + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "committed" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "product_eval" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "product_next_eval" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "permuted_input_eval" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "permuted_input_inv_eval" + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "permuted_table_eval" + |) + |)) + ] + |)) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_fields_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Evaluated" |); + (* Unsize *) M.pointer_coercion (M.read (| names |)); + M.read (| values |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_lookup_verifier_Evaluated_C. + + Module Impl_halo2_proofs_plonk_lookup_Argument_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::Argument") [ F ]. + + (* + pub fn read_permuted_commitments< + C: CurveAffine, + E: EncodedChallenge, + T: TranscriptRead, + >( + &self, + transcript: &mut T, + ) -> Result, Error> { + let permuted_input_commitment = transcript.read_point()?; + let permuted_table_commitment = transcript.read_point()?; + + Ok(PermutationCommitments { + permuted_input_commitment, + permuted_table_commitment, + }) + } + *) + Definition read_permuted_commitments (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ C; E; T ], [ self; transcript ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let transcript := M.alloc (| transcript |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let permuted_input_commitment := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptRead", + T, + [ C; E ], + "read_point", + [] + |), + [ M.read (| transcript |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let permuted_table_commitment := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptRead", + T, + [ C; E ], + "read_point", + [] + |), + [ M.read (| transcript |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments" + [ + ("permuted_input_commitment", M.read (| permuted_input_commitment |)); + ("permuted_table_commitment", M.read (| permuted_table_commitment |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_read_permuted_commitments : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "read_permuted_commitments" (read_permuted_commitments F). + End Impl_halo2_proofs_plonk_lookup_Argument_F. + + Module Impl_halo2_proofs_plonk_lookup_verifier_PermutationCommitments_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") [ C ]. + + (* + pub fn read_product_commitment, T: TranscriptRead>( + self, + transcript: &mut T, + ) -> Result, Error> { + let product_commitment = transcript.read_point()?; + + Ok(Committed { + permuted: self, + product_commitment, + }) + } + *) + Definition read_product_commitment (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ E; T ], [ self; transcript ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let transcript := M.alloc (| transcript |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let product_commitment := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptRead", + T, + [ C; E ], + "read_point", + [] + |), + [ M.read (| transcript |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::lookup::verifier::Committed" + [ + ("permuted", M.read (| self |)); + ("product_commitment", M.read (| product_commitment |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_read_product_commitment : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "read_product_commitment" (read_product_commitment C). + End Impl_halo2_proofs_plonk_lookup_verifier_PermutationCommitments_C. + + Module Impl_halo2_proofs_plonk_lookup_verifier_Committed_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::verifier::Committed") [ C ]. + + (* + pub fn evaluate, T: TranscriptRead>( + self, + transcript: &mut T, + ) -> Result, Error> { + let product_eval = transcript.read_scalar()?; + let product_next_eval = transcript.read_scalar()?; + let permuted_input_eval = transcript.read_scalar()?; + let permuted_input_inv_eval = transcript.read_scalar()?; + let permuted_table_eval = transcript.read_scalar()?; + + Ok(Evaluated { + committed: self, + product_eval, + product_next_eval, + permuted_input_eval, + permuted_input_inv_eval, + permuted_table_eval, + }) + } + *) + Definition evaluate (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ E; T ], [ self; transcript ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let transcript := M.alloc (| transcript |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let product_eval := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptRead", + T, + [ C; E ], + "read_scalar", + [] + |), + [ M.read (| transcript |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let product_next_eval := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptRead", + T, + [ C; E ], + "read_scalar", + [] + |), + [ M.read (| transcript |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let permuted_input_eval := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptRead", + T, + [ C; E ], + "read_scalar", + [] + |), + [ M.read (| transcript |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let permuted_input_inv_eval := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptRead", + T, + [ C; E ], + "read_scalar", + [] + |), + [ M.read (| transcript |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let permuted_table_eval := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptRead", + T, + [ C; E ], + "read_scalar", + [] + |), + [ M.read (| transcript |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::lookup::verifier::Evaluated" + [ + ("committed", M.read (| self |)); + ("product_eval", M.read (| product_eval |)); + ("product_next_eval", M.read (| product_next_eval |)); + ("permuted_input_eval", M.read (| permuted_input_eval |)); + ("permuted_input_inv_eval", M.read (| permuted_input_inv_eval |)); + ("permuted_table_eval", M.read (| permuted_table_eval |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_evaluate : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "evaluate" (evaluate C). + End Impl_halo2_proofs_plonk_lookup_verifier_Committed_C. + + Module Impl_halo2_proofs_plonk_lookup_verifier_Evaluated_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::lookup::verifier::Evaluated") [ C ]. + + (* + pub(in crate::plonk) fn expressions<'a>( + &'a self, + l_0: C::Scalar, + l_last: C::Scalar, + l_blind: C::Scalar, + argument: &'a Argument, + theta: ChallengeTheta, + beta: ChallengeBeta, + gamma: ChallengeGamma, + advice_evals: &[C::Scalar], + fixed_evals: &[C::Scalar], + instance_evals: &[C::Scalar], + ) -> impl Iterator + 'a { + let active_rows = C::Scalar::one() - (l_last + l_blind); + + let product_expression = || { + // z(\omega X) (a'(X) + \beta) (s'(X) + \gamma) + // - z(X) (\theta^{m-1} a_0(X) + ... + a_{m-1}(X) + \beta) (\theta^{m-1} s_0(X) + ... + s_{m-1}(X) + \gamma) + let left = self.product_next_eval + * &(self.permuted_input_eval + &*beta) + * &(self.permuted_table_eval + &*gamma); + + let compress_expressions = |expressions: &[Expression]| { + expressions + .iter() + .map(|expression| { + expression.evaluate( + &|scalar| scalar, + &|_| panic!("virtual selectors are removed during optimization"), + &|index, _, _| fixed_evals[index], + &|index, _, _| advice_evals[index], + &|index, _, _| instance_evals[index], + &|a| -a, + &|a, b| a + &b, + &|a, b| a() * &b(), + &|a, scalar| a * &scalar, + ) + }) + .fold(C::Scalar::zero(), |acc, eval| acc * &*theta + &eval) + }; + let right = self.product_eval + * &(compress_expressions(&argument.input_expressions) + &*beta) + * &(compress_expressions(&argument.table_expressions) + &*gamma); + + (left - &right) * &active_rows + }; + + std::iter::empty() + .chain( + // l_0(X) * (1 - z'(X)) = 0 + Some(l_0 * &(C::Scalar::one() - &self.product_eval)), + ) + .chain( + // l_last(X) * (z(X)^2 - z(X)) = 0 + Some(l_last * &(self.product_eval.square() - &self.product_eval)), + ) + .chain( + // (1 - (l_last(X) + l_blind(X))) * ( + // z(\omega X) (a'(X) + \beta) (s'(X) + \gamma) + // - z(X) (\theta^{m-1} a_0(X) + ... + a_{m-1}(X) + \beta) (\theta^{m-1} s_0(X) + ... + s_{m-1}(X) + \gamma) + // ) = 0 + Some(product_expression()), + ) + .chain(Some( + // l_0(X) * (a'(X) - s'(X)) = 0 + l_0 * &(self.permuted_input_eval - &self.permuted_table_eval), + )) + .chain(Some( + // (1 - (l_last(X) + l_blind(X))) * (a′(X) − s′(X))⋅(a′(X) − a′(\omega^{-1} X)) = 0 + (self.permuted_input_eval - &self.permuted_table_eval) + * &(self.permuted_input_eval - &self.permuted_input_inv_eval) + * &active_rows, + )) + } + *) + Definition expressions (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], + [ + self; + l_0; + l_last; + l_blind; + argument; + theta; + beta; + gamma; + advice_evals; + fixed_evals; + instance_evals + ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let l_0 := M.alloc (| l_0 |) in + let l_last := M.alloc (| l_last |) in + let l_blind := M.alloc (| l_blind |) in + let argument := M.alloc (| argument |) in + let theta := M.alloc (| theta |) in + let beta := M.alloc (| beta |) in + let gamma := M.alloc (| gamma |) in + let advice_evals := M.alloc (| advice_evals |) in + let fixed_evals := M.alloc (| fixed_evals |) in + let instance_evals := M.alloc (| instance_evals |) in + M.read (| + let active_rows := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ Ty.associated ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "one", [] |), + [] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ Ty.associated ], + "add", + [] + |), + [ M.read (| l_last |); M.read (| l_blind |) ] + |) + ] + |) + |) in + let product_expression := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let left := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "product_next_eval" + |) + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] + ], + "add", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "permuted_input_eval" + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path "halo2_proofs::plonk::Beta" + ], + [], + "deref", + [] + |), + [ beta ] + |) + ] + |) + |) + ] + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "add", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "permuted_table_eval" + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::Gamma" + ], + [], + "deref", + [] + |), + [ gamma ] + |) + ] + |) + |) + ] + |) + |) in + let compress_expressions := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let expressions := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ], + [], + "fold", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ Ty.associated; Ty.associated + ] + ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ], + [], + "map", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ], + "iter", + [] + |), + [ M.read (| expressions |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let expression := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + Ty.associated + ], + "evaluate", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.associated + ] + ] + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ] + ] + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.associated + ] + ] + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.associated; + Ty.associated + ] + ] + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ] + ] + ] + ] + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.associated; + Ty.associated + ] + ] + Ty.associated + ] + |), + [ + M.read (| + expression + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match + γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + scalar := + M.copy (| + γ + |) in + M.read (| + scalar + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match + γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.never_to_any (| + M.call_closure (| + M.get_function (| + "std::panicking::begin_panic", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + Value.String + "virtual selectors are removed during optimization" + |) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1; + α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + index := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + M.SubPointer.get_array_field (| + M.read (| + fixed_evals + |), + index + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1; + α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + index := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + M.SubPointer.get_array_field (| + M.read (| + advice_evals + |), + index + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1; + α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + index := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + M.SubPointer.get_array_field (| + M.read (| + instance_evals + |), + index + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match + γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Neg", + Ty.associated, + [], + "neg", + [] + |), + [ + M.read (| + a + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + b := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "add", + [] + |), + [ + M.read (| + a + |); + b + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + b := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ], + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.read (| + a + |); + Value.Tuple + [] + ] + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ], + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.read (| + b + |); + Value.Tuple + [] + ] + |) + |) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + scalar := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "mul", + [] + |), + [ + M.read (| + a + |); + scalar + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "zero", + [] + |), + [] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := + M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let eval := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "mul", + [] + |), + [ + M.read (| + acc + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Theta" + ], + [], + "deref", + [] + |), + [ + theta + ] + |) + ] + |); + eval + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let right := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "product_eval" + |) + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ] + ] + ] + ] + Ty.associated, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ] + ] + ] + ], + "call", + [] + |), + [ + compress_expressions; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| argument |), + "halo2_proofs::plonk::lookup::Argument", + "input_expressions" + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path "halo2_proofs::plonk::Beta" + ], + [], + "deref", + [] + |), + [ beta ] + |) + ] + |) + |) + ] + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ] + ] + ] + ] + Ty.associated, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ] + ] + ] + ], + "call", + [] + |), + [ + compress_expressions; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| argument |), + "halo2_proofs::plonk::lookup::Argument", + "table_expressions" + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::Gamma" + ], + [], + "deref", + [] + |), + [ gamma ] + |) + ] + |) + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "sub", + [] + |), + [ M.read (| left |); right ] + |); + active_rows + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.associated ]; + Ty.apply (Ty.path "core::option::IntoIter") [ Ty.associated ] + ]; + Ty.apply (Ty.path "core::option::IntoIter") [ Ty.associated ] + ]; + Ty.apply (Ty.path "core::option::IntoIter") [ Ty.associated ] + ]; + Ty.apply (Ty.path "core::option::IntoIter") [ Ty.associated ] + ], + [], + "chain", + [ Ty.apply (Ty.path "core::option::Option") [ Ty.associated ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.associated ]; + Ty.apply (Ty.path "core::option::IntoIter") [ Ty.associated ] + ]; + Ty.apply (Ty.path "core::option::IntoIter") [ Ty.associated ] + ]; + Ty.apply (Ty.path "core::option::IntoIter") [ Ty.associated ] + ], + [], + "chain", + [ Ty.apply (Ty.path "core::option::Option") [ Ty.associated ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.associated ]; + Ty.apply (Ty.path "core::option::IntoIter") [ Ty.associated ] + ]; + Ty.apply (Ty.path "core::option::IntoIter") [ Ty.associated ] + ], + [], + "chain", + [ Ty.apply (Ty.path "core::option::Option") [ Ty.associated ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.associated ]; + Ty.apply (Ty.path "core::option::IntoIter") [ Ty.associated ] + ], + [], + "chain", + [ Ty.apply (Ty.path "core::option::Option") [ Ty.associated ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.associated ], + [], + "chain", + [ Ty.apply (Ty.path "core::option::Option") [ Ty.associated ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "core::iter::sources::empty::empty", + [ Ty.associated ] + |), + [] + |); + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul", + [] + |), + [ + M.read (| l_0 |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |); + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "product_eval" + |) + ] + |) + |) + ] + |) + ] + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul", + [] + |), + [ + M.read (| l_last |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "square", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "product_eval" + |) + ] + |); + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "product_eval" + |) + ] + |) + |) + ] + |) + ] + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function [ Ty.tuple [] ] Ty.associated, + [ Ty.tuple [] ], + "call", + [] + |), + [ product_expression; Value.Tuple [] ] + |) + ] + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul", + [] + |), + [ + M.read (| l_0 |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "sub", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "permuted_input_eval" + |) + |); + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "permuted_table_eval" + |) + ] + |) + |) + ] + |) + ] + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "sub", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "permuted_input_eval" + |) + |); + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "permuted_table_eval" + |) + ] + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "sub", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "permuted_input_eval" + |) + |); + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "permuted_input_inv_eval" + |) + ] + |) + |) + ] + |); + active_rows + ] + |) + ] + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_expressions : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "expressions" (expressions C). + + (* + pub(in crate::plonk) fn queries<'r>( + &'r self, + vk: &'r VerifyingKey, + x: ChallengeX, + ) -> impl Iterator> + Clone { + let x_inv = vk.domain.rotate_omega( *x, Rotation::prev()); + let x_next = vk.domain.rotate_omega( *x, Rotation::next()); + + iter::empty() + // Open lookup product commitment at x + .chain(Some(VerifierQuery::new_commitment( + &self.committed.product_commitment, + *x, + Rotation::cur(), + self.product_eval, + ))) + // Open lookup input commitments at x + .chain(Some(VerifierQuery::new_commitment( + &self.committed.permuted.permuted_input_commitment, + *x, + Rotation::cur(), + self.permuted_input_eval, + ))) + // Open lookup table commitments at x + .chain(Some(VerifierQuery::new_commitment( + &self.committed.permuted.permuted_table_commitment, + *x, + Rotation::cur(), + self.permuted_table_eval, + ))) + // Open lookup input commitments at \omega^{-1} x + .chain(Some(VerifierQuery::new_commitment( + &self.committed.permuted.permuted_input_commitment, + x_inv, + Rotation::prev(), + self.permuted_input_inv_eval, + ))) + // Open lookup product commitment at \omega x + .chain(Some(VerifierQuery::new_commitment( + &self.committed.product_commitment, + x_next, + Rotation::next(), + self.product_next_eval, + ))) + } + *) + Definition queries (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; vk; x ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let vk := M.alloc (| vk |) in + let x := M.alloc (| x |) in + M.read (| + let x_inv := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "rotate_omega", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "prev", + [] + |), + [] + |) + ] + |) + |) in + let x_next := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "rotate_omega", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "next", + [] + |), + [] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") [ C ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "core::iter::sources::empty::empty", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + |), + [] + |); + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ], + "new_commitment", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "committed" + |), + "halo2_proofs::plonk::lookup::verifier::Committed", + "product_commitment" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "product_eval" + |) + |) + ] + |) + ] + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ], + "new_commitment", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "committed" + |), + "halo2_proofs::plonk::lookup::verifier::Committed", + "permuted" + |), + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments", + "permuted_input_commitment" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "permuted_input_eval" + |) + |) + ] + |) + ] + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ], + "new_commitment", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "committed" + |), + "halo2_proofs::plonk::lookup::verifier::Committed", + "permuted" + |), + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments", + "permuted_table_commitment" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "permuted_table_eval" + |) + |) + ] + |) + ] + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ], + "new_commitment", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "committed" + |), + "halo2_proofs::plonk::lookup::verifier::Committed", + "permuted" + |), + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments", + "permuted_input_commitment" + |); + M.read (| x_inv |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "prev", + [] + |), + [] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "permuted_input_inv_eval" + |) + |) + ] + |) + ] + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ], + "new_commitment", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "committed" + |), + "halo2_proofs::plonk::lookup::verifier::Committed", + "product_commitment" + |); + M.read (| x_next |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "next", + [] + |), + [] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::lookup::verifier::Evaluated", + "product_next_eval" + |) + |) + ] + |) + ] + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_queries : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "queries" (queries C). + End Impl_halo2_proofs_plonk_lookup_verifier_Evaluated_C. + End verifier. + End lookup. +End plonk. diff --git a/CoqOfRust/halo2_proofs/plonk/permutation.v b/CoqOfRust/halo2_proofs/plonk/permutation.v new file mode 100644 index 000000000..a67817694 --- /dev/null +++ b/CoqOfRust/halo2_proofs/plonk/permutation.v @@ -0,0 +1,973 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module plonk. + Module permutation. + (* StructRecord + { + name := "Argument"; + ty_params := []; + fields := + [ + ("columns", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_permutation_Argument. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::permutation::Argument". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Argument" |); + M.read (| Value.String "columns" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::Argument", + "columns" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_permutation_Argument. + + Module Impl_core_clone_Clone_for_halo2_proofs_plonk_permutation_Argument. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::permutation::Argument". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::plonk::permutation::Argument" + [ + ("columns", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::Argument", + "columns" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_plonk_permutation_Argument. + + Module Impl_halo2_proofs_plonk_permutation_Argument. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::permutation::Argument". + + (* + pub(crate) fn new() -> Self { + Argument { columns: vec![] } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [] => + ltac:(M.monadic + (Value.StructRecord + "halo2_proofs::plonk::permutation::Argument" + [ + ("columns", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + + (* + pub(crate) fn required_degree(&self) -> usize { + // degree 2: + // l_0(X) * (1 - z(X)) = 0 + // + // We will fit as many polynomials p_i(X) as possible + // into the required degree of the circuit, so the + // following will not affect the required degree of + // this middleware. + // + // (1 - (l_last(X) + l_blind(X))) * ( + // z(\omega X) \prod (p(X) + \beta s_i(X) + \gamma) + // - z(X) \prod (p(X) + \delta^i \beta X + \gamma) + // ) + // + // On the first sets of columns, except the first + // set, we will do + // + // l_0(X) * (z(X) - z'(\omega^(last) X)) = 0 + // + // where z'(X) is the permutation for the previous set + // of columns. + // + // On the final set of columns, we will do + // + // degree 3: + // l_last(X) * (z'(X)^2 - z'(X)) = 0 + // + // which will allow the last value to be zero to + // ensure the argument is perfectly complete. + + // There are constraints of degree 3 regardless of the + // number of columns involved. + 3 + } + *) + Definition required_degree (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.Integer 3)) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_required_degree : + M.IsAssociatedFunction Self "required_degree" required_degree. + + (* + pub(crate) fn add_column(&mut self, column: Column) { + if !self.columns.contains(&column) { + self.columns.push(column); + } + } + *) + Definition add_column (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; column ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "contains", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::Argument", + "columns" + |) + ] + |); + column + ] + |)) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::Argument", + "columns" + |); + M.read (| column |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_add_column : M.IsAssociatedFunction Self "add_column" add_column. + + (* + pub(crate) fn get_columns(&self) -> Vec> { + self.columns.clone() + } + *) + Definition get_columns (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::Argument", + "columns" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get_columns : M.IsAssociatedFunction Self "get_columns" get_columns. + End Impl_halo2_proofs_plonk_permutation_Argument. + + (* StructRecord + { + name := "VerifyingKey"; + ty_params := [ "C" ]; + fields := + [ + ("commitments", + Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_plonk_permutation_VerifyingKey_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::permutation::VerifyingKey") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "VerifyingKey" |); + M.read (| Value.String "commitments" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::VerifyingKey", + "commitments" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_plonk_permutation_VerifyingKey_C. + + Module Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_plonk_permutation_VerifyingKey_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::permutation::VerifyingKey") [ C ]. + + (* Clone *) + Definition clone (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::plonk::permutation::VerifyingKey" + [ + ("commitments", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::VerifyingKey", + "commitments" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone C)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_plonk_permutation_VerifyingKey_C. + + Module Impl_halo2_proofs_plonk_permutation_VerifyingKey_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::permutation::VerifyingKey") [ C ]. + + (* + pub fn write(&self, writer: &mut W) -> io::Result<()> { + for commitment in &self.commitments { + writer.write_all(commitment.to_bytes().as_ref())?; + } + + Ok(()) + } + *) + Definition write (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ W ], [ self; writer ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ] + ], + [], + "into_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::VerifyingKey", + "commitments" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ C ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let commitment := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "std::io::Write", + W, + [], + "write_all", + [] + |), + [ + M.read (| writer |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ + Ty.apply + (Ty.path "slice") + [ Ty.path "u8" ] + ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::GroupEncoding", + C, + [], + "to_bytes", + [] + |), + [ M.read (| commitment |) ] + |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_write : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "write" (write C). + + (* + pub fn read(reader: &mut R, argument: &Argument) -> io::Result { + let commitments = (0..argument.columns.len()) + .map(|_| C::read(reader)) + .collect::, _>>()?; + Ok(VerifyingKey { commitments }) + } + *) + Definition read (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ R ], [ reader; argument ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + let argument := M.alloc (| argument |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let commitments := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ]) + ] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| argument |), + "halo2_proofs::plonk::permutation::Argument", + "columns" + |) + ] + |)) + ]; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::CurveRead", + C, + [], + "read", + [ R ] + |), + [ M.read (| reader |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::VerifyingKey") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::permutation::VerifyingKey" + [ ("commitments", M.read (| commitments |)) ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_read : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "read" (read C). + End Impl_halo2_proofs_plonk_permutation_VerifyingKey_C. + + (* StructRecord + { + name := "ProvingKey"; + ty_params := [ "C" ]; + fields := + [ + ("permutations", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]; + Ty.path "alloc::alloc::Global" + ]); + ("polys", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]; + Ty.path "alloc::alloc::Global" + ]); + ("cosets", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::ExtendedLagrangeCoeff" ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_permutation_ProvingKey_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::permutation::ProvingKey") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "ProvingKey" |); + M.read (| Value.String "permutations" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::ProvingKey", + "permutations" + |)); + M.read (| Value.String "polys" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::ProvingKey", + "polys" + |)); + M.read (| Value.String "cosets" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::ProvingKey", + "cosets" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_permutation_ProvingKey_C. + End permutation. +End plonk. diff --git a/CoqOfRust/halo2_proofs/plonk/permutation/keygen.v b/CoqOfRust/halo2_proofs/plonk/permutation/keygen.v new file mode 100644 index 000000000..951522698 --- /dev/null +++ b/CoqOfRust/halo2_proofs/plonk/permutation/keygen.v @@ -0,0 +1,6198 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module plonk. + Module permutation. + Module keygen. + (* StructRecord + { + name := "ParallelAssembly"; + ty_params := []; + fields := + [ + ("n", Ty.path "usize"); + ("columns", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ]); + ("aux", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]); + ("cycles", + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_permutation_keygen_ParallelAssembly. + Definition Self : Ty.t := + Ty.path "halo2_proofs::plonk::permutation::keygen::ParallelAssembly". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field4_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "ParallelAssembly" |); + M.read (| Value.String "n" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "n" + |)); + M.read (| Value.String "columns" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "columns" + |)); + M.read (| Value.String "aux" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "aux" + |)); + M.read (| Value.String "cycles" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "cycles" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_permutation_keygen_ParallelAssembly. + + Module Impl_halo2_proofs_plonk_permutation_keygen_ParallelAssembly. + Definition Self : Ty.t := + Ty.path "halo2_proofs::plonk::permutation::keygen::ParallelAssembly". + + (* + pub(crate) fn new(n: usize, p: &Argument) -> Self { + Self { + n, + columns: p.columns.clone(), + aux: vec![vec![None; n]; p.columns.len()], + cycles: BTreeSet::default(), + } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ n; p ] => + ltac:(M.monadic + (let n := M.alloc (| n |) in + let p := M.alloc (| p |) in + Value.StructRecord + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" + [ + ("n", M.read (| n |)); + ("columns", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| p |), + "halo2_proofs::plonk::permutation::Argument", + "columns" + |) + ] + |)); + ("aux", + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + |), + [ Value.StructTuple "core::option::Option::None" []; M.read (| n |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| p |), + "halo2_proofs::plonk::permutation::Argument", + "columns" + |) + ] + |) + ] + |)); + ("cycles", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "default", + [] + |), + [] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + + (* + pub(crate) fn copy( + &mut self, + left_column: Column, + left_row: usize, + right_column: Column, + right_row: usize, + ) -> Result<(), Error> { + let left_column = self + .columns + .iter() + .position(|c| c == &left_column) + .ok_or(Error::ColumnNotInPermutation(left_column))?; + let right_column = self + .columns + .iter() + .position(|c| c == &right_column) + .ok_or(Error::ColumnNotInPermutation(right_column))?; + + // Check bounds + if left_row >= self.n || right_row >= self.n { + return Err(Error::BoundsFailure); + } + + let left_cycle = self.aux[left_column][left_row].clone(); + let right_cycle = self.aux[right_column][right_row].clone(); + + // If left and right are in the same cycle, do nothing. + if left_cycle.is_some() && right_cycle.is_some() { + if Rc::ptr_eq(left_cycle.as_ref().unwrap(), right_cycle.as_ref().unwrap()) { + return Ok(()); + } + } + + let left_cycle = left_cycle.unwrap_or_else(|| { + let cycle = Rc::new(RefCell::new(vec![(left_column as u32, left_row as u32)])); + + self.aux[left_column][left_row] = Some(cycle.clone()); + cycle + }); + let right_cycle = right_cycle.unwrap_or_else(|| { + let cycle = Rc::new(RefCell::new(vec![(right_column as u32, right_row as u32)])); + + self.aux[right_column][right_row] = Some(cycle.clone()); + cycle + }); + + let (small_cycle, big_cycle) = + if left_cycle.borrow().len() <= right_cycle.borrow_mut().len() { + (left_cycle, right_cycle) + } else { + (right_cycle, left_cycle) + }; + + // merge small cycle into big cycle + self.cycles.remove(&small_cycle); + self.cycles.insert(big_cycle.clone()); + + for (col, row) in small_cycle.borrow().iter() { + self.aux[*col as usize][*row as usize] = Some(big_cycle.clone()); + } + + let mut small_cycle = Rc::try_unwrap(small_cycle).unwrap().into_inner(); + big_cycle.borrow_mut().append(&mut small_cycle); + + Ok(()) + } + *) + Definition copy (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; left_column; left_row; right_column; right_row ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let left_column := M.alloc (| left_column |) in + let left_row := M.alloc (| left_row |) in + let right_column := M.alloc (| right_column |) in + let right_row := M.alloc (| right_row |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let left_column := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ], + "ok_or", + [ Ty.path "halo2_proofs::plonk::error::Error" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + [], + "position", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "columns" + |) + ] + |) + ] + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let c := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ], + "eq", + [] + |), + [ c; M.alloc (| left_column |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::error::Error::ColumnNotInPermutation" + [ M.read (| left_column |) ] + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let right_column := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ], + "ok_or", + [ Ty.path "halo2_proofs::plonk::error::Error" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + [], + "position", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "columns" + |) + ] + |) + ] + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let c := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ], + "eq", + [] + |), + [ c; M.alloc (| right_column |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::error::Error::ColumnNotInPermutation" + [ M.read (| right_column |) ] + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.or (| + BinOp.Pure.ge + (M.read (| left_row |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "n" + |) + |)), + ltac:(M.monadic + (BinOp.Pure.ge + (M.read (| right_row |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "n" + |) + |)))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "halo2_proofs::plonk::error::Error::BoundsFailure" + [] + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let left_cycle := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "clone", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "aux" + |); + M.read (| left_column |) + ] + |); + M.read (| left_row |) + ] + |) + ] + |) + |) in + let right_cycle := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "clone", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "aux" + |); + M.read (| right_column |) + ] + |); + M.read (| right_row |) + ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "is_some", + [] + |), + [ left_cycle ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "is_some", + [] + |), + [ right_cycle ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "ptr_eq", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "as_ref", + [] + |), + [ left_cycle ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "as_ref", + [] + |), + [ right_cycle ] + |) + ] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let left_cycle := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "unwrap_or_else", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| left_cycle |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let cycle := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.rust_cast + (M.read (| + left_column + |)); + M.rust_cast + (M.read (| + left_row + |)) + ] + ] + |) + ] + |) + |)) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "aux" + |); + M.read (| left_column |) + ] + |); + M.read (| left_row |) + ] + |), + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ cycle ] + |) + ] + |) in + cycle + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let right_cycle := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "unwrap_or_else", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| right_cycle |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let cycle := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.rust_cast + (M.read (| + right_column + |)); + M.rust_cast + (M.read (| + right_row + |)) + ] + ] + |) + ] + |) + |)) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "aux" + |); + M.read (| right_column |) + ] + |); + M.read (| right_row |) + ] + |), + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ cycle ] + |) + ] + |) in + cycle + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.match_operator (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.le + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "core::cell::Ref") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ], + "borrow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ left_cycle ] + |) + ] + |) + |) + ] + |) + ] + |)) + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "core::cell::RefMut") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ right_cycle ] + |) + ] + |) + |) + ] + |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.Tuple [ M.read (| left_cycle |); M.read (| right_cycle |) ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple [ M.read (| right_cycle |); M.read (| left_cycle |) ] + |))) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let small_cycle := M.copy (| γ0_0 |) in + let big_cycle := M.copy (| γ0_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "remove", + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "cycles" + |); + small_cycle + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "cycles" + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ big_cycle ] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "core::cell::Ref") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "borrow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ small_cycle ] + |) + ] + |) + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ2_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let col := M.alloc (| γ2_0 |) in + let row := M.alloc (| γ2_1 |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path + "u32"; + Ty.path + "u32" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "aux" + |); + M.rust_cast + (M.read (| M.read (| col |) |)) + ] + |); + M.rust_cast + (M.read (| M.read (| row |) |)) + ] + |), + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ big_cycle ] + |) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let small_cycle := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ], + "into_inner", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "try_unwrap", + [] + |), + [ M.read (| small_cycle |) ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + "append", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "core::cell::RefMut") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ big_cycle ] + |) + ] + |) + |) + ] + |); + small_cycle + ] + |) + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_copy : M.IsAssociatedFunction Self "copy" copy. + End Impl_halo2_proofs_plonk_permutation_keygen_ParallelAssembly. + + (* StructRecord + { + name := "Assembly"; + ty_params := []; + fields := + [ + ("mapping", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_plonk_permutation_keygen_Assembly. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::permutation::keygen::Assembly". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Assembly" |); + M.read (| Value.String "mapping" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::keygen::Assembly", + "mapping" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_plonk_permutation_keygen_Assembly. + + Module Impl_core_clone_Clone_for_halo2_proofs_plonk_permutation_keygen_Assembly. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::permutation::keygen::Assembly". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::plonk::permutation::keygen::Assembly" + [ + ("mapping", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::keygen::Assembly", + "mapping" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_plonk_permutation_keygen_Assembly. + + Module Impl_core_convert_From_halo2_proofs_plonk_permutation_keygen_ParallelAssembly_for_halo2_proofs_plonk_permutation_keygen_Assembly. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::permutation::keygen::Assembly". + + (* + fn from(assembly: ParallelAssembly) -> Self { + let mut mapping: Vec> = vec![]; + + for i in 0..assembly.columns.len() { + // Computes [(i, 0), (i, 1), ..., (i, n - 1)] + mapping.push((0..assembly.n).map(|j| (i as u32, j as u32)).collect()); + } + + for cycle in assembly.cycles { + let mut first = None; + + let mut cycle = cycle.borrow_mut(); + cycle.sort(); + + let mut iter = cycle.iter().peekable(); + while let Some(origin) = iter.next() { + if first.is_none() { + first = Some( *origin); + } + + if let Some(permuted) = iter.peek() { + mapping[origin.0 as usize][origin.1 as usize] = **permuted; + } else { + // It's last element + mapping[origin.0 as usize][origin.1 as usize] = first.unwrap(); + } + } + } + + Self { mapping } + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ assembly ] => + ltac:(M.monadic + (let assembly := M.alloc (| assembly |) in + M.read (| + let mapping := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + assembly, + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "columns" + |) + ] + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + mapping; + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "map", + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ]) + ] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.read (| + M.SubPointer.get_struct_record_field (| + assembly, + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "n" + |) + |)) + ]; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let j := + M.copy (| γ |) in + Value.Tuple + [ + M.rust_cast + (M.read (| i |)); + M.rust_cast + (M.read (| j |)) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + assembly, + "halo2_proofs::plonk::permutation::keygen::ParallelAssembly", + "cycles" + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::collections::btree::set::IntoIter") + [ + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let cycle := M.copy (| γ0_0 |) in + let first := + M.alloc (| + Value.StructTuple "core::option::Option::None" [] + |) in + let cycle := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ cycle ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] ], + "sort", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "core::cell::RefMut") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref_mut", + [] + |), + [ cycle ] + |) + ] + |) + ] + |) + |) in + let iter := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] ], + [], + "peekable", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.tuple [ Ty.path "u32"; Ty.path "u32" ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "core::cell::RefMut") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref", + [] + |), + [ cycle ] + |) + ] + |) + ] + |) + ] + |) + |) in + M.loop (| + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::peekable::Peekable") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let origin := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ] + ], + "is_none", + [] + |), + [ first ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.write (| + first, + Value.StructTuple + "core::option::Option::Some" + [ + M.read (| + M.read (| origin |) + |) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::iter::adapters::peekable::Peekable") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ] + ] + ], + "peek", + [] + |), + [ iter ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let permuted := M.copy (| γ0_0 |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + mapping; + M.rust_cast + (M.read (| + M.SubPointer.get_tuple_field (| + M.read (| origin |), + 0 + |) + |)) + ] + |); + M.rust_cast + (M.read (| + M.SubPointer.get_tuple_field (| + M.read (| origin |), + 1 + |) + |)) + ] + |), + M.read (| + M.read (| + M.read (| permuted |) + |) + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + mapping; + M.rust_cast + (M.read (| + M.SubPointer.get_tuple_field (| + M.read (| origin |), + 0 + |) + |)) + ] + |); + M.rust_cast + (M.read (| + M.SubPointer.get_tuple_field (| + M.read (| origin |), + 1 + |) + |)) + ] + |), + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ] + ], + "unwrap", + [] + |), + [ M.read (| first |) ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + let _ := + M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |) in + M.alloc (| Value.Tuple [] |) + |) + |) + |))) + ] + |))) + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::permutation::keygen::Assembly" + [ ("mapping", M.read (| mapping |)) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::convert::From" + Self + (* Trait polymorphic types *) + [ (* T *) Ty.path "halo2_proofs::plonk::permutation::keygen::ParallelAssembly" ] + (* Instance *) [ ("from", InstanceField.Method from) ]. + End Impl_core_convert_From_halo2_proofs_plonk_permutation_keygen_ParallelAssembly_for_halo2_proofs_plonk_permutation_keygen_Assembly. + + Module Impl_halo2_proofs_plonk_permutation_keygen_Assembly. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::permutation::keygen::Assembly". + + (* + pub(crate) fn build_vk( + self, + params: &Params, + domain: &EvaluationDomain, + p: &Argument, + ) -> VerifyingKey { + // Compute [omega^0, omega^1, ..., omega^{params.n - 1}] + let mut omega_powers = Vec::with_capacity(params.n as usize); + { + let mut cur = C::Scalar::one(); + for _ in 0..params.n { + omega_powers.push(cur); + cur *= &domain.get_omega(); + } + } + + // Compute [omega_powers * \delta^0, omega_powers * \delta^1, ..., omega_powers * \delta^m] + let mut delta_omegas = Vec::with_capacity(p.columns.len()); + { + let mut cur = C::Scalar::one(); + for _ in 0..p.columns.len() { + let mut omega_powers = omega_powers.clone(); + for o in &mut omega_powers { + *o *= &cur; + } + + delta_omegas.push(omega_powers); + + cur *= &C::Scalar::DELTA; + } + } + + // Pre-compute commitments for the URS. + let mut commitments = vec![]; + for i in 0..p.columns.len() { + // Computes the permutation polynomial based on the permutation + // description in the assembly. + let mut permutation_poly = domain.empty_lagrange(); + for (j, p) in permutation_poly.iter_mut().enumerate() { + let (permuted_i, permuted_j) = self.mapping[i][j]; + *p = delta_omegas[permuted_i as usize][permuted_j as usize]; + } + + // Compute commitment to permutation polynomial + commitments.push(params.commit_lagrange(&permutation_poly).to_affine()); + } + VerifyingKey { commitments } + } + *) + Definition build_vk (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C ], [ self; params; domain; p ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let params := M.alloc (| params |) in + let domain := M.alloc (| domain |) in + let p := M.alloc (| p |) in + M.read (| + let omega_powers := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "with_capacity", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)) + ] + |) + |) in + let _ := + let cur := + M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "one", [] |), + [] + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "u64" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u64" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ omega_powers; M.read (| cur |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul_assign", + [] + |), + [ + cur; + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "get_omega", + [] + |), + [ M.read (| domain |) ] + |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let delta_omegas := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + "with_capacity", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| p |), + "halo2_proofs::plonk::permutation::Argument", + "columns" + |) + ] + |) + ] + |) + |) in + let _ := + let cur := + M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "one", [] |), + [] + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| p |), + "halo2_proofs::plonk::permutation::Argument", + "columns" + |) + ] + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let omega_powers := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ omega_powers ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ omega_powers ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let o := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ], + "mul_assign", + [] + |), + [ M.read (| o |); cur ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ delta_omegas; M.read (| omega_powers |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul_assign", + [] + |), + [ + cur; + M.get_constant (| + "pairing_bn256::arithmetic::fields::FieldExt::DELTA" + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let commitments := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| p |), + "halo2_proofs::plonk::permutation::Argument", + "columns" + |) + ] + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let permutation_poly := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "empty_lagrange", + [] + |), + [ M.read (| domain |) ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ Ty.associated ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.associated, + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + "iter_mut", + [] + |), + [ permutation_poly ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ Ty.associated ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let j := M.copy (| γ1_0 |) in + let p := M.copy (| γ1_1 |) in + M.match_operator (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path + "u32"; + Ty.path + "u32" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::permutation::keygen::Assembly", + "mapping" + |); + M.read (| i |) + ] + |); + M.read (| j |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let permuted_i := + M.copy (| γ0_0 |) in + let permuted_j := + M.copy (| γ0_1 |) in + let _ := + M.write (| + M.read (| p |), + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + delta_omegas; + M.rust_cast + (M.read (| + permuted_i + |)) + ] + |); + M.rust_cast + (M.read (| + permuted_j + |)) + ] + |) + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + commitments; + M.call_closure (| + M.get_trait_method (| + "group::Curve", + Ty.associated, + [], + "to_affine", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::Params") + [ C ], + "commit_lagrange", + [] + |), + [ M.read (| params |); permutation_poly ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::permutation::VerifyingKey" + [ ("commitments", M.read (| commitments |)) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_build_vk : M.IsAssociatedFunction Self "build_vk" build_vk. + + (* + pub(crate) fn build_pk( + self, + params: &Params, + domain: &EvaluationDomain, + p: &Argument, + ) -> ProvingKey { + // Compute [omega^0, omega^1, ..., omega^{params.n - 1}] + let timer = start_timer!(|| "prepare delta_omegas"); + let mut deltas = vec![C::Scalar::one()]; + for _ in 1..p.columns.len() { + deltas.push(C::Scalar::DELTA * deltas.last().unwrap()); + } + + let mut delta_omegas = vec![vec![]; p.columns.len()]; + let omega = domain.get_omega(); + delta_omegas.par_iter_mut().enumerate().for_each(|(i, x)| { + x.push(deltas[i]); + for _ in 1..params.n { + x.push(omega * x.last().unwrap()) + } + }); + end_timer!(timer); + + let timer = start_timer!(|| "prepare permutations"); + // Compute permutation polynomials, convert to coset form. + let mut permutations = vec![]; + for i in 0..p.columns.len() { + // Computes the permutation polynomial based on the permutation + // description in the assembly. + let mut permutation_poly = domain.empty_lagrange(); + + parallelize(&mut permutation_poly, |permutation_poly, start| { + permutation_poly.iter_mut().enumerate().for_each(|(j, p)| { + let j = start + j; + let (permuted_i, permuted_j) = self.mapping[i][j]; + *p = delta_omegas[permuted_i as usize][permuted_j as usize]; + }); + }); + + // Store permutation polynomial and precompute its coset evaluation + permutations.push(permutation_poly.clone()); + } + end_timer!(timer); + + let timer = start_timer!(|| "prepare poly"); + let polys: Vec<_> = permutations + .par_iter() + .map(|permutation_poly| domain.lagrange_to_coeff_st(permutation_poly.clone())) + .collect(); + end_timer!(timer); + + #[cfg(not(feature = "cuda"))] + let cosets = polys + .par_iter() + .map(|poly| domain.coeff_to_extended(poly.clone())) + .collect(); + + ProvingKey { + permutations, + polys, + + #[cfg(not(feature = "cuda"))] + cosets, + } + } + *) + Definition build_pk (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C ], [ self; params; domain; p ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let params := M.alloc (| params |) in + let domain := M.alloc (| domain |) in + let p := M.alloc (| p |) in + M.read (| + let timer := + M.alloc (| Value.StructTuple "ark_std::perf_trace::inner::TimerInfo" [] |) in + let deltas := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "array") [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |)) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 1); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| p |), + "halo2_proofs::plonk::permutation::Argument", + "columns" + |) + ] + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + deltas; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul", + [] + |), + [ + M.read (| + M.get_constant (| + "pairing_bn256::arithmetic::fields::FieldExt::DELTA" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "last", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ deltas ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let delta_omegas := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| p |), + "halo2_proofs::plonk::permutation::Argument", + "columns" + |) + ] + |) + ] + |) + |) in + let omega := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "get_omega", + [] + |), + [ M.read (| domain |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "rayon::slice::IterMut") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IndexedParallelIterator", + Ty.apply + (Ty.path "rayon::slice::IterMut") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelRefMutIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "par_iter_mut", + [] + |), + [ delta_omegas ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let i := M.copy (| γ0_0 |) in + let x := M.copy (| γ0_1 |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.read (| x |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ deltas; M.read (| i |) ] + |) + |) + ] + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u64" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 1); + ("end_", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "u64" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.read (| x |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ], + "mul", + [] + |), + [ + M.read (| omega |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.associated + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ], + "last", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + x + |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple "ark_std::perf_trace::inner::TimerInfo" [] + |) in + let permutations := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| p |), + "halo2_proofs::plonk::permutation::Argument", + "columns" + |) + ] + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let permutation_poly := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "empty_lagrange", + [] + |), + [ M.read (| domain |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [], + "deref_mut", + [] + |), + [ permutation_poly ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let permutation_poly := + M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let start := + M.copy (| + γ + |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&mut") + [ + Ty.associated + ] + ] + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ], + "iter_mut", + [] + |), + [ + M.read (| + permutation_poly + |) + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + j := + M.copy (| + γ0_0 + |) in + let + p := + M.copy (| + γ0_1 + |) in + M.read (| + let + j := + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.read (| + start + |), + M.read (| + j + |) + |) + |) in + M.match_operator (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path + "u32"; + Ty.path + "u32" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path + "u32"; + Ty.path + "u32" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::permutation::keygen::Assembly", + "mapping" + |); + M.read (| + i + |) + ] + |); + M.read (| + j + |) + ] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + permuted_i := + M.copy (| + γ0_0 + |) in + let + permuted_j := + M.copy (| + γ0_1 + |) in + let + _ := + M.write (| + M.read (| + p + |), + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + delta_omegas; + M.rust_cast + (M.read (| + permuted_i + |)) + ] + |); + M.rust_cast + (M.read (| + permuted_j + |)) + ] + |) + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + permutations; + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [], + "clone", + [] + |), + [ permutation_poly ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple "ark_std::perf_trace::inner::TimerInfo" [] + |) in + let polys := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ]); + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelRefIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "par_iter", + [] + |), + [ permutations ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let permutation_poly := + M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "lagrange_to_coeff_st", + [] + |), + [ + M.read (| domain |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [], + "clone", + [] + |), + [ M.read (| permutation_poly |) ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let cosets := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]); + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelRefIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "par_iter", + [] + |), + [ polys ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let poly := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "coeff_to_extended", + [] + |), + [ + M.read (| domain |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [], + "clone", + [] + |), + [ M.read (| poly |) ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::permutation::ProvingKey" + [ + ("permutations", M.read (| permutations |)); + ("polys", M.read (| polys |)); + ("cosets", M.read (| cosets |)) + ] + |))) + ] + |))) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_build_pk : M.IsAssociatedFunction Self "build_pk" build_pk. + End Impl_halo2_proofs_plonk_permutation_keygen_Assembly. + End keygen. + End permutation. +End plonk. diff --git a/CoqOfRust/halo2_proofs/plonk/permutation/prover.v b/CoqOfRust/halo2_proofs/plonk/permutation/prover.v new file mode 100644 index 000000000..af23f8015 --- /dev/null +++ b/CoqOfRust/halo2_proofs/plonk/permutation/prover.v @@ -0,0 +1,5033 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module plonk. + Module permutation. + Module prover. + (* StructRecord + { + name := "CommittedSet"; + ty_params := [ "C" ]; + fields := + [ + ("permutation_product_poly", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]); + ("permutation_product_coset", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::ExtendedLagrangeCoeff" ]) + ]; + } *) + + (* StructRecord + { + name := "Committed"; + ty_params := [ "C" ]; + fields := + [ + ("sets", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ C ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + (* StructRecord + { + name := "ConstructedSet"; + ty_params := [ "C" ]; + fields := + [ + ("permutation_product_poly", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]) + ]; + } *) + + (* StructRecord + { + name := "Constructed"; + ty_params := [ "C" ]; + fields := + [ + ("sets", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + (* StructRecord + { + name := "Evaluated"; + ty_params := [ "C" ]; + fields := + [ + ("constructed", + Ty.apply (Ty.path "halo2_proofs::plonk::permutation::prover::Constructed") [ C ]) + ]; + } *) + + Module Impl_halo2_proofs_plonk_permutation_Argument. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::permutation::Argument". + + (* + pub(in crate::plonk) fn commit( + &self, + params: &Params, + pk: &plonk::ProvingKey, + pkey: &ProvingKey, + advice: &[Polynomial], + fixed: &[Polynomial], + instance: &[Polynomial], + beta: ChallengeBeta, + gamma: ChallengeGamma, + mut rng: R, + ) -> Result>, Error> { + let domain = &pk.vk.domain; + + // How many columns can be included in a single permutation polynomial? + // We need to multiply by z(X) and (1 - (l_last(X) + l_blind(X))). This + // will never underflow because of the requirement of at least a degree + // 3 circuit for the permutation argument. + assert!(pk.vk.cs.degree() >= 3); + let chunk_len = pk.vk.cs.degree() - 2; + let blinding_factors = pk.vk.cs.blinding_factors(); + + let mut sets = vec![]; + + let raw_zs = self + .columns + .par_chunks(chunk_len) + .zip(pkey.permutations.par_chunks(chunk_len)) + .enumerate() + .map(|(i, (columns, permutations))| { + // Each column gets its own delta power. + let mut delta_omega = C::Scalar::DELTA.pow(&[i as u64 * chunk_len as u64, 0, 0, 0]); + + // Goal is to compute the products of fractions + // + // (p_j(\omega^i) + \delta^j \omega^i \beta + \gamma) / + // (p_j(\omega^i) + \beta s_j(\omega^i) + \gamma) + // + // where p_j(X) is the jth column in this permutation, + // and i is the ith row of the column. + + let mut modified_values = vec![C::Scalar::one(); params.n as usize]; + + // Iterate over each column of the permutation + for (&column, permuted_column_values) in columns.iter().zip(permutations.iter()) { + let values = match column.column_type() { + Any::Advice => advice, + Any::Fixed => fixed, + Any::Instance => instance, + }; + for i in 0..params.n as usize { + modified_values[i] *= &( *beta * permuted_column_values[i] + + &*gamma + + values[column.index()][i]); + } + } + + // Invert to obtain the denominator for the permutation product polynomial + modified_values.iter_mut().batch_invert(); + + // Iterate over each column again, this time finishing the computation + // of the entire fraction by computing the numerators + for &column in columns.iter() { + let omega = domain.get_omega(); + let values = match column.column_type() { + Any::Advice => advice, + Any::Fixed => fixed, + Any::Instance => instance, + }; + for i in 0..params.n as usize { + modified_values[i] *= + &(delta_omega * &*beta + &*gamma + values[column.index()][i]); + delta_omega *= ω + } + delta_omega *= &C::Scalar::DELTA; + } + + // The modified_values vector is a vector of products of fractions + // of the form + // + // (p_j(\omega^i) + \delta^j \omega^i \beta + \gamma) / + // (p_j(\omega^i) + \beta s_j(\omega^i) + \gamma) + // + // where i is the index into modified_values, for the jth column in + // the permutation + + // Compute the evaluations of the permutation product polynomial + // over our domain, starting with z[0] = 1 + + let mut z = vec![C::Scalar::zero(); params.n as usize]; + z.iter_mut().enumerate().for_each(|(i, z)| { + if i > 0 { + *z = modified_values[i - 1]; + } + }); + z + }) + .collect::>(); + + // Track the "last" value from the previous column set + let mut last_z = C::Scalar::one(); + + for mut z in raw_zs.into_iter() { + z[0] = last_z; + for i in 0..z.len() - 1 { + z[i + 1] = z[i] * z[i + 1]; + } + + let mut z = domain.lagrange_from_vec(z); + // Set blinding factors + for z in &mut z[params.n as usize - blinding_factors..] { + *z = C::Scalar::random(&mut rng); + } + // Set new last_z + last_z = z[params.n as usize - (blinding_factors + 1)]; + + sets.push(z); + } + + Ok(sets) + } + *) + Definition commit (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; R ], [ self; params; pk; pkey; advice; fixed; instance; beta; gamma; rng ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let params := M.alloc (| params |) in + let pk := M.alloc (| pk |) in + let pkey := M.alloc (| pkey |) in + let advice := M.alloc (| advice |) in + let fixed := M.alloc (| fixed |) in + let instance := M.alloc (| instance |) in + let beta := M.alloc (| beta |) in + let gamma := M.alloc (| gamma |) in + let rng := M.alloc (| rng |) in + M.read (| + let domain := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.ge + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "degree", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |)) + (Value.Integer 3)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "assertion failed: pk.vk.cs.degree() >= 3" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let chunk_len := + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "degree", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |), + Value.Integer 2 + |) + |) in + let blinding_factors := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "blinding_factors", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |) + |) in + let sets := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let raw_zs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path "rayon::iter::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "rayon::iter::zip::Zip") + [ + Ty.apply + (Ty.path "rayon::slice::chunks::Chunks") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ]; + Ty.apply + (Ty.path "rayon::slice::chunks::Chunks") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "rayon::iter::zip::Zip") + [ + Ty.apply + (Ty.path "rayon::slice::chunks::Chunks") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ]; + Ty.apply + (Ty.path "rayon::slice::chunks::Chunks") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]); + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IndexedParallelIterator", + Ty.apply + (Ty.path "rayon::iter::zip::Zip") + [ + Ty.apply + (Ty.path "rayon::slice::chunks::Chunks") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ]; + Ty.apply + (Ty.path "rayon::slice::chunks::Chunks") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IndexedParallelIterator", + Ty.apply + (Ty.path "rayon::slice::chunks::Chunks") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path "rayon::slice::chunks::Chunks") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::slice::ParallelSlice", + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "par_chunks", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::Argument", + "columns" + |) + ] + |); + M.read (| chunk_len |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "rayon::slice::ParallelSlice", + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ], + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ], + "par_chunks", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| pkey |), + "halo2_proofs::plonk::permutation::ProvingKey", + "permutations" + |) + ] + |); + M.read (| chunk_len |) + ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let i := M.copy (| γ0_0 |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_1, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_1, 1 |) in + let columns := M.copy (| γ1_0 |) in + let permutations := M.copy (| γ1_1 |) in + M.read (| + let delta_omega := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::fields::BaseExt", + Ty.associated, + [], + "pow", + [] + |), + [ + M.get_constant (| + "pairing_bn256::arithmetic::fields::FieldExt::DELTA" + |); + M.alloc (| + Value.Array + [ + BinOp.Panic.mul (| + Integer.U64, + M.rust_cast (M.read (| i |)), + M.rust_cast (M.read (| chunk_len |)) + |); + Value.Integer 0; + Value.Integer 0; + Value.Integer 0 + ] + |) + ] + |) + |) in + let modified_values := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |); + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "iter", + [] + |), + [ M.read (| columns |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ], + "iter", + [] + |), + [ M.read (| permutations |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let γ1_0 := + M.read (| γ1_0 |) in + let column := + M.copy (| γ1_0 |) in + let + permuted_column_values := + M.copy (| γ1_1 |) in + let values := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "column_type", + [] + |), + [ column ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.read (| + γ + |) in + advice)); + fun γ => + ltac:(M.monadic + (let γ := + M.read (| + γ + |) in + M.alloc (| + M.read (| + fixed + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := + M.read (| + γ + |) in + M.alloc (| + M.read (| + instance + |) + |))) + ] + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "usize" + ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + Value.Integer + 0); + ("end_", + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + params + |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |))) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "usize" + ], + [], + "next", + [] + |), + [ iter + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + i := + M.copy (| + γ0_0 + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "mul_assign", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index_mut", + [] + |), + [ + modified_values; + M.read (| + i + |) + ] + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Beta" + ], + [], + "deref", + [] + |), + [ + beta + ] + |) + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + permuted_column_values + |); + M.read (| + i + |) + ] + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Gamma" + ], + [], + "deref", + [] + |), + [ + gamma + ] + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| + values + |), + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "index", + [] + |), + [ + column + ] + |) + |) + |); + M.read (| + i + |) + ] + |) + |) + ] + |) + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::batch::BatchInvert", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ], + [ Ty.associated ], + "batch_invert", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ modified_values ] + |) + ] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "iter", + [] + |), + [ M.read (| columns |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ0_0 := + M.read (| γ0_0 |) in + let column := + M.copy (| γ0_0 |) in + let omega := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "get_omega", + [] + |), + [ M.read (| domain |) + ] + |) + |) in + let values := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "column_type", + [] + |), + [ column ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.read (| + γ + |) in + advice)); + fun γ => + ltac:(M.monadic + (let γ := + M.read (| + γ + |) in + M.alloc (| + M.read (| + fixed + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := + M.read (| + γ + |) in + M.alloc (| + M.read (| + instance + |) + |))) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "usize" + ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + Value.Integer + 0); + ("end_", + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + params + |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |))) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "usize" + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + i := + M.copy (| + γ0_0 + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "mul_assign", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index_mut", + [] + |), + [ + modified_values; + M.read (| + i + |) + ] + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "mul", + [] + |), + [ + M.read (| + delta_omega + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Beta" + ], + [], + "deref", + [] + |), + [ + beta + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Gamma" + ], + [], + "deref", + [] + |), + [ + gamma + ] + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_array_field (| + M.read (| + values + |), + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "index", + [] + |), + [ + column + ] + |) + |) + |); + M.read (| + i + |) + ] + |) + |) + ] + |) + |) + ] + |) + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "mul_assign", + [] + |), + [ + delta_omega; + omega + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ + Ty.apply + (Ty.path "&") + [ Ty.associated + ] + ], + "mul_assign", + [] + |), + [ + delta_omega; + M.get_constant (| + "pairing_bn256::arithmetic::fields::FieldExt::DELTA" + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let z := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "zero", + [] + |), + [] + |); + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&mut") + [ Ty.associated ] + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ z ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let i := M.copy (| γ0_0 |) in + let z := M.copy (| γ0_1 |) in + M.read (| + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| + i + |)) + (Value.Integer + 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.write (| + M.read (| z |), + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + modified_values; + BinOp.Panic.sub (| + Integer.Usize, + M.read (| + i + |), + Value.Integer + 1 + |) + ] + |) + |) + |) in + M.alloc (| + Value.Tuple [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple [] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + z + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let last_z := + M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "one", [] |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| raw_zs |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let z := M.copy (| γ0_0 |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ z; Value.Integer 0 ] + |), + M.read (| last_z |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + BinOp.Panic.sub (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ z ] + |), + Value.Integer 1 + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + z; + BinOp.Panic.add (| + Integer.Usize, + M.read (| i |), + Value.Integer 1 + |) + ] + |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.associated ], + "mul", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" + ], + "index", + [] + |), + [ z; M.read (| i |) + ] + |) + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" + ], + "index", + [] + |), + [ + z; + BinOp.Panic.add (| + Integer.Usize, + M.read (| i |), + Value.Integer 1 + |) + ] + |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let z := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "lagrange_from_vec", + [] + |), + [ M.read (| domain |); M.read (| z |) ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [ + Ty.apply + (Ty.path + "core::ops::range::RangeFrom") + [ Ty.path "usize" ] + ], + "index_mut", + [] + |), + [ + z; + Value.StructRecord + "core::ops::range::RangeFrom" + [ + ("start", + BinOp.Panic.sub (| + Integer.Usize, + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)), + M.read (| blinding_factors |) + |)) + ] + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let z := M.copy (| γ0_0 |) in + let _ := + M.write (| + M.read (| z |), + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "random", + [ + Ty.apply + (Ty.path "&mut") + [ R ] + ] + |), + [ rng ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.write (| + last_z, + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + z; + BinOp.Panic.sub (| + Integer.Usize, + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)), + BinOp.Panic.add (| + Integer.Usize, + M.read (| blinding_factors |), + Value.Integer 1 + |) + |) + ] + |) + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ sets; M.read (| z |) ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| sets |) ] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_commit : M.IsAssociatedFunction Self "commit" commit. + End Impl_halo2_proofs_plonk_permutation_Argument. + + Module Impl_halo2_proofs_plonk_permutation_prover_Committed_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::permutation::prover::Committed") [ C ]. + + (* + pub(in crate::plonk) fn construct(self) -> Constructed { + Constructed { + sets: self + .sets + .into_iter() + .map(|set| ConstructedSet { + permutation_product_poly: set.permutation_product_poly, + }) + .collect(), + } + } + *) + Definition construct (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::plonk::permutation::prover::Constructed" + [ + ("sets", + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ C ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ C ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::permutation::prover::Committed", + "sets" + |) + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let set := M.copy (| γ |) in + Value.StructRecord + "halo2_proofs::plonk::permutation::prover::ConstructedSet" + [ + ("permutation_product_poly", + M.read (| + M.SubPointer.get_struct_record_field (| + set, + "halo2_proofs::plonk::permutation::prover::CommittedSet", + "permutation_product_poly" + |) + |)) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_construct : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "construct" (construct C). + End Impl_halo2_proofs_plonk_permutation_prover_Committed_C. + + Module Impl_halo2_proofs_plonk_permutation_ProvingKey_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::permutation::ProvingKey") [ C ]. + + (* + pub(in crate::plonk) fn open( + &self, + x: ChallengeX, + ) -> impl Iterator> + Clone { + self.polys.iter().map(move |poly| ProverQuery { + point: *x, + rotation: Rotation::cur(), + poly, + }) + } + *) + Definition open (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; x ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let x := M.alloc (| x |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ], + [], + "map", + [ + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") [ C ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") [ C ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::ProvingKey", + "polys" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let poly := M.copy (| γ |) in + Value.StructRecord + "halo2_proofs::poly::multiopen::ProverQuery" + [ + ("point", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |)); + ("rotation", + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |)); + ("poly", M.read (| poly |)) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_open : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "open" (open C). + + (* + pub(in crate::plonk) fn evaluate, T: TranscriptWrite>( + &self, + x: ChallengeX, + transcript: &mut T, + ) -> Result<(), Error> { + // Hash permutation evals + for eval in self.polys.iter().map(|poly| eval_polynomial(poly, *x)) { + transcript.write_scalar(eval)?; + } + + Ok(()) + } + *) + Definition evaluate (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ E; T ], [ self; x; transcript ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let x := M.alloc (| x |) in + let transcript := M.alloc (| transcript |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ] + ] + ] + Ty.associated + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ], + [], + "map", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ] + ] + ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::ProvingKey", + "polys" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let poly := M.copy (| γ |) in + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::eval_polynomial", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ], + [], + "deref", + [] + |), + [ M.read (| poly |) ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ x ] + |) + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + ] + ] + Ty.associated + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let eval := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ C; E ], + "write_scalar", + [] + |), + [ + M.read (| transcript |); + M.read (| eval |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_evaluate : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "evaluate" (evaluate C). + End Impl_halo2_proofs_plonk_permutation_ProvingKey_C. + + Module Impl_halo2_proofs_plonk_permutation_prover_Constructed_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::permutation::prover::Constructed") [ C ]. + + (* + pub(in crate::plonk) fn evaluate, T: TranscriptWrite>( + self, + pk: &plonk::ProvingKey, + x: ChallengeX, + transcript: &mut T, + ) -> Result, Error> { + let domain = &pk.vk.domain; + let blinding_factors = pk.vk.cs.blinding_factors(); + + { + let mut sets = self.sets.iter(); + + while let Some(set) = sets.next() { + let permutation_product_eval = eval_polynomial(&set.permutation_product_poly, *x); + + let permutation_product_next_eval = eval_polynomial( + &set.permutation_product_poly, + domain.rotate_omega( *x, Rotation::next()), + ); + + // Hash permutation product evals + for eval in iter::empty() + .chain(Some(&permutation_product_eval)) + .chain(Some(&permutation_product_next_eval)) + { + transcript.write_scalar( *eval)?; + } + + // If we have any remaining sets to process, evaluate this set at omega^u + // so we can constrain the last value of its running product to equal the + // first value of the next set's running product, chaining them together. + if sets.len() > 0 { + let permutation_product_last_eval = eval_polynomial( + &set.permutation_product_poly, + domain.rotate_omega( *x, Rotation(-((blinding_factors + 1) as i32))), + ); + + transcript.write_scalar(permutation_product_last_eval)?; + } + } + } + + Ok(Evaluated { constructed: self }) + } + *) + Definition evaluate (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ E; T ], [ self; pk; x; transcript ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let pk := M.alloc (| pk |) in + let x := M.alloc (| x |) in + let transcript := M.alloc (| transcript |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let domain := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + |) in + let blinding_factors := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "blinding_factors", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |) + |) in + let _ := + let sets := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::permutation::prover::Constructed", + "sets" + |) + ] + |) + ] + |) + |) in + M.loop (| + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ] + ], + [], + "next", + [] + |), + [ sets ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let set := M.copy (| γ0_0 |) in + let permutation_product_eval := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::eval_polynomial", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| set |), + "halo2_proofs::plonk::permutation::prover::ConstructedSet", + "permutation_product_poly" + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |) + ] + |) + |) in + let permutation_product_next_eval := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::eval_polynomial", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| set |), + "halo2_proofs::plonk::permutation::prover::ConstructedSet", + "permutation_product_poly" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "rotate_omega", + [] + |), + [ + M.read (| domain |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "next", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ Ty.apply (Ty.path "&") [ Ty.associated ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "&") [ Ty.associated ] ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "&") [ Ty.associated ] ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ Ty.apply (Ty.path "&") [ Ty.associated ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "&") [ Ty.associated ] ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.associated ] ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ Ty.apply (Ty.path "&") [ Ty.associated ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.associated ] + ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "core::iter::sources::empty::empty", + [ Ty.apply (Ty.path "&") [ Ty.associated ] + ] + |), + [] + |); + Value.StructTuple + "core::option::Option::Some" + [ permutation_product_eval ] + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ permutation_product_next_eval ] + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path + "core::option::IntoIter") + [ + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let eval := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ C; E ], + "write_scalar", + [] + |), + [ + M.read (| transcript |); + M.read (| + M.read (| eval |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ C ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.call_closure (| + M.get_trait_method (| + "core::iter::traits::exact_size::ExactSizeIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ] + ], + [], + "len", + [] + |), + [ sets ] + |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let permutation_product_last_eval := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::eval_polynomial", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| set |), + "halo2_proofs::plonk::permutation::prover::ConstructedSet", + "permutation_product_poly" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "rotate_omega", + [] + |), + [ + M.read (| domain |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ x ] + |) + |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + UnOp.Panic.neg (| + Integer.I32, + M.rust_cast + (BinOp.Panic.add (| + Integer.Usize, + M.read (| blinding_factors |), + Value.Integer 1 + |)) + |) + ] + ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ C; E ], + "write_scalar", + [] + |), + [ + M.read (| transcript |); + M.read (| permutation_product_last_eval |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ C ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + let _ := + M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |) in + M.alloc (| Value.Tuple [] |) + |) + |) + |))) + ] + |))) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::permutation::prover::Evaluated" + [ ("constructed", M.read (| self |)) ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_evaluate : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "evaluate" (evaluate C). + End Impl_halo2_proofs_plonk_permutation_prover_Constructed_C. + + Module Impl_halo2_proofs_plonk_permutation_prover_Evaluated_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::permutation::prover::Evaluated") [ C ]. + + (* + pub(in crate::plonk) fn open<'a>( + &'a self, + pk: &'a plonk::ProvingKey, + x: ChallengeX, + ) -> impl Iterator> + Clone { + let blinding_factors = pk.vk.cs.blinding_factors(); + let x_next = pk.vk.domain.rotate_omega( *x, Rotation::next()); + let x_last = pk + .vk + .domain + .rotate_omega( *x, Rotation(-((blinding_factors + 1) as i32))); + + iter::empty() + .chain(self.constructed.sets.iter().flat_map(move |set| { + iter::empty() + // Open permutation product commitments at x and \omega x + .chain(Some(ProverQuery { + point: *x, + rotation: Rotation::cur(), + poly: &set.permutation_product_poly, + })) + .chain(Some(ProverQuery { + point: x_next, + rotation: Rotation::next(), + poly: &set.permutation_product_poly, + })) + })) + // Open it at \omega^{last} x for all but the last set. This rotation is only + // sensical for the first row, but we only use this rotation in a constraint + // that is gated on l_0. + .chain( + self.constructed + .sets + .iter() + .rev() + .skip(1) + .flat_map(move |set| { + Some(ProverQuery { + point: x_last, + rotation: Rotation(-((blinding_factors + 1) as i32)), + poly: &set.permutation_product_poly, + }) + }), + ) + } + *) + Definition open (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; pk; x ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let pk := M.alloc (| pk |) in + let x := M.alloc (| x |) in + M.read (| + let blinding_factors := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "blinding_factors", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |) + |) in + let x_next := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "rotate_omega", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "next", + [] + |), + [] + |) + ] + |) + |) in + let x_last := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "rotate_omega", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + UnOp.Panic.neg (| + Integer.I32, + M.rust_cast + (BinOp.Panic.add (| + Integer.Usize, + M.read (| blinding_factors |), + Value.Integer 1 + |)) + |) + ] + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.apply (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") [ C ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]) + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ] + ] + ] + ]; + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ]) + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.apply (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") [ C ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]) + ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "core::iter::sources::empty::empty", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + |), + [] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ] + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::prover::Evaluated", + "constructed" + |), + "halo2_proofs::plonk::permutation::prover::Constructed", + "sets" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let set := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "core::iter::sources::empty::empty", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + |), + [] + |); + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "halo2_proofs::poly::multiopen::ProverQuery" + [ + ("point", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ x ] + |) + |)); + ("rotation", + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |)); + ("poly", + M.SubPointer.get_struct_record_field (| + M.read (| set |), + "halo2_proofs::plonk::permutation::prover::ConstructedSet", + "permutation_product_poly" + |)) + ] + ] + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "halo2_proofs::poly::multiopen::ProverQuery" + [ + ("point", M.read (| x_next |)); + ("rotation", + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "next", + [] + |), + [] + |)); + ("poly", + M.SubPointer.get_struct_record_field (| + M.read (| set |), + "halo2_proofs::plonk::permutation::prover::ConstructedSet", + "permutation_product_poly" + |)) + ] + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ] + ] + ] + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ] + ] + ], + [], + "skip", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ] + ], + [], + "rev", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::ConstructedSet") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::prover::Evaluated", + "constructed" + |), + "halo2_proofs::plonk::permutation::prover::Constructed", + "sets" + |) + ] + |) + ] + |) + ] + |); + Value.Integer 1 + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let set := M.copy (| γ |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "halo2_proofs::poly::multiopen::ProverQuery" + [ + ("point", M.read (| x_last |)); + ("rotation", + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + UnOp.Panic.neg (| + Integer.I32, + M.rust_cast + (BinOp.Panic.add (| + Integer.Usize, + M.read (| blinding_factors |), + Value.Integer 1 + |)) + |) + ]); + ("poly", + M.SubPointer.get_struct_record_field (| + M.read (| set |), + "halo2_proofs::plonk::permutation::prover::ConstructedSet", + "permutation_product_poly" + |)) + ] + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_open : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "open" (open C). + End Impl_halo2_proofs_plonk_permutation_prover_Evaluated_C. + End prover. + End permutation. +End plonk. diff --git a/CoqOfRust/halo2_proofs/plonk/permutation/verifier.v b/CoqOfRust/halo2_proofs/plonk/permutation/verifier.v new file mode 100644 index 000000000..adb7e8499 --- /dev/null +++ b/CoqOfRust/halo2_proofs/plonk/permutation/verifier.v @@ -0,0 +1,5058 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module plonk. + Module permutation. + Module verifier. + (* StructRecord + { + name := "Committed"; + ty_params := [ "C" ]; + fields := + [ + ("permutation_product_commitments", + Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_plonk_permutation_verifier_Committed_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::permutation::verifier::Committed") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Committed" |); + M.read (| Value.String "permutation_product_commitments" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::verifier::Committed", + "permutation_product_commitments" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_plonk_permutation_verifier_Committed_C. + + (* StructRecord + { + name := "EvaluatedSet"; + ty_params := [ "C" ]; + fields := + [ + ("permutation_product_commitment", C); + ("permutation_product_eval", Ty.associated); + ("permutation_product_next_eval", Ty.associated); + ("permutation_product_last_eval", + Ty.apply (Ty.path "core::option::Option") [ Ty.associated ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_permutation_verifier_EvaluatedSet_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field4_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "EvaluatedSet" |); + M.read (| Value.String "permutation_product_commitment" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet", + "permutation_product_commitment" + |)); + M.read (| Value.String "permutation_product_eval" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet", + "permutation_product_eval" + |)); + M.read (| Value.String "permutation_product_next_eval" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet", + "permutation_product_next_eval" + |)); + M.read (| Value.String "permutation_product_last_eval" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet", + "permutation_product_last_eval" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_permutation_verifier_EvaluatedSet_C. + + (* StructRecord + { + name := "CommonEvaluated"; + ty_params := [ "C" ]; + fields := + [ + ("permutation_evals", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_permutation_verifier_CommonEvaluated_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::permutation::verifier::CommonEvaluated") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "CommonEvaluated" |); + M.read (| Value.String "permutation_evals" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::verifier::CommonEvaluated", + "permutation_evals" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_permutation_verifier_CommonEvaluated_C. + + (* StructRecord + { + name := "Evaluated"; + ty_params := [ "C" ]; + fields := + [ + ("sets", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_plonk_permutation_verifier_Evaluated_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::permutation::verifier::Evaluated") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Evaluated" |); + M.read (| Value.String "sets" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::verifier::Evaluated", + "sets" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_plonk_permutation_verifier_Evaluated_C. + + Module Impl_halo2_proofs_plonk_permutation_Argument. + Definition Self : Ty.t := Ty.path "halo2_proofs::plonk::permutation::Argument". + + (* + pub fn read_product_commitments< + C: CurveAffine, + E: EncodedChallenge, + T: TranscriptRead, + >( + &self, + vk: &plonk::VerifyingKey, + transcript: &mut T, + ) -> Result, Error> { + let chunk_len = vk.cs.degree() - 2; + + let permutation_product_commitments = self + .columns + .chunks(chunk_len) + .map(|_| transcript.read_point()) + .collect::, _>>()?; + + Ok(Committed { + permutation_product_commitments, + }) + } + *) + Definition read_product_commitments (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; E; T ], [ self; vk; transcript ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let vk := M.alloc (| vk |) in + let transcript := M.alloc (| transcript |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let chunk_len := + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "degree", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |), + Value.Integer 2 + |) + |) in + let permutation_product_commitments := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Chunks") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Chunks") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "chunks", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::Argument", + "columns" + |) + ] + |); + M.read (| chunk_len |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptRead", + T, + [ C; E ], + "read_point", + [] + |), + [ M.read (| transcript |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Committed") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::permutation::verifier::Committed" + [ + ("permutation_product_commitments", + M.read (| permutation_product_commitments |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_read_product_commitments : + M.IsAssociatedFunction Self "read_product_commitments" read_product_commitments. + End Impl_halo2_proofs_plonk_permutation_Argument. + + Module Impl_halo2_proofs_plonk_permutation_VerifyingKey_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::permutation::VerifyingKey") [ C ]. + + (* + pub fn evaluate, T: TranscriptRead>( + &self, + transcript: &mut T, + ) -> Result, Error> { + let permutation_evals = self + .commitments + .iter() + .map(|_| transcript.read_scalar()) + .collect::, _>>()?; + + Ok(CommonEvaluated { permutation_evals }) + } + *) + Definition evaluate (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ E; T ], [ self; transcript ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let transcript := M.alloc (| transcript |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let permutation_evals := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply (Ty.path "core::slice::iter::Iter") [ C ]; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ C ] ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ C ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ]; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ C ] ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ C ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::VerifyingKey", + "commitments" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptRead", + T, + [ C; E ], + "read_scalar", + [] + |), + [ M.read (| transcript |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::CommonEvaluated") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::permutation::verifier::CommonEvaluated" + [ ("permutation_evals", M.read (| permutation_evals |)) ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_evaluate : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "evaluate" (evaluate C). + End Impl_halo2_proofs_plonk_permutation_VerifyingKey_C. + + Module Impl_halo2_proofs_plonk_permutation_verifier_Committed_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::permutation::verifier::Committed") [ C ]. + + (* + pub fn evaluate, T: TranscriptRead>( + self, + transcript: &mut T, + ) -> Result, Error> { + let mut sets = vec![]; + + let mut iter = self.permutation_product_commitments.into_iter(); + + while let Some(permutation_product_commitment) = iter.next() { + let permutation_product_eval = transcript.read_scalar()?; + let permutation_product_next_eval = transcript.read_scalar()?; + let permutation_product_last_eval = if iter.len() > 0 { + Some(transcript.read_scalar()?) + } else { + None + }; + + sets.push(EvaluatedSet { + permutation_product_commitment, + permutation_product_eval, + permutation_product_next_eval, + permutation_product_last_eval, + }); + } + + Ok(Evaluated { sets }) + } + *) + Definition evaluate (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ E; T ], [ self; transcript ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let transcript := M.alloc (| transcript |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let sets := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let iter := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ], + [], + "into_iter", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::permutation::verifier::Committed", + "permutation_product_commitments" + |) + |) + ] + |) + |) in + let _ := + M.loop (| + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ C; Ty.path "alloc::alloc::Global" ], + [], + "next", + [] + |), + [ iter ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let permutation_product_commitment := M.copy (| γ0_0 |) in + let permutation_product_eval := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptRead", + T, + [ C; E ], + "read_scalar", + [] + |), + [ M.read (| transcript |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ C ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let permutation_product_next_eval := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptRead", + T, + [ C; E ], + "read_scalar", + [] + |), + [ M.read (| transcript |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ C ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let permutation_product_last_eval := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.call_closure (| + M.get_trait_method (| + "core::iter::traits::exact_size::ExactSizeIterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ C; Ty.path "alloc::alloc::Global" ], + [], + "len", + [] + |), + [ iter ] + |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.associated; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptRead", + T, + [ C; E ], + "read_scalar", + [] + |), + [ M.read (| transcript |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ C ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple "core::option::Option::None" [] + |))) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + sets; + Value.StructRecord + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet" + [ + ("permutation_product_commitment", + M.read (| permutation_product_commitment |)); + ("permutation_product_eval", + M.read (| permutation_product_eval |)); + ("permutation_product_next_eval", + M.read (| permutation_product_next_eval |)); + ("permutation_product_last_eval", + M.read (| permutation_product_last_eval |)) + ] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + let _ := + M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |) in + M.alloc (| Value.Tuple [] |) + |) + |) + |))) + ] + |))) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::permutation::verifier::Evaluated" + [ ("sets", M.read (| sets |)) ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_evaluate : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "evaluate" (evaluate C). + End Impl_halo2_proofs_plonk_permutation_verifier_Committed_C. + + Module Impl_halo2_proofs_plonk_permutation_verifier_Evaluated_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::permutation::verifier::Evaluated") [ C ]. + + (* + pub(in crate::plonk) fn expressions<'a>( + &'a self, + vk: &'a plonk::VerifyingKey, + p: &'a Argument, + common: &'a CommonEvaluated, + advice_evals: &'a [C::Scalar], + fixed_evals: &'a [C::Scalar], + instance_evals: &'a [C::Scalar], + l_0: C::Scalar, + l_last: C::Scalar, + l_blind: C::Scalar, + beta: ChallengeBeta, + gamma: ChallengeGamma, + x: ChallengeX, + ) -> impl Iterator + 'a { + let chunk_len = vk.cs.degree() - 2; + iter::empty() + // Enforce only for the first set. + // l_0(X) * (1 - z_0(X)) = 0 + .chain( + self.sets.first().map(|first_set| { + l_0 * &(C::Scalar::one() - &first_set.permutation_product_eval) + }), + ) + // Enforce only for the last set. + // l_last(X) * (z_l(X)^2 - z_l(X)) = 0 + .chain(self.sets.last().map(|last_set| { + (last_set.permutation_product_eval.square() - &last_set.permutation_product_eval) + * &l_last + })) + // Except for the first set, enforce. + // l_0(X) * (z_i(X) - z_{i-1}(\omega^(last) X)) = 0 + .chain( + self.sets + .iter() + .skip(1) + .zip(self.sets.iter()) + .map(|(set, last_set)| { + ( + set.permutation_product_eval, + last_set.permutation_product_last_eval.unwrap(), + ) + }) + .map(move |(set, prev_last)| (set - &prev_last) * &l_0), + ) + // And for all the sets we enforce: + // (1 - (l_last(X) + l_blind(X))) * ( + // z_i(\omega X) \prod (p(X) + \beta s_i(X) + \gamma) + // - z_i(X) \prod (p(X) + \delta^i \beta X + \gamma) + // ) + .chain( + self.sets + .iter() + .zip(p.columns.chunks(chunk_len)) + .zip(common.permutation_evals.chunks(chunk_len)) + .enumerate() + .map(move |(chunk_index, ((set, columns), permutation_evals))| { + let mut left = set.permutation_product_next_eval; + for (eval, permutation_eval) in columns + .iter() + .map(|&column| match column.column_type() { + Any::Advice => { + advice_evals[vk.cs.get_any_query_index(column, Rotation::cur())] + } + Any::Fixed => { + fixed_evals[vk.cs.get_any_query_index(column, Rotation::cur())] + } + Any::Instance => { + instance_evals + [vk.cs.get_any_query_index(column, Rotation::cur())] + } + }) + .zip(permutation_evals.iter()) + { + left *= &(eval + &( *beta * permutation_eval) + &*gamma); + } + + let mut right = set.permutation_product_eval; + let mut current_delta = ( *beta * &*x) + * &(C::Scalar::DELTA.pow_vartime(&[(chunk_index * chunk_len) as u64])); + for eval in columns.iter().map(|&column| match column.column_type() { + Any::Advice => { + advice_evals[vk.cs.get_any_query_index(column, Rotation::cur())] + } + Any::Fixed => { + fixed_evals[vk.cs.get_any_query_index(column, Rotation::cur())] + } + Any::Instance => { + instance_evals[vk.cs.get_any_query_index(column, Rotation::cur())] + } + }) { + right *= &(eval + ¤t_delta + &*gamma); + current_delta *= &C::Scalar::DELTA; + } + + (left - &right) * (C::Scalar::one() - &(l_last + &l_blind)) + }), + ) + } + *) + Definition expressions (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], + [ + self; + vk; + p; + common; + advice_evals; + fixed_evals; + instance_evals; + l_0; + l_last; + l_blind; + beta; + gamma; + x + ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let vk := M.alloc (| vk |) in + let p := M.alloc (| p |) in + let common := M.alloc (| common |) in + let advice_evals := M.alloc (| advice_evals |) in + let fixed_evals := M.alloc (| fixed_evals |) in + let instance_evals := M.alloc (| instance_evals |) in + let l_0 := M.alloc (| l_0 |) in + let l_last := M.alloc (| l_last |) in + let l_blind := M.alloc (| l_blind |) in + let beta := M.alloc (| beta |) in + let gamma := M.alloc (| gamma |) in + let x := M.alloc (| x |) in + M.read (| + let chunk_len := + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "degree", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |), + Value.Integer 2 + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.associated ]; + Ty.apply (Ty.path "core::option::IntoIter") [ Ty.associated ] + ]; + Ty.apply (Ty.path "core::option::IntoIter") [ Ty.associated ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ] + ] + ] + (Ty.tuple [ Ty.associated; Ty.associated ]) + ]; + Ty.function + [ Ty.tuple [ Ty.tuple [ Ty.associated; Ty.associated ] ] ] + Ty.associated + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Chunks") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ] + ]; + Ty.apply (Ty.path "core::slice::iter::Chunks") [ Ty.associated ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] + ] + ] + ] + ] + Ty.associated + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.associated ]; + Ty.apply (Ty.path "core::option::IntoIter") [ Ty.associated ] + ]; + Ty.apply (Ty.path "core::option::IntoIter") [ Ty.associated ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ] + ] + ] + (Ty.tuple [ Ty.associated; Ty.associated ]) + ]; + Ty.function + [ Ty.tuple [ Ty.tuple [ Ty.associated; Ty.associated ] ] ] + Ty.associated + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.associated ]; + Ty.apply (Ty.path "core::option::IntoIter") [ Ty.associated ] + ], + [], + "chain", + [ Ty.apply (Ty.path "core::option::Option") [ Ty.associated ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.associated ], + [], + "chain", + [ Ty.apply (Ty.path "core::option::Option") [ Ty.associated ] ] + |), + [ + M.call_closure (| + M.get_function (| + "core::iter::sources::empty::empty", + [ Ty.associated ] + |), + [] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ], + "map", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ] + ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ], + "first", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::verifier::Evaluated", + "sets" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let first_set := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] + ], + "mul", + [] + |), + [ + M.read (| l_0 |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |); + M.SubPointer.get_struct_record_field (| + M.read (| first_set |), + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet", + "permutation_product_eval" + |) + ] + |) + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ], + "map", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ] + ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ], + "last", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::verifier::Evaluated", + "sets" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let last_set := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "square", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| last_set |), + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet", + "permutation_product_eval" + |) + ] + |); + M.SubPointer.get_struct_record_field (| + M.read (| last_set |), + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet", + "permutation_product_eval" + |) + ] + |); + l_last + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ] + ] + ] + (Ty.tuple [ Ty.associated; Ty.associated ]) + ], + [], + "map", + [ + Ty.associated; + Ty.function + [ Ty.tuple [ Ty.tuple [ Ty.associated; Ty.associated ] ] ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ], + [], + "map", + [ + Ty.tuple [ Ty.associated; Ty.associated ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ] + ] + ] + (Ty.tuple [ Ty.associated; Ty.associated ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ], + [], + "skip", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::verifier::Evaluated", + "sets" + |) + ] + |) + ] + |); + Value.Integer 1 + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::verifier::Evaluated", + "sets" + |) + ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let set := M.copy (| γ0_0 |) in + let last_set := M.copy (| γ0_1 |) in + Value.Tuple + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| set |), + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet", + "permutation_product_eval" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.associated ], + "unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| last_set |), + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet", + "permutation_product_last_eval" + |) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let set := M.copy (| γ0_0 |) in + let prev_last := M.copy (| γ0_1 |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "sub", + [] + |), + [ M.read (| set |); prev_last ] + |); + l_0 + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Chunks") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ] + ]; + Ty.apply (Ty.path "core::slice::iter::Chunks") [ Ty.associated ] + ] + ], + [], + "map", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] + ] + ] + ] + ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Chunks") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ] + ]; + Ty.apply (Ty.path "core::slice::iter::Chunks") [ Ty.associated ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Chunks") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ] + ], + [], + "zip", + [ Ty.apply (Ty.path "core::slice::iter::Chunks") [ Ty.associated ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Chunks") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::verifier::Evaluated", + "sets" + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ] + ], + "chunks", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Any" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| p |), + "halo2_proofs::plonk::permutation::Argument", + "columns" + |) + ] + |); + M.read (| chunk_len |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "chunks", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| common |), + "halo2_proofs::plonk::permutation::verifier::CommonEvaluated", + "permutation_evals" + |) + ] + |); + M.read (| chunk_len |) + ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let chunk_index := M.copy (| γ0_0 |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_1, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_1, 1 |) in + let γ2_0 := M.SubPointer.get_tuple_field (| γ1_0, 0 |) in + let γ2_1 := M.SubPointer.get_tuple_field (| γ1_0, 1 |) in + let set := M.copy (| γ2_0 |) in + let columns := M.copy (| γ2_1 |) in + let permutation_evals := M.copy (| γ1_1 |) in + M.read (| + let left := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| set |), + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet", + "permutation_product_next_eval" + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ] + Ty.associated + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ] + Ty.associated + ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.associated ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + [], + "map", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "iter", + [] + |), + [ M.read (| columns |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.read (| γ |) in + let column := + M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "column_type", + [] + |), + [ column ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.read (| + γ + |) in + M.SubPointer.get_array_field (| + M.read (| + advice_evals + |), + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ + Ty.associated + ], + "get_any_query_index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + vk + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |); + M.read (| + column + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := + M.read (| + γ + |) in + M.SubPointer.get_array_field (| + M.read (| + fixed_evals + |), + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ + Ty.associated + ], + "get_any_query_index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + vk + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |); + M.read (| + column + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := + M.read (| + γ + |) in + M.SubPointer.get_array_field (| + M.read (| + instance_evals + |), + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ + Ty.associated + ], + "get_any_query_index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + vk + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |); + M.read (| + column + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + |) + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "iter", + [] + |), + [ M.read (| permutation_evals |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ] + Ty.associated + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.associated ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let eval := + M.copy (| γ1_0 |) in + let permutation_eval := + M.copy (| γ1_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ], + "mul_assign", + [] + |), + [ + left; + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "add", + [] + |), + [ + M.read (| + eval + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "mul", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Beta" + ], + [], + "deref", + [] + |), + [ + beta + ] + |) + |); + M.read (| + permutation_eval + |) + ] + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Gamma" + ], + [], + "deref", + [] + |), + [ gamma ] + |) + ] + |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let right := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| set |), + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet", + "permutation_product_eval" + |) + |) in + let current_delta := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] + ], + "mul", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Beta" + ], + [], + "deref", + [] + |), + [ beta ] + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ x ] + |) + ] + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "pow_vartime", + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "u64" ] + ] + ] + |), + [ + M.get_constant (| + "pairing_bn256::arithmetic::fields::FieldExt::DELTA" + |); + M.alloc (| + Value.Array + [ + M.rust_cast + (BinOp.Panic.mul (| + Integer.Usize, + M.read (| chunk_index |), + M.read (| chunk_len |) + |)) + ] + |) + ] + |) + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ] + Ty.associated + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + [], + "map", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ], + "iter", + [] + |), + [ M.read (| columns |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.read (| γ |) in + let column := + M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ], + "column_type", + [] + |), + [ column ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.read (| + γ + |) in + M.SubPointer.get_array_field (| + M.read (| + advice_evals + |), + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ + Ty.associated + ], + "get_any_query_index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + vk + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |); + M.read (| + column + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := + M.read (| + γ + |) in + M.SubPointer.get_array_field (| + M.read (| + fixed_evals + |), + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ + Ty.associated + ], + "get_any_query_index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + vk + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |); + M.read (| + column + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := + M.read (| + γ + |) in + M.SubPointer.get_array_field (| + M.read (| + instance_evals + |), + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ + Ty.associated + ], + "get_any_query_index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + vk + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |); + M.read (| + column + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + |) + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Any" + ] + ] + ] + ] + Ty.associated + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let eval := + M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ], + "mul_assign", + [] + |), + [ + right; + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "add", + [] + |), + [ + M.read (| + eval + |); + current_delta + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Gamma" + ], + [], + "deref", + [] + |), + [ gamma ] + |) + ] + |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ], + "mul_assign", + [] + |), + [ + current_delta; + M.get_constant (| + "pairing_bn256::arithmetic::fields::FieldExt::DELTA" + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.associated ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "sub", + [] + |), + [ M.read (| left |); right ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ], + "add", + [] + |), + [ M.read (| l_last |); l_blind ] + |) + |) + ] + |) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_expressions : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "expressions" (expressions C). + + (* + pub(in crate::plonk) fn queries<'r>( + &'r self, + vk: &'r plonk::VerifyingKey, + x: ChallengeX, + ) -> impl Iterator> + Clone { + let blinding_factors = vk.cs.blinding_factors(); + let x_next = vk.domain.rotate_omega( *x, Rotation::next()); + let x_last = vk + .domain + .rotate_omega( *x, Rotation(-((blinding_factors + 1) as i32))); + + iter::empty() + .chain(self.sets.iter().flat_map(move |set| { + iter::empty() + // Open permutation product commitments at x and \omega^{-1} x + // Open permutation product commitments at x and \omega x + .chain(Some(VerifierQuery::new_commitment( + &set.permutation_product_commitment, + *x, + Rotation::cur(), + set.permutation_product_eval, + ))) + .chain(Some(VerifierQuery::new_commitment( + &set.permutation_product_commitment, + x_next, + Rotation::next(), + set.permutation_product_next_eval, + ))) + })) + // Open it at \omega^{last} x for all but the last set + .chain(self.sets.iter().rev().skip(1).flat_map(move |set| { + Some(VerifierQuery::new_commitment( + &set.permutation_product_commitment, + x_last, + Rotation(-((blinding_factors + 1) as i32)), + set.permutation_product_last_eval.unwrap(), + )) + })) + } + *) + Definition queries (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; vk; x ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let vk := M.alloc (| vk |) in + let x := M.alloc (| x |) in + M.read (| + let blinding_factors := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "blinding_factors", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |) + |) in + let x_next := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "rotate_omega", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "next", + [] + |), + [] + |) + ] + |) + |) in + let x_last := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "rotate_omega", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + UnOp.Panic.neg (| + Integer.I32, + M.rust_cast + (BinOp.Panic.add (| + Integer.Usize, + M.read (| blinding_factors |), + Value.Integer 1 + |)) + |) + ] + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ]) + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ] + ]; + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ]) + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ]) + ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "core::iter::sources::empty::empty", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + |), + [] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::verifier::Evaluated", + "sets" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let set := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "core::iter::sources::empty::empty", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ] + |), + [] + |); + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ], + "new_commitment", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| set |), + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet", + "permutation_product_commitment" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ x ] + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| set |), + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet", + "permutation_product_eval" + |) + |) + ] + |) + ] + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ], + "new_commitment", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| set |), + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet", + "permutation_product_commitment" + |); + M.read (| x_next |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "next", + [] + |), + [] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| set |), + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet", + "permutation_product_next_eval" + |) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ] + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ] + ], + [], + "skip", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ], + [], + "rev", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::verifier::Evaluated", + "sets" + |) + ] + |) + ] + |) + ] + |); + Value.Integer 1 + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let set := M.copy (| γ |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ], + "new_commitment", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| set |), + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet", + "permutation_product_commitment" + |); + M.read (| x_last |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + UnOp.Panic.neg (| + Integer.I32, + M.rust_cast + (BinOp.Panic.add (| + Integer.Usize, + M.read (| blinding_factors |), + Value.Integer 1 + |)) + |) + ]; + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.associated ], + "unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| set |), + "halo2_proofs::plonk::permutation::verifier::EvaluatedSet", + "permutation_product_last_eval" + |) + |) + ] + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_queries : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "queries" (queries C). + End Impl_halo2_proofs_plonk_permutation_verifier_Evaluated_C. + + Module Impl_halo2_proofs_plonk_permutation_verifier_CommonEvaluated_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::permutation::verifier::CommonEvaluated") [ C ]. + + (* + pub(in crate::plonk) fn queries<'r>( + &'r self, + vkey: &'r VerifyingKey, + x: ChallengeX, + ) -> impl Iterator> + Clone { + // Open permutation commitments for each permutation argument at x + vkey.commitments + .iter() + .zip(self.permutation_evals.iter()) + .map(move |(commitment, &eval)| { + VerifierQuery::new_commitment(commitment, *x, Rotation::cur(), eval) + }) + } + *) + Definition queries (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; vkey; x ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let vkey := M.alloc (| vkey |) in + let x := M.alloc (| x |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply (Ty.path "core::slice::iter::Iter") [ C ]; + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.associated ] + ], + [], + "map", + [ + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") [ C ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ C ]; + Ty.apply (Ty.path "&") [ Ty.associated ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") [ C ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ C ], + [], + "zip", + [ Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.associated ] ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ C ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vkey |), + "halo2_proofs::plonk::permutation::VerifyingKey", + "commitments" + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::permutation::verifier::CommonEvaluated", + "permutation_evals" + |) + ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let commitment := M.copy (| γ0_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let eval := M.copy (| γ0_1 |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ], + "new_commitment", + [] + |), + [ + M.read (| commitment |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |); + M.read (| eval |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_queries : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "queries" (queries C). + End Impl_halo2_proofs_plonk_permutation_verifier_CommonEvaluated_C. + End verifier. + End permutation. +End plonk. diff --git a/CoqOfRust/halo2_proofs/plonk/prover.v b/CoqOfRust/halo2_proofs/plonk/prover.v new file mode 100644 index 000000000..d173db068 --- /dev/null +++ b/CoqOfRust/halo2_proofs/plonk/prover.v @@ -0,0 +1,42196 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module plonk. + Module prover. + (* StructRecord + { + name := "InstanceSingle"; + ty_params := [ "C" ]; + fields := + [ + ("instance_values", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]; + Ty.path "alloc::alloc::Global" + ]); + ("instance_polys", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]; + Ty.path "alloc::alloc::Global" + ]); + ("instance_cosets", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::ExtendedLagrangeCoeff" ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_prover_InstanceSingle_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::prover::InstanceSingle") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "InstanceSingle" |); + M.read (| Value.String "instance_values" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::prover::InstanceSingle", + "instance_values" + |)); + M.read (| Value.String "instance_polys" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::prover::InstanceSingle", + "instance_polys" + |)); + M.read (| Value.String "instance_cosets" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::prover::InstanceSingle", + "instance_cosets" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_prover_InstanceSingle_C. + + (* + pub fn create_single_instances, T: TranscriptWrite>( + params: &Params, + pk: &ProvingKey, + instances: &[&[&[C::Scalar]]], + transcript: &mut T, + ) -> Result>, Error> { + for instance in instances.iter() { + if instance.len() != pk.vk.cs.num_instance_columns { + return Err(Error::InvalidInstances); + } + } + + // Hash verification key into transcript + pk.vk.hash_into(transcript)?; + + let domain = &pk.vk.domain; + + // Selector optimizations cannot be applied here; use the ConstraintSystem + // from the verification key. + let meta = &pk.vk.cs; + + let instance: Vec> = instances + .iter() + .map(|instance| -> Result, Error> { + let instance_values = instance + .iter() + .map(|values| { + let mut poly = domain.empty_lagrange(); + assert_eq!(poly.len(), params.n as usize); + if values.len() > (poly.len() - (meta.blinding_factors() + 1)) { + return Err(Error::InstanceTooLarge); + } + for (poly, value) in poly.iter_mut().zip(values.iter()) { + *poly = *value; + } + Ok(poly) + }) + .collect::, _>>()?; + + let instance_commitments_projective: Vec<_> = instance_values + .iter() + .map(|poly| params.commit_lagrange(poly)) + .collect(); + let mut instance_commitments = + vec![C::identity(); instance_commitments_projective.len()]; + C::Curve::batch_normalize(&instance_commitments_projective, &mut instance_commitments); + let instance_commitments = instance_commitments; + drop(instance_commitments_projective); + + for commitment in &instance_commitments { + transcript.common_point( *commitment)?; + } + + let instance_polys: Vec<_> = instance_values + .iter() + .map(|poly| { + let lagrange_vec = domain.lagrange_from_vec(poly.to_vec()); + domain.lagrange_to_coeff(lagrange_vec) + }) + .collect(); + + #[cfg(not(feature = "cuda"))] + let instance_cosets: Vec<_> = instance_polys + .iter() + .map(|poly| domain.coeff_to_extended(poly.clone())) + .collect(); + + Ok(InstanceSingle { + instance_values, + instance_polys, + + #[cfg(not(feature = "cuda"))] + instance_cosets, + }) + }) + .collect::, _>>()?; + Ok(instance) + } + *) + Definition create_single_instances (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; E; T ], [ params; pk; instances; transcript ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let pk := M.alloc (| pk |) in + let instances := M.alloc (| instances |) in + let transcript := M.alloc (| transcript |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] + ] + ] + ], + "iter", + [] + |), + [ M.read (| instances |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ] + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let instance := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.call_closure (| + M.get_trait_method (| + "ark_std::iterable::Iterable", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ] + ] + ], + [], + "len", + [] + |), + [ M.read (| instance |) ] + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_instance_columns" + |) + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "halo2_proofs::plonk::error::Error::InvalidInstances" + [] + ] + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::VerifyingKey") [ C ], + "hash_into", + [ E; T ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |); + M.read (| transcript |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let domain := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + |) in + let meta := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + |) in + let instance := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::prover::InstanceSingle") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ] + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::prover::InstanceSingle") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::prover::InstanceSingle") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] + ] + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::prover::InstanceSingle") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ] + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] + ] + ] + ] + ], + "iter", + [] + |), + [ M.read (| instances |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let instance := M.copy (| γ |) in + M.read (| + let instance_values := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "slice") + [ Ty.associated + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "slice") + [ Ty.associated + ] + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ark_std::iterable::Iterable", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ] + ] + ] + ], + [], + "iter", + [] + |), + [ M.read (| instance |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + values := + M.copy (| + γ + |) in + M.read (| + let + poly := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "empty_lagrange", + [] + |), + [ + M.read (| + domain + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ], + "len", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [], + "deref", + [] + |), + [ + poly + ] + |) + ] + |) + |); + M.alloc (| + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + params + |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)) + |) + ] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + left_val := + M.copy (| + γ0_0 + |) in + let + right_val := + M.copy (| + γ0_1 + |) in + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| + M.read (| + left_val + |) + |)) + (M.read (| + M.read (| + right_val + |) + |))) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let + kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ + Ty.path + "usize"; + Ty.path + "usize" + ] + |), + [ + M.read (| + kind + |); + M.read (| + left_val + |); + M.read (| + right_val + |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple + [] + |))) + ] + |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.call_closure (| + M.get_trait_method (| + "ark_std::iterable::Iterable", + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ] + ], + [], + "len", + [] + |), + [ + M.read (| + values + |) + ] + |)) + (BinOp.Panic.sub (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ], + "len", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [], + "deref", + [] + |), + [ + poly + ] + |) + ] + |), + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ + Ty.associated + ], + "blinding_factors", + [] + |), + [ + M.read (| + meta + |) + ] + |), + Value.Integer + 1 + |) + |)) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "halo2_proofs::plonk::error::Error::InstanceTooLarge" + [] + ] + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.associated; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.associated + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.associated, + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.associated + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + "iter_mut", + [] + |), + [ + poly + ] + |); + M.call_closure (| + M.get_trait_method (| + "ark_std::iterable::Iterable", + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ] + ], + [], + "iter", + [] + |), + [ + M.read (| + values + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.associated; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.associated + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + poly := + M.copy (| + γ1_0 + |) in + let + value := + M.copy (| + γ1_1 + |) in + let + _ := + M.write (| + M.read (| + poly + |), + M.read (| + M.read (| + value + |) + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.read (| + poly + |) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let instance_commitments_projective := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + Ty.associated + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ], + [], + "map", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ instance_values ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let poly := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::Params") + [ C ], + "commit_lagrange", + [] + |), + [ + M.read (| + params + |); + M.read (| + poly + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let instance_commitments := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ C ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "group::prime::PrimeCurveAffine", + C, + [], + "identity", + [] + |), + [] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ instance_commitments_projective ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::Curve", + Ty.associated, + [], + "batch_normalize", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ instance_commitments_projective ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + C; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ instance_commitments ] + |) + ] + |) + |) in + let instance_commitments := + M.copy (| instance_commitments |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::mem::drop", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.read (| + instance_commitments_projective + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ instance_commitments ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ C ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let commitment := + M.copy (| + γ0_0 + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ C; E + ], + "common_point", + [] + |), + [ + M.read (| + transcript + |); + M.read (| + M.read (| + commitment + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let instance_polys := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ instance_values ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let poly := + M.copy (| + γ + |) in + M.read (| + let + lagrange_vec := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "lagrange_from_vec", + [] + |), + [ + M.read (| + domain + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ], + "to_vec", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [], + "deref", + [] + |), + [ + M.read (| + poly + |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "lagrange_to_coeff", + [] + |), + [ + M.read (| + domain + |); + M.read (| + lagrange_vec + |) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let instance_cosets := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ instance_polys ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let poly := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "coeff_to_extended", + [] + |), + [ + M.read (| + domain + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [], + "clone", + [] + |), + [ + M.read (| + poly + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::prover::InstanceSingle" + [ + ("instance_values", + M.read (| instance_values |)); + ("instance_polys", + M.read (| instance_polys |)); + ("instance_cosets", + M.read (| instance_cosets |)) + ] + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| instance |) ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + pub fn create_proof_ext< + C: CurveAffine, + E: EncodedChallenge, + R: RngCore, + T: TranscriptWrite, + ConcreteCircuit: Circuit, + >( + params: &Params, + pk: &ProvingKey, + circuits: &[ConcreteCircuit], + instances: &[&[&[C::Scalar]]], + mut rng: R, + transcript: &mut T, + use_gwc: bool, + ) -> Result<(), Error> { + let domain = &pk.vk.domain; + + let timer = start_timer!(|| "instance"); + let instance = create_single_instances(params, pk, instances, transcript)?; + end_timer!(timer); + + let meta = &pk.vk.cs; + + let timer = start_timer!(|| "advice"); + struct AdviceSingle { + pub advice_polys: Vec>, + + #[cfg(not(feature = "cuda"))] + pub advice_cosets: Vec>, + } + + let get_scalar_bits = |x: C::Scalar| { + let repr = x.to_repr(); + let max_scalar_repr_ref: &[u8] = repr.as_ref(); + max_scalar_repr_ref + .iter() + .enumerate() + .fold(0, |acc, (idx, v)| { + if *v == 0 { + acc + } else { + idx * 8 + 8 - v.leading_zeros() as usize + } + }) + }; + + let find_max_scalar_bits = |x: &Vec| { + get_scalar_bits(x.iter().fold(C::Scalar::zero(), |acc, x| acc.max( *x))) + }; + + let advice: Vec>> = circuits + .iter() + .zip(instances.iter()) + .map(|(circuit, instances)| { + let unusable_rows_start = params.n as usize - (meta.blinding_factors() + 1); + + let timer = start_timer!(|| "prepare collection"); + let mut advice: Vec<_> = (0..meta.num_advice_columns) + .into_par_iter() + .map(|_| domain.empty_lagrange()) + .collect(); + + generate_advice_from_synthesize( + params, + pk, + circuit, + instances, + &advice + .iter_mut() + .map(|x| (&mut x.values[..]) as *mut [_]) + .collect::>()[..], + ); + end_timer!(timer); + + let named = &pk.vk.cs.named_advices; + + let timer = start_timer!(|| "rng"); + advice.par_iter_mut().enumerate().for_each(|(i, advice)| { + if named.iter().find(|n| n.1 as usize == i).is_none() { + for cell in &mut advice[unusable_rows_start..] { + *cell = C::Scalar::from(u16::rand(&mut OsRng) as u64); + } + } + }); + end_timer!(timer); + + let timer = start_timer!(|| "commit_lagrange"); + let advice_commitments_projective: Vec<_> = advice + .par_iter() + .map(|advice| { + let max_bits = find_max_scalar_bits(&advice.values); + params.commit_lagrange_with_bound(advice, max_bits) + }) + .collect(); + end_timer!(timer); + + let timer = start_timer!(|| "advice_commitments_projective"); + let mut advice_commitments = vec![C::identity(); advice_commitments_projective.len()]; + C::Curve::batch_normalize(&advice_commitments_projective, &mut advice_commitments); + let advice_commitments = advice_commitments; + drop(advice_commitments_projective); + end_timer!(timer); + + for commitment in &advice_commitments { + transcript.write_point( *commitment).unwrap(); + } + + advice + }) + .collect::>(); + + // Sample theta challenge for keeping lookup columns linearly independent + let theta: ChallengeTheta<_> = transcript.squeeze_challenge_scalar(); + + end_timer!(timer); + let timer = start_timer!(|| format!("lookups {}", pk.vk.cs.lookups.len())); + let (lookups, lookups_commitments): (Vec>>, Vec>) = + instance + .iter() + .zip(advice.iter()) + .map(|(instance, advice)| -> (Vec<_>, Vec<_>) { + pk.vk + .cs + .lookups + .par_iter() + .map(|lookup| { + lookup + .commit_permuted( + pk, + params, + domain, + theta, + &advice, + &pk.fixed_values, + &instance.instance_values, + &mut OsRng, + ) + .unwrap() + }) + .unzip() + }) + .unzip(); + + lookups_commitments.into_iter().for_each(|x| { + x.iter().for_each(|x| { + transcript.write_point(x[0]).unwrap(); + transcript.write_point(x[1]).unwrap(); + }) + }); + end_timer!(timer); + + // Sample beta challenge + let beta: ChallengeBeta<_> = transcript.squeeze_challenge_scalar(); + // Sample gamma challenge + let gamma: ChallengeGamma<_> = transcript.squeeze_challenge_scalar(); + + let (lookups, permutations) = std::thread::scope(|s| { + let permutations = s.spawn(|| { + // prepare permutation value. + instance + .iter() + .zip(advice.iter()) + .map(|(instance, advice)| { + pk.vk.cs.permutation.commit( + params, + pk, + &pk.permutation, + &advice, + &pk.fixed_values, + &instance.instance_values, + beta, + gamma.clone(), + &mut OsRng, + ) + }) + .collect::, _>>() + .unwrap() + }); + + let timer = start_timer!(|| "lookups commit product"); + let lookups: Vec> = lookups + .into_iter() + .map(|lookups| { + lookups + .into_par_iter() + .map(|lookup| lookup.commit_product(pk, params, beta, gamma).unwrap()) + .collect::>() + }) + .collect::>(); + end_timer!(timer); + + let timer = start_timer!(|| "lookups add blinding value"); + let lookups: Vec> = lookups + .into_iter() + .map(|lookups| { + lookups + .into_iter() + .map(|(l0, l1, mut z)| { + for _ in 0..pk.vk.cs.blinding_factors() { + z.push(C::Scalar::random(&mut rng)) + } + (l0, l1, pk.vk.domain.lagrange_from_vec(z)) + }) + .collect::>() + }) + .collect::>>(); + end_timer!(timer); + + let timer = start_timer!(|| "lookups msm and fft"); + let (lookups_z_commitments, lookups): (Vec>, Vec>) = lookups + .into_iter() + .map(|lookups| { + lookups + .into_par_iter() + .map(|l| { + let (product_poly, c) = params.commit_lagrange_and_ifft( + l.2, + &pk.vk.domain.get_omega_inv(), + &pk.vk.domain.ifft_divisor, + ); + let c = c.to_affine(); + ( + c, + lookup::prover::Committed { + permuted_input_poly: pk.vk.domain.lagrange_to_coeff_st(l.0), + permuted_table_poly: pk.vk.domain.lagrange_to_coeff_st(l.1), + product_poly, + }, + ) + }) + .collect::>() + .into_iter() + .unzip() + }) + .unzip(); + end_timer!(timer); + + let timer = start_timer!(|| "permutation commit"); + let permutations = permutations + .join() + .expect("permutations thread failed unexpectedly"); + + let permutations: Vec<_> = permutations + .into_iter() + .map(|permutations| { + let (c, sets): (Vec<_>, _) = permutations + .into_par_iter() + .map(|z| { + let (permutation_product_poly, permutation_product_commitment_projective) = + params.commit_lagrange_and_ifft( + z, + &pk.vk.domain.get_omega_inv(), + &pk.vk.domain.ifft_divisor, + ); + + #[cfg(not(feature = "cuda"))] + let permutation_product_coset = + domain.coeff_to_extended(permutation_product_poly.clone()); + + let permutation_product_commitment = + permutation_product_commitment_projective.to_affine(); + + ( + permutation_product_commitment, + permutation::prover::CommittedSet { + permutation_product_poly, + #[cfg(not(feature = "cuda"))] + permutation_product_coset, + }, + ) + }) + .unzip(); + (c, permutation::prover::Committed { sets }) + }) + .collect(); + + for (cl, _) in permutations.iter() { + for c in cl { + transcript.write_point( *c).unwrap(); + } + } + + let permutations: Vec<_> = permutations.into_iter().map(|x| x.1).collect(); + end_timer!(timer); + + lookups_z_commitments + .into_iter() + .for_each(|lookups_z_commitments| { + lookups_z_commitments + .into_iter() + .for_each(|lookups_z_commitment| { + transcript.write_point(lookups_z_commitment).unwrap() + }) + }); + + (lookups, permutations) + }); + + let timer = start_timer!(|| "vanishing commit"); + // Commit to the vanishing argument's random polynomial for blinding h(x_3) + let vanishing = vanishing::Argument::commit(params, domain, rng, transcript)?; + + // Obtain challenge for keeping all separate gates linearly independent + let y: ChallengeY<_> = transcript.squeeze_challenge_scalar(); + + end_timer!(timer); + let timer = start_timer!(|| "h_poly"); + // Evaluate the h(X) polynomial + + let advice = advice + .into_iter() + .map(|advice| { + let timer = start_timer!(|| "lagrange_to_coeff_st"); + let advice_polys: Vec<_> = advice + .into_par_iter() + .map(|poly| domain.lagrange_to_coeff_st(poly)) + .collect(); + end_timer!(timer); + + #[cfg(not(feature = "cuda"))] + let advice_cosets: Vec<_> = advice_polys + .iter() + .map(|poly| domain.coeff_to_extended(poly.clone())) + .collect(); + + AdviceSingle:: { + advice_polys, + #[cfg(not(feature = "cuda"))] + advice_cosets, + } + }) + .collect::>(); + + #[cfg(feature = "cuda")] + let h_poly = pk.ev.evaluate_h( + pk, + advice.iter().map(|a| &a.advice_polys).collect(), + instance.iter().map(|i| &i.instance_polys).collect(), + *y, + *beta, + *gamma, + *theta, + &lookups, + &permutations, + ); + + #[cfg(not(feature = "cuda"))] + let h_poly = pk.ev.evaluate_h( + pk, + advice.iter().map(|a| &a.advice_cosets).collect(), + instance.iter().map(|i| &i.instance_cosets).collect(), + *y, + *beta, + *gamma, + *theta, + &lookups, + &permutations, + ); + + end_timer!(timer); + let timer = start_timer!(|| "vanishing construct"); + // Construct the vanishing argument's h(X) commitments + let vanishing = vanishing.construct(params, domain, h_poly, transcript)?; + + let x: ChallengeX<_> = transcript.squeeze_challenge_scalar(); + let xn = x.pow(&[params.n as u64, 0, 0, 0]); + end_timer!(timer); + + let timer = start_timer!(|| "eval poly"); + + let mut inputs = vec![]; + + // Compute and hash instance evals for each circuit instance + for instance in instance.iter() { + // Evaluate polynomials at omega^i x + meta.instance_queries.iter().for_each(|&(column, at)| { + inputs.push(( + &instance.instance_polys[column.index()], + domain.rotate_omega( *x, at), + )) + }) + } + + // Compute and hash advice evals for each circuit instance + for advice in advice.iter() { + // Evaluate polynomials at omega^i x + meta.advice_queries.iter().for_each(|&(column, at)| { + inputs.push(( + &advice.advice_polys[column.index()], + domain.rotate_omega( *x, at), + )) + }) + } + + // Compute and hash fixed evals (shared across all circuit instances) + meta.fixed_queries.iter().for_each(|&(column, at)| { + inputs.push((&pk.fixed_polys[column.index()], domain.rotate_omega( *x, at))) + }); + + for eval in inputs + .into_par_iter() + .map(|(a, b)| eval_polynomial_st(a, b)) + .collect::>() + { + transcript.write_scalar(eval)?; + } + + end_timer!(timer); + let timer = start_timer!(|| "eval poly vanishing"); + let vanishing = vanishing.evaluate(x, xn, domain, transcript)?; + + end_timer!(timer); + let timer = start_timer!(|| "eval poly permutation"); + // Evaluate common permutation data + pk.permutation.evaluate(x, transcript)?; + + // Evaluate the permutations, if any, at omega^i x. + let permutations: Vec> = permutations + .into_iter() + .map(|permutation| -> Result<_, _> { permutation.construct().evaluate(pk, x, transcript) }) + .collect::, _>>()?; + + end_timer!(timer); + + let timer = start_timer!(|| "eval poly lookups"); + // Evaluate the lookups, if any, at omega^i x. + let (lookups, evals): ( + Vec>>, + Vec>>, + ) = lookups + .into_iter() + .map(|lookups| lookups.into_par_iter().map(|p| p.evaluate(pk, x)).unzip()) + .unzip(); + evals.into_iter().for_each(|evals| { + evals.into_iter().for_each(|evals| { + evals + .into_iter() + .for_each(|eval| transcript.write_scalar(eval).unwrap()) + }) + }); + end_timer!(timer); + + let timer = start_timer!(|| "multi open"); + let instances = instance + .iter() + .zip(advice.iter()) + .zip(permutations.iter()) + .zip(lookups.iter()) + .flat_map(|(((instance, advice), permutation), lookups)| { + iter::empty() + .chain( + pk.vk + .cs + .instance_queries + .iter() + .map(move |&(column, at)| ProverQuery { + point: domain.rotate_omega( *x, at), + rotation: at, + poly: &instance.instance_polys[column.index()], + }), + ) + .chain( + pk.vk + .cs + .advice_queries + .iter() + .map(move |&(column, at)| ProverQuery { + point: domain.rotate_omega( *x, at), + rotation: at, + poly: &advice.advice_polys[column.index()], + }), + ) + .chain(permutation.open(pk, x)) + .chain(lookups.iter().flat_map(move |p| p.open(pk, x)).into_iter()) + }) + .chain( + pk.vk + .cs + .fixed_queries + .iter() + .map(|&(column, at)| ProverQuery { + point: domain.rotate_omega( *x, at), + rotation: at, + poly: &pk.fixed_polys[column.index()], + }), + ) + .chain(pk.permutation.open(x)) + // We query the h(X) polynomial at x + .chain(vanishing.open(x)); + + let res = if use_gwc { + multiopen::gwc::create_proof(params, transcript, instances).map_err(|_| Error::Opening) + } else { + multiopen::shplonk::create_proof(params, transcript, instances).map_err(|_| Error::Opening) + }; + end_timer!(timer); + + res + } + *) + Definition create_proof_ext (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; E; R; T; ConcreteCircuit ], + [ params; pk; circuits; instances; rng; transcript; use_gwc ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let pk := M.alloc (| pk |) in + let circuits := M.alloc (| circuits |) in + let instances := M.alloc (| instances |) in + let rng := M.alloc (| rng |) in + let transcript := M.alloc (| transcript |) in + let use_gwc := M.alloc (| use_gwc |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let domain := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + |) in + let timer := + M.alloc (| Value.StructTuple "ark_std::perf_trace::inner::TimerInfo" [] |) in + let instance := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::prover::InstanceSingle") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::prover::create_single_instances", + [ C; E; T ] + |), + [ + M.read (| params |); + M.read (| pk |); + M.read (| instances |); + M.read (| transcript |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let meta := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + |) in + let timer := + M.alloc (| + Value.StructTuple "ark_std::perf_trace::inner::TimerInfo" [] + |) in + let get_scalar_bits := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.read (| + let repr := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::PrimeField", + Ty.associated, + [], + "to_repr", + [] + |), + [ x ] + |) + |) in + let max_scalar_repr_ref := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] + ], + "as_ref", + [] + |), + [ repr ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "u8" ] + ], + [], + "fold", + [ + Ty.path "usize"; + Ty.function + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ Ty.path "u8" ] + ] + ] + ] + (Ty.path "usize") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "u8" ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "u8" ], + "iter", + [] + |), + [ M.read (| max_scalar_repr_ref |) ] + |) + ] + |); + Value.Integer 0; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let idx := + M.copy (| γ0_0 |) in + let v := + M.copy (| γ0_1 |) in + M.read (| + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| + M.read (| + v + |) + |)) + (Value.Integer + 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + acc)); + fun γ => + ltac:(M.monadic + (M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.mul (| + Integer.Usize, + M.read (| + idx + |), + Value.Integer + 8 + |), + Value.Integer + 8 + |), + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path + "u8", + "leading_zeros", + [] + |), + [ + M.read (| + M.read (| + v + |) + |) + ] + |)) + |) + |))) + ] + |) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let find_max_scalar_bits := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [ Ty.associated ] ] + (Ty.path "usize"), + [ Ty.tuple [ Ty.associated ] ], + "call", + [] + |), + [ + get_scalar_bits; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.associated ], + [], + "fold", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.associated; + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ] + ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ark_std::iterable::Iterable", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "iter", + [] + |), + [ x ] + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "zero", + [] + |), + [] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := + M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let x := + M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.associated, + [], + "max", + [] + |), + [ + M.read (| + acc + |); + M.read (| + M.read (| x |) + |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let advice := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ ConcreteCircuit ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] + ] + ] + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ ConcreteCircuit ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ] + ] + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ ConcreteCircuit ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] + ] + ] + ] + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ ConcreteCircuit ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ] + ] + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ ConcreteCircuit ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ] + ] + ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ ConcreteCircuit ], + "iter", + [] + |), + [ M.read (| circuits |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ] + ] + ] + ], + "iter", + [] + |), + [ M.read (| instances |) ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let circuit := M.copy (| γ0_0 |) in + let instances := M.copy (| γ0_1 |) in + M.read (| + let unusable_rows_start := + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)), + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "blinding_factors", + [] + |), + [ M.read (| meta |) ] + |), + Value.Integer 1 + |) + |) + |) in + let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let advice := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path "rayon::range::Iter") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::range::Iter") + [ Ty.path "usize" ], + [], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "usize" ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]); + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelIterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "into_par_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + Value.Integer 0); + ("end_", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| meta |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_columns" + |) + |)) + ] + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "empty_lagrange", + [] + |), + [ + M.read (| + domain + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::prover::generate_advice_from_synthesize", + [ C; ConcreteCircuit ] + |), + [ + M.read (| params |); + M.read (| pk |); + M.read (| circuit |); + M.read (| M.read (| instances |) |); + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "*mut") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ]; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.path + "core::ops::range::RangeFull" + ], + "index", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "*mut") + [ + Ty.apply + (Ty.path + "slice") + [ Ty.associated + ] + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "*mut") + [ + Ty.apply + (Ty.path + "slice") + [ Ty.associated + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "*mut") + [ + Ty.apply + (Ty.path + "slice") + [ Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "*mut") + [ + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ advice ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + x := + M.copy (| + γ + |) in + M.read (| + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "core::ops::range::RangeFull" + ], + "index_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + x + |), + "halo2_proofs::poly::Polynomial", + "values" + |); + Value.StructTuple + "core::ops::range::RangeFull" + [] + ] + |) + |)) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |); + Value.StructTuple + "core::ops::range::RangeFull" + [] + ] + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let named := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "named_advices" + |) + |) in + let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::iter::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "rayon::slice::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IndexedParallelIterator", + Ty.apply + (Ty.path + "rayon::slice::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelRefMutIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "par_iter_mut", + [] + |), + [ advice ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let i := + M.copy (| + γ0_0 + |) in + let advice := + M.copy (| + γ0_1 + |) in + M.read (| + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.path + "alloc::string::String"; + Ty.path + "u32" + ] + ] + ], + "is_none", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.path + "alloc::string::String"; + Ty.path + "u32" + ] + ], + [], + "find", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.path + "alloc::string::String"; + Ty.path + "u32" + ] + ] + ] + ] + ] + (Ty.path + "bool") + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ark_std::iterable::Iterable", + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path + "alloc::string::String"; + Ty.path + "u32" + ]; + Ty.path + "alloc::alloc::Global" + ] + ], + [], + "iter", + [] + |), + [ + named + ] + |) + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + n := + M.copy (| + γ + |) in + BinOp.Pure.eq + (M.rust_cast + (M.read (| + M.SubPointer.get_tuple_field (| + M.read (| + M.read (| + n + |) + |), + 1 + |) + |))) + (M.read (| + i + |)))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) + ] + |) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [ + Ty.apply + (Ty.path + "core::ops::range::RangeFrom") + [ + Ty.path + "usize" + ] + ], + "index_mut", + [] + |), + [ + M.read (| + advice + |); + Value.StructRecord + "core::ops::range::RangeFrom" + [ + ("start", + M.read (| + unusable_rows_start + |)) + ] + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + cell := + M.copy (| + γ0_0 + |) in + let + _ := + M.write (| + M.read (| + cell + |), + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.associated, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_trait_method (| + "ark_std::rand_helper::UniformRand", + Ty.path + "u16", + [], + "rand", + [ + Ty.path + "rand_core::os::OsRng" + ] + |), + [ + M.alloc (| + Value.StructTuple + "rand_core::os::OsRng" + [] + |) + ] + |)) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple + [] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let + advice_commitments_projective := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path + "rayon::slice::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + Ty.associated + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::slice::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + Ty.associated; + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelRefIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "par_iter", + [] + |), + [ advice ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + advice := + M.copy (| + γ + |) in + M.read (| + let + max_bits := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + (Ty.path + "usize"), + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ], + "call", + [] + |), + [ + find_max_scalar_bits; + Value.Tuple + [ + M.SubPointer.get_struct_record_field (| + M.read (| + advice + |), + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::Params") + [ + C + ], + "commit_lagrange_with_bound", + [] + |), + [ + M.read (| + params + |); + M.read (| + advice + |); + M.read (| + max_bits + |) + ] + |) + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let + advice_commitments := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ C ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "group::prime::PrimeCurveAffine", + C, + [], + "identity", + [] + |), + [] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ + advice_commitments_projective + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::Curve", + Ty.associated, + [], + "batch_normalize", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + advice_commitments_projective + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ + advice_commitments + ] + |) + ] + |) + |) in + let + advice_commitments := + M.copy (| + advice_commitments + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::mem::drop", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.read (| + advice_commitments_projective + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + advice_commitments + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + C + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + commitment := + M.copy (| + γ0_0 + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "std::io::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ + C; + E + ], + "write_point", + [] + |), + [ + M.read (| + transcript + |); + M.read (| + M.read (| + commitment + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + advice)) + ] + |))) + ] + |))) + ] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let theta := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ C; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::plonk::Theta" ] + |), + [ M.read (| transcript |) ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple "ark_std::perf_trace::inner::TimerInfo" [] + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "array") [ C ]; + Ty.path "alloc::alloc::Global" + ] + ]) + ], + [], + "unzip", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "array") [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "array") [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "map", + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "array") [ C ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "array") [ C ]; + Ty.path "alloc::alloc::Global" + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ instance ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ advice ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let instance := M.copy (| γ0_0 |) in + let advice := M.copy (| γ0_1 |) in + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.apply + (Ty.path "array") + [ C ] + ]) + ], + [], + "unzip", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.apply (Ty.path "array") [ C ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "array") + [ C ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.apply + (Ty.path "array") + [ C ] + ]); + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.apply + (Ty.path "array") + [ C ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelRefIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "par_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "lookups" + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let lookup := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ + C + ]; + Ty.apply + (Ty.path + "array") + [ + C + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ + Ty.associated + ], + "commit_permuted", + [ + C; + Ty.apply + (Ty.path + "&mut") + [ + Ty.path + "rand_core::os::OsRng" + ] + ] + |), + [ + M.read (| + lookup + |); + M.read (| + pk + |); + M.read (| + params + |); + M.read (| + domain + |); + M.read (| + theta + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + advice + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "fixed_values" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + instance + |), + "halo2_proofs::plonk::prover::InstanceSingle", + "instance_values" + |) + ] + |); + M.alloc (| + Value.StructTuple + "rand_core::os::OsRng" + [] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let lookups := M.copy (| γ0_0 |) in + let lookups_commitments := M.copy (| γ0_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "array") [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "array") [ C ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "array") [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| lookups_commitments |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "array") + [ C ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "array") + [ C ] + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "array") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "array") + [ C ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ x ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := + M.copy (| + γ + |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "std::io::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ + C; + E + ], + "write_point", + [] + |), + [ + M.read (| + transcript + |); + M.read (| + M.SubPointer.get_array_field (| + M.read (| + x + |), + M.alloc (| + Value.Integer + 0 + |) + |) + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "std::io::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ + C; + E + ], + "write_point", + [] + |), + [ + M.read (| + transcript + |); + M.read (| + M.SubPointer.get_array_field (| + M.read (| + x + |), + M.alloc (| + Value.Integer + 1 + |) + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let beta := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ C; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::plonk::Beta" ] + |), + [ M.read (| transcript |) ] + |) + |) in + let gamma := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ C; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::plonk::Gamma" ] + |), + [ M.read (| transcript |) ] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_function (| + "std::thread::scoped::scope", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "std::thread::scoped::Scope" + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ C ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ C ]; + Ty.path "alloc::alloc::Global" + ] + ]); + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ C ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let s := M.copy (| γ |) in + M.read (| + let permutations := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "std::thread::scoped::Scope", + "spawn", + [ + Ty.function + [ Ty.tuple [] + ] + (Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]); + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.read (| s |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + instance + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + advice + ] + |) + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + instance := + M.copy (| + γ0_0 + |) in + let + advice := + M.copy (| + γ0_1 + |) in + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::plonk::permutation::Argument", + "commit", + [ + C; + Ty.apply + (Ty.path + "&mut") + [ + Ty.path + "rand_core::os::OsRng" + ] + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |); + M.read (| + params + |); + M.read (| + pk + |); + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "permutation" + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + advice + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "fixed_values" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + instance + |), + "halo2_proofs::plonk::prover::InstanceSingle", + "instance_values" + |) + ] + |); + M.read (| + beta + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Gamma" + ], + [], + "clone", + [] + |), + [ + gamma + ] + |); + M.alloc (| + Value.StructTuple + "rand_core::os::OsRng" + [] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) in + let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let lookups := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + lookups + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + lookups := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ + C + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ + C + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ + C + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ + C + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]); + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_par_iter", + [] + |), + [ + M.read (| + lookups + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + lookup := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ + C + ], + "commit_product", + [] + |), + [ + M.read (| + lookup + |); + M.read (| + pk + |); + M.read (| + params + |); + M.read (| + beta + |); + M.read (| + gamma + |) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let lookups := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + lookups + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + lookups := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + lookups + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + γ0_2 := + M.SubPointer.get_tuple_field (| + γ, + 2 + |) in + let + l0 := + M.copy (| + γ0_0 + |) in + let + l1 := + M.copy (| + γ0_1 + |) in + let + z := + M.copy (| + γ0_2 + |) in + M.read (| + let + _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "usize" + ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + Value.Integer + 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ + Ty.associated + ], + "blinding_factors", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |)) + ] + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "usize" + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + z; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "random", + [ + Ty.apply + (Ty.path + "&mut") + [ + R + ] + ] + |), + [ + rng + ] + |) + ] + |) + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + M.alloc (| + Value.Tuple + [ + M.read (| + l0 + |); + M.read (| + l1 + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "lagrange_from_vec", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| + z + |) + ] + |) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let + timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ]) + ], + [], + "unzip", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + lookups + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + lookups := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "unzip", + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + (Ty.tuple + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ] + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + (Ty.tuple + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ] + ]); + Ty.tuple + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_par_iter", + [] + |), + [ + M.read (| + lookups + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + l := + M.copy (| + γ + |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::Params") + [ + C + ], + "commit_lagrange_and_ifft", + [] + |), + [ + M.read (| + params + |); + M.read (| + M.SubPointer.get_tuple_field (| + l, + 2 + |) + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "get_omega_inv", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |) + |); + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |), + "halo2_proofs::poly::domain::EvaluationDomain", + "ifft_divisor" + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + product_poly := + M.copy (| + γ0_0 + |) in + let + c := + M.copy (| + γ0_1 + |) in + let + c := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::Curve", + Ty.associated, + [], + "to_affine", + [] + |), + [ + c + ] + |) + |) in + M.alloc (| + Value.Tuple + [ + M.read (| + c + |); + Value.StructRecord + "halo2_proofs::plonk::lookup::prover::Committed" + [ + ("permuted_input_poly", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "lagrange_to_coeff_st", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| + M.SubPointer.get_tuple_field (| + l, + 0 + |) + |) + ] + |)); + ("permuted_table_poly", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "lagrange_to_coeff_st", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| + M.SubPointer.get_tuple_field (| + l, + 1 + |) + |) + ] + |)); + ("product_poly", + M.read (| + product_poly + |)) + ] + ] + |))) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + lookups_z_commitments := + M.copy (| + γ0_0 + |) in + let + lookups := + M.copy (| + γ0_1 + |) in + M.match_operator (| + timer, + [ + fun + γ => + ltac:(M.monadic + (let + timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let + permutations := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.dyn + [ + ("core::any::Any::Trait", + []) + ]; + Ty.path + "alloc::alloc::Global" + ] + ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::thread::scoped::ScopedJoinHandle") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ], + "join", + [] + |), + [ + M.read (| + permutations + |) + ] + |); + M.read (| + Value.String + "permutations thread failed unexpectedly" + |) + ] + |) + |) in + let + permutations := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + permutations + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + permutations := + M.copy (| + γ + |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + (Ty.tuple + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ] + ]) + ], + [], + "unzip", + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + (Ty.tuple + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ] + ]); + Ty.tuple + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_par_iter", + [] + |), + [ + M.read (| + permutations + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + z := + M.copy (| + γ + |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::Params") + [ + C + ], + "commit_lagrange_and_ifft", + [] + |), + [ + M.read (| + params + |); + M.read (| + z + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "get_omega_inv", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |) + |); + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |), + "halo2_proofs::poly::domain::EvaluationDomain", + "ifft_divisor" + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + permutation_product_poly := + M.copy (| + γ0_0 + |) in + let + permutation_product_commitment_projective := + M.copy (| + γ0_1 + |) in + let + permutation_product_coset := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "coeff_to_extended", + [] + |), + [ + M.read (| + domain + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [], + "clone", + [] + |), + [ + permutation_product_poly + ] + |) + ] + |) + |) in + let + permutation_product_commitment := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::Curve", + Ty.associated, + [], + "to_affine", + [] + |), + [ + permutation_product_commitment_projective + ] + |) + |) in + M.alloc (| + Value.Tuple + [ + M.read (| + permutation_product_commitment + |); + Value.StructRecord + "halo2_proofs::plonk::permutation::prover::CommittedSet" + [ + ("permutation_product_poly", + M.read (| + permutation_product_poly + |)); + ("permutation_product_coset", + M.read (| + permutation_product_coset + |)) + ] + ] + |))) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + c := + M.copy (| + γ0_0 + |) in + let + sets := + M.copy (| + γ0_1 + |) in + M.alloc (| + Value.Tuple + [ + M.read (| + c + |); + Value.StructRecord + "halo2_proofs::plonk::permutation::prover::Committed" + [ + ("sets", + M.read (| + sets + |)) + ] + ] + |))) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let + _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + permutations + ] + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + γ0_0 := + M.read (| + γ0_0 + |) in + let + γ2_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let + γ2_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + cl := + M.alloc (| + γ2_0 + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.read (| + cl + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + C + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + c := + M.copy (| + γ0_0 + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "std::io::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ + C; + E + ], + "write_point", + [] + |), + [ + M.read (| + transcript + |); + M.read (| + M.read (| + c + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + let + permutations := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + permutations + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + x := + M.copy (| + γ + |) in + M.read (| + M.SubPointer.get_tuple_field (| + x, + 1 + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun + γ => + ltac:(M.monadic + (let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + lookups_z_commitments + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + lookups_z_commitments := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + C; + Ty.path + "alloc::alloc::Global" + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + C + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + lookups_z_commitments + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + lookups_z_commitment := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "std::io::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ + C; + E + ], + "write_point", + [] + |), + [ + M.read (| + transcript + |); + M.read (| + lookups_z_commitment + |) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.Tuple + [ + M.read (| + lookups + |); + M.read (| + permutations + |) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let lookups := M.copy (| γ0_0 |) in + let permutations := M.copy (| γ0_1 |) in + let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let vanishing := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::prover::Committed") + [ C ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::Argument") + [ C ], + "commit", + [ E; R; T ] + |), + [ + M.read (| params |); + M.read (| domain |); + M.read (| rng |); + M.read (| transcript |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let y := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ C; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::plonk::Y" ] + |), + [ M.read (| transcript |) ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let advice := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ C ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ C ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ C ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ C ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| advice |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + advice := + M.copy (| + γ + |) in + M.read (| + let + timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let + advice_polys := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]); + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_par_iter", + [] + |), + [ + M.read (| + advice + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + poly := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "lagrange_to_coeff_st", + [] + |), + [ + M.read (| + domain + |); + M.read (| + poly + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun + γ => + ltac:(M.monadic + (let + advice_cosets := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + advice_polys + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + poly := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "coeff_to_extended", + [] + |), + [ + M.read (| + domain + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [], + "clone", + [] + |), + [ + M.read (| + poly + |) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle" + [ + ("advice_polys", + M.read (| + advice_polys + |)); + ("advice_cosets", + M.read (| + advice_cosets + |)) + ] + |))) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let h_poly := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "evaluate_h", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "ev" + |); + M.read (| pk |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ C ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ C ] + ] + ] + ] + (Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ C ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ C + ] + ] + ] + ] + (Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ C ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ advice ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.SubPointer.get_struct_record_field (| + M.read (| + a + |), + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle", + "advice_cosets" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ] + ] + ] + ] + (Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C + ] + ] + ] + ] + (Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ instance ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + i := + M.copy (| + γ + |) in + M.SubPointer.get_struct_record_field (| + M.read (| + i + |), + "halo2_proofs::plonk::prover::InstanceSingle", + "instance_cosets" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Y" + ], + [], + "deref", + [] + |), + [ y ] + |) + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Beta" + ], + [], + "deref", + [] + |), + [ beta ] + |) + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Gamma" + ], + [], + "deref", + [] + |), + [ gamma ] + |) + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Theta" + ], + [], + "deref", + [] + |), + [ theta ] + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ C ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ lookups ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ C ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ permutations ] + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let vanishing := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::prover::Constructed") + [ C ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::prover::Committed") + [ C ], + "construct", + [ E; T ] + |), + [ + M.read (| + vanishing + |); + M.read (| + params + |); + M.read (| + domain + |); + M.read (| + h_poly + |); + M.read (| + transcript + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) + |) in + let x := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ C; E ], + "squeeze_challenge_scalar", + [ + Ty.path + "halo2_proofs::plonk::X" + ] + |), + [ + M.read (| + transcript + |) + ] + |) + |) in + let xn := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::fields::BaseExt", + Ty.associated, + [], + "pow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ x ] + |); + M.alloc (| + Value.Array + [ + M.read (| + M.use + (M.SubPointer.get_struct_record_field (| + M.read (| + params + |), + "halo2_proofs::poly::commitment::Params", + "n" + |)) + |); + Value.Integer + 0; + Value.Integer + 0; + Value.Integer + 0 + ] + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let inputs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + instance + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + instance := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + meta + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "instance_queries" + |) + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.read (| + γ + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + column := + M.copy (| + γ1_0 + |) in + let + at_ := + M.copy (| + γ1_1 + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + inputs; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + instance + |), + "halo2_proofs::plonk::prover::InstanceSingle", + "instance_polys" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ], + "index", + [] + |), + [ + column + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "rotate_omega", + [] + |), + [ + M.read (| + domain + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ + x + ] + |) + |); + M.read (| + at_ + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + advice + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + advice := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + meta + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "advice_queries" + |) + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.read (| + γ + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + column := + M.copy (| + γ1_0 + |) in + let + at_ := + M.copy (| + γ1_1 + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + inputs; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + advice + |), + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle", + "advice_polys" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ], + "index", + [] + |), + [ + column + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "rotate_omega", + [] + |), + [ + M.read (| + domain + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ + x + ] + |) + |); + M.read (| + at_ + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + meta + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "fixed_queries" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match + γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.read (| + γ + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + column := + M.copy (| + γ1_0 + |) in + let + at_ := + M.copy (| + γ1_1 + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + inputs; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "fixed_polys" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ], + "index", + [] + |), + [ + column + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "rotate_omega", + [] + |), + [ + M.read (| + domain + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ + x + ] + |) + |); + M.read (| + at_ + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ] + ] + ] + Ty.associated + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ] + ] + ] + Ty.associated; + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_par_iter", + [] + |), + [ + M.read (| + inputs + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + a := + M.copy (| + γ0_0 + |) in + let + b := + M.copy (| + γ0_1 + |) in + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::eval_polynomial_st", + [ + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [], + "deref", + [] + |), + [ + M.read (| + a + |) + ] + |); + M.read (| + b + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + eval := + M.copy (| + γ0_0 + |) in + let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ + C; + E + ], + "write_scalar", + [] + |), + [ + M.read (| + transcript + |); + M.read (| + eval + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let + timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let + vanishing := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::prover::Evaluated") + [ + C + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::prover::Constructed") + [ + C + ], + "evaluate", + [ + E; + T + ] + |), + [ + M.read (| + vanishing + |); + M.read (| + x + |); + M.read (| + xn + |); + M.read (| + domain + |); + M.read (| + transcript + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let + timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::ProvingKey") + [ + C + ], + "evaluate", + [ + E; + T + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "permutation" + |); + M.read (| + x + |); + M.read (| + transcript + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let + permutations := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + permutations + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + permutation := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Constructed") + [ + C + ], + "evaluate", + [ + E; + T + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ], + "construct", + [] + |), + [ + M.read (| + permutation + |) + ] + |); + M.read (| + pk + |); + M.read (| + x + |); + M.read (| + transcript + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun + γ => + ltac:(M.monadic + (let + timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]) + ], + [], + "unzip", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + lookups + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + lookups := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]) + ], + [], + "unzip", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]); + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_par_iter", + [] + |), + [ + M.read (| + lookups + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + p := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ], + "evaluate", + [] + |), + [ + M.read (| + p + |); + M.read (| + pk + |); + M.read (| + x + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + lookups := + M.copy (| + γ0_0 + |) in + let + evals := + M.copy (| + γ0_1 + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + evals + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + evals := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + evals + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + evals := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.associated + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + evals + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + eval := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "std::io::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ + C; + E + ], + "write_scalar", + [] + |), + [ + M.read (| + transcript + |); + M.read (| + eval + |) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun + γ => + ltac:(M.monadic + (let + timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let + instances := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]) + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ], + [], + "chain", + [ + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]) + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ], + [], + "chain", + [ + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]) + ], + [], + "chain", + [ + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ] + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + instance + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + advice + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + permutations + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + lookups + ] + |) + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + γ2_0 := + M.SubPointer.get_tuple_field (| + γ1_0, + 0 + |) in + let + γ2_1 := + M.SubPointer.get_tuple_field (| + γ1_0, + 1 + |) in + let + instance := + M.copy (| + γ2_0 + |) in + let + advice := + M.copy (| + γ2_1 + |) in + let + permutation := + M.copy (| + γ1_1 + |) in + let + lookups := + M.copy (| + γ0_1 + |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ], + [], + "chain", + [ + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ], + [], + "chain", + [ + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "core::iter::sources::empty::empty", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ] + |), + [] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "instance_queries" + |) + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.read (| + γ + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + column := + M.copy (| + γ1_0 + |) in + let + at_ := + M.copy (| + γ1_1 + |) in + Value.StructRecord + "halo2_proofs::poly::multiopen::ProverQuery" + [ + ("point", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "rotate_omega", + [] + |), + [ + M.read (| + domain + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ + x + ] + |) + |); + M.read (| + at_ + |) + ] + |)); + ("rotation", + M.read (| + at_ + |)); + ("poly", + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + instance + |), + "halo2_proofs::plonk::prover::InstanceSingle", + "instance_polys" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ], + "index", + [] + |), + [ + column + ] + |) + ] + |)) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "advice_queries" + |) + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.read (| + γ + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + column := + M.copy (| + γ1_0 + |) in + let + at_ := + M.copy (| + γ1_1 + |) in + Value.StructRecord + "halo2_proofs::poly::multiopen::ProverQuery" + [ + ("point", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "rotate_omega", + [] + |), + [ + M.read (| + domain + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ + x + ] + |) + |); + M.read (| + at_ + |) + ] + |)); + ("rotation", + M.read (| + at_ + |)); + ("poly", + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + advice + |), + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle", + "advice_polys" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ], + "index", + [] + |), + [ + column + ] + |) + ] + |)) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ], + "open", + [] + |), + [ + M.read (| + permutation + |); + M.read (| + pk + |); + M.read (| + x + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ], + [], + "flat_map", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ark_std::iterable::Iterable", + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ], + [], + "iter", + [] + |), + [ + lookups + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + p := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ], + "open", + [] + |), + [ + M.read (| + p + |); + M.read (| + pk + |); + M.read (| + x + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "fixed_queries" + |) + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.read (| + γ + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + column := + M.copy (| + γ1_0 + |) in + let + at_ := + M.copy (| + γ1_1 + |) in + Value.StructRecord + "halo2_proofs::poly::multiopen::ProverQuery" + [ + ("point", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "rotate_omega", + [] + |), + [ + M.read (| + domain + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ + x + ] + |) + |); + M.read (| + at_ + |) + ] + |)); + ("rotation", + M.read (| + at_ + |)); + ("poly", + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "fixed_polys" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ], + "index", + [] + |), + [ + column + ] + |) + ] + |)) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::ProvingKey") + [ + C + ], + "open", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "permutation" + |); + M.read (| + x + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::prover::Evaluated") + [ + C + ], + "open", + [] + |), + [ + vanishing; + M.read (| + x + |) + ] + |) + ] + |) + |) in + let + res := + M.copy (| + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + use_gwc in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "std::io::error::Error" + ], + "map_err", + [ + Ty.path + "halo2_proofs::plonk::error::Error"; + Ty.function + [ + Ty.tuple + [ + Ty.path + "std::io::error::Error" + ] + ] + (Ty.path + "halo2_proofs::plonk::error::Error") + ] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::poly::multiopen::gwc::prover::create_proof", + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]) + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.associated + ]; + C; + E; + T + ] + |), + [ + M.read (| + params + |); + M.read (| + transcript + |); + M.read (| + instances + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::plonk::error::Error::Opening" + [])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "std::io::error::Error" + ], + "map_err", + [ + Ty.path + "halo2_proofs::plonk::error::Error"; + Ty.function + [ + Ty.tuple + [ + Ty.path + "std::io::error::Error" + ] + ] + (Ty.path + "halo2_proofs::plonk::error::Error") + ] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::poly::multiopen::shplonk::prover::create_proof", + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_ext::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]) + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.associated + ]; + C; + E; + T + ] + |), + [ + M.read (| + params + |); + M.read (| + transcript + |); + M.read (| + instances + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::plonk::error::Error::Opening" + [])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |))) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun + γ => + ltac:(M.monadic + res) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Module create_proof_ext. + (* StructRecord + { + name := "AdviceSingle"; + ty_params := [ "C" ]; + fields := + [ + ("advice_polys", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]; + Ty.path "alloc::alloc::Global" + ]); + ("advice_cosets", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::ExtendedLagrangeCoeff" ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + End create_proof_ext. + + (* + pub fn create_proof_with_shplonk< + C: CurveAffine, + E: EncodedChallenge, + R: RngCore, + T: TranscriptWrite, + ConcreteCircuit: Circuit, + >( + params: &Params, + pk: &ProvingKey, + circuits: &[ConcreteCircuit], + instances: &[&[&[C::Scalar]]], + rng: R, + transcript: &mut T, + ) -> Result<(), Error> { + create_proof_ext(params, pk, circuits, instances, rng, transcript, false) + } + *) + Definition create_proof_with_shplonk (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; E; R; T; ConcreteCircuit ], [ params; pk; circuits; instances; rng; transcript ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let pk := M.alloc (| pk |) in + let circuits := M.alloc (| circuits |) in + let instances := M.alloc (| instances |) in + let rng := M.alloc (| rng |) in + let transcript := M.alloc (| transcript |) in + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::prover::create_proof_ext", + [ C; E; R; T; ConcreteCircuit ] + |), + [ + M.read (| params |); + M.read (| pk |); + M.read (| circuits |); + M.read (| instances |); + M.read (| rng |); + M.read (| transcript |); + Value.Bool false + ] + |))) + | _, _ => M.impossible + end. + + (* + pub fn create_proof< + C: CurveAffine, + E: EncodedChallenge, + R: RngCore, + T: TranscriptWrite, + ConcreteCircuit: Circuit, + >( + params: &Params, + pk: &ProvingKey, + circuits: &[ConcreteCircuit], + instances: &[&[&[C::Scalar]]], + rng: R, + transcript: &mut T, + ) -> Result<(), Error> { + create_proof_ext(params, pk, circuits, instances, rng, transcript, true) + } + *) + Definition create_proof (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; E; R; T; ConcreteCircuit ], [ params; pk; circuits; instances; rng; transcript ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let pk := M.alloc (| pk |) in + let circuits := M.alloc (| circuits |) in + let instances := M.alloc (| instances |) in + let rng := M.alloc (| rng |) in + let transcript := M.alloc (| transcript |) in + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::prover::create_proof_ext", + [ C; E; R; T; ConcreteCircuit ] + |), + [ + M.read (| params |); + M.read (| pk |); + M.read (| circuits |); + M.read (| instances |); + M.read (| rng |); + M.read (| transcript |); + Value.Bool true + ] + |))) + | _, _ => M.impossible + end. + + (* + pub fn create_witness>( + params: &Params, + pk: &ProvingKey, + circuit: &ConcreteCircuit, + instances: &[&[C::Scalar]], + fd: &mut File, + ) -> Result<(), Error> { + let meta = &pk.vk.cs; + let unusable_rows_start = params.n as usize - (meta.blinding_factors() + 1); + AssignWitnessCollection::store_witness( + params, + pk, + instances, + unusable_rows_start, + circuit, + fd, + )?; + Ok(()) + } + *) + Definition create_witness (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; ConcreteCircuit ], [ params; pk; circuit; instances; fd ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let pk := M.alloc (| pk |) in + let circuit := M.alloc (| circuit |) in + let instances := M.alloc (| instances |) in + let fd := M.alloc (| fd |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let meta := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + |) in + let unusable_rows_start := + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)), + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "blinding_factors", + [] + |), + [ M.read (| meta |) ] + |), + Value.Integer 1 + |) + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::helpers::AssignWitnessCollection") + [ C ], + "store_witness", + [ ConcreteCircuit ] + |), + [ + M.read (| params |); + M.read (| pk |); + M.read (| instances |); + M.read (| unusable_rows_start |); + M.read (| circuit |); + M.read (| fd |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + pub fn create_proof_from_witness< + C: CurveAffine, + E: EncodedChallenge, + R: RngCore, + T: TranscriptWrite, + >( + params: &Params, + pk: &ProvingKey, + instances: &[&[&[C::Scalar]]], + mut rng: R, + transcript: &mut T, + fd: &mut File, + use_gwc: bool, + ) -> Result<(), Error> { + let meta = &pk.vk.cs; + let domain = &pk.vk.domain; + + let timer = start_timer!(|| "create single instances"); + let instance = create_single_instances(params, pk, instances, transcript)?; + + end_timer!(timer); + let timer = start_timer!(|| "advice"); + struct AdviceSingle { + pub advice_polys: Vec>, + + #[cfg(not(feature = "cuda"))] + pub advice_cosets: Vec>, + } + + let get_scalar_bits = |x: C::Scalar| { + let repr = x.to_repr(); + let max_scalar_repr_ref: &[u8] = repr.as_ref(); + max_scalar_repr_ref + .iter() + .enumerate() + .fold(0, |acc, (idx, v)| { + if *v == 0 { + acc + } else { + idx * 8 + 8 - v.leading_zeros() as usize + } + }) + }; + + let find_max_scalar_bits = |x: &Vec| { + get_scalar_bits(x.iter().fold(C::Scalar::zero(), |acc, x| acc.max( *x))) + }; + + let advice: Vec>> = instances + .iter() + .map(|_| -> Vec> { + let unusable_rows_start = params.n as usize - (meta.blinding_factors() + 1); + + let mut advice = AssignWitnessCollection::fetch_witness(params, fd) + .expect("fetch witness should not fail"); + + let timer = start_timer!(|| "rng"); + advice.par_iter_mut().for_each(|advice| { + for cell in &mut advice[unusable_rows_start..] { + *cell = C::Scalar::from(u16::rand(&mut OsRng) as u64); + } + }); + end_timer!(timer); + + let timer = start_timer!(|| "commit_lagrange"); + let advice_commitments_projective: Vec<_> = advice + .par_iter() + .map(|advice| { + let max_bits = find_max_scalar_bits(&advice.values); + params.commit_lagrange_with_bound(advice, max_bits) + }) + .collect(); + end_timer!(timer); + + let timer = start_timer!(|| "advice_commitments_projective"); + let mut advice_commitments = vec![C::identity(); advice_commitments_projective.len()]; + C::Curve::batch_normalize(&advice_commitments_projective, &mut advice_commitments); + let advice_commitments = advice_commitments; + drop(advice_commitments_projective); + end_timer!(timer); + + for commitment in &advice_commitments { + transcript.write_point( *commitment).unwrap(); + } + + advice + }) + .collect::>(); + + // Sample theta challenge for keeping lookup columns linearly independent + let theta: ChallengeTheta<_> = transcript.squeeze_challenge_scalar(); + + end_timer!(timer); + let timer = start_timer!(|| format!("lookups {}", pk.vk.cs.lookups.len())); + let (lookups, lookups_commitments): (Vec>>, Vec>) = + instance + .iter() + .zip(advice.iter()) + .map(|(instance, advice)| -> (Vec<_>, Vec<_>) { + pk.vk + .cs + .lookups + .par_iter() + .map(|lookup| { + lookup + .commit_permuted( + pk, + params, + domain, + theta, + &advice, + &pk.fixed_values, + &instance.instance_values, + &mut OsRng, + ) + .unwrap() + }) + .unzip() + }) + .unzip(); + + lookups_commitments.into_iter().for_each(|x| { + x.iter().for_each(|x| { + transcript.write_point(x[0]).unwrap(); + transcript.write_point(x[1]).unwrap(); + }) + }); + end_timer!(timer); + + // Sample beta challenge + let beta: ChallengeBeta<_> = transcript.squeeze_challenge_scalar(); + // Sample gamma challenge + let gamma: ChallengeGamma<_> = transcript.squeeze_challenge_scalar(); + + let (lookups, permutations) = std::thread::scope(|s| { + let permutations = s.spawn(|| { + // prepare permutation value. + instance + .iter() + .zip(advice.iter()) + .map(|(instance, advice)| { + pk.vk.cs.permutation.commit( + params, + pk, + &pk.permutation, + &advice, + &pk.fixed_values, + &instance.instance_values, + beta, + gamma.clone(), + &mut OsRng, + ) + }) + .collect::, _>>() + .unwrap() + }); + + let timer = start_timer!(|| "lookups commit product"); + let lookups: Vec> = lookups + .into_iter() + .map(|lookups| { + lookups + .into_par_iter() + .map(|lookup| lookup.commit_product(pk, params, beta, gamma).unwrap()) + .collect::>() + }) + .collect::>(); + end_timer!(timer); + + let timer = start_timer!(|| "lookups add blinding value"); + let lookups: Vec> = lookups + .into_iter() + .map(|lookups| { + lookups + .into_iter() + .map(|(l0, l1, mut z)| { + for _ in 0..pk.vk.cs.blinding_factors() { + z.push(C::Scalar::random(&mut rng)) + } + (l0, l1, pk.vk.domain.lagrange_from_vec(z)) + }) + .collect::>() + }) + .collect::>>(); + end_timer!(timer); + + let timer = start_timer!(|| "lookups msm and fft"); + let (lookups_z_commitments, lookups): (Vec>, Vec>) = lookups + .into_iter() + .map(|lookups| { + lookups + .into_par_iter() + .map(|l| { + let (product_poly, c) = params.commit_lagrange_and_ifft( + l.2, + &pk.vk.domain.get_omega_inv(), + &pk.vk.domain.ifft_divisor, + ); + let c = c.to_affine(); + ( + c, + lookup::prover::Committed { + permuted_input_poly: pk.vk.domain.lagrange_to_coeff_st(l.0), + permuted_table_poly: pk.vk.domain.lagrange_to_coeff_st(l.1), + product_poly, + }, + ) + }) + .collect::>() + .into_iter() + .unzip() + }) + .unzip(); + end_timer!(timer); + + let timer = start_timer!(|| "permutation commit"); + let permutations = permutations + .join() + .expect("permutations thread failed unexpectedly"); + + let permutations: Vec<_> = permutations + .into_iter() + .map(|permutations| { + let (c, sets): (Vec<_>, _) = permutations + .into_par_iter() + .map(|z| { + let (permutation_product_poly, permutation_product_commitment_projective) = + params.commit_lagrange_and_ifft( + z, + &pk.vk.domain.get_omega_inv(), + &pk.vk.domain.ifft_divisor, + ); + + #[cfg(not(feature = "cuda"))] + let permutation_product_coset = + domain.coeff_to_extended(permutation_product_poly.clone()); + + let permutation_product_commitment = + permutation_product_commitment_projective.to_affine(); + + ( + permutation_product_commitment, + permutation::prover::CommittedSet { + permutation_product_poly, + #[cfg(not(feature = "cuda"))] + permutation_product_coset, + }, + ) + }) + .unzip(); + (c, permutation::prover::Committed { sets }) + }) + .collect(); + + for (cl, _) in permutations.iter() { + for c in cl { + transcript.write_point( *c).unwrap(); + } + } + + let permutations: Vec<_> = permutations.into_iter().map(|x| x.1).collect(); + end_timer!(timer); + + lookups_z_commitments + .into_iter() + .for_each(|lookups_z_commitments| { + lookups_z_commitments + .into_iter() + .for_each(|lookups_z_commitment| { + transcript.write_point(lookups_z_commitment).unwrap() + }) + }); + + (lookups, permutations) + }); + + let timer = start_timer!(|| "vanishing commit"); + // Commit to the vanishing argument's random polynomial for blinding h(x_3) + let vanishing = vanishing::Argument::commit(params, domain, rng, transcript)?; + + // Obtain challenge for keeping all separate gates linearly independent + let y: ChallengeY<_> = transcript.squeeze_challenge_scalar(); + + end_timer!(timer); + let timer = start_timer!(|| "h_poly"); + // Evaluate the h(X) polynomial + + let advice = advice + .into_iter() + .map(|advice| { + let timer = start_timer!(|| "lagrange_to_coeff_st"); + let advice_polys: Vec<_> = advice + .into_par_iter() + .map(|poly| domain.lagrange_to_coeff_st(poly)) + .collect(); + end_timer!(timer); + + #[cfg(not(feature = "cuda"))] + let advice_cosets: Vec<_> = advice_polys + .iter() + .map(|poly| domain.coeff_to_extended(poly.clone())) + .collect(); + + AdviceSingle:: { + advice_polys, + #[cfg(not(feature = "cuda"))] + advice_cosets, + } + }) + .collect::>(); + + #[cfg(feature = "cuda")] + let h_poly = pk.ev.evaluate_h( + pk, + advice.iter().map(|a| &a.advice_polys).collect(), + instance.iter().map(|i| &i.instance_polys).collect(), + *y, + *beta, + *gamma, + *theta, + &lookups, + &permutations, + ); + + #[cfg(not(feature = "cuda"))] + let h_poly = pk.ev.evaluate_h( + pk, + advice.iter().map(|a| &a.advice_cosets).collect(), + instance.iter().map(|i| &i.instance_cosets).collect(), + *y, + *beta, + *gamma, + *theta, + &lookups, + &permutations, + ); + + end_timer!(timer); + let timer = start_timer!(|| "vanishing construct"); + // Construct the vanishing argument's h(X) commitments + let vanishing = vanishing.construct(params, domain, h_poly, transcript)?; + + let x: ChallengeX<_> = transcript.squeeze_challenge_scalar(); + let xn = x.pow(&[params.n as u64, 0, 0, 0]); + end_timer!(timer); + + let timer = start_timer!(|| "eval poly"); + + let mut inputs = vec![]; + + // Compute and hash instance evals for each circuit instance + for instance in instance.iter() { + // Evaluate polynomials at omega^i x + meta.instance_queries.iter().for_each(|&(column, at)| { + inputs.push(( + &instance.instance_polys[column.index()], + domain.rotate_omega( *x, at), + )) + }) + } + + // Compute and hash advice evals for each circuit instance + for advice in advice.iter() { + // Evaluate polynomials at omega^i x + meta.advice_queries.iter().for_each(|&(column, at)| { + inputs.push(( + &advice.advice_polys[column.index()], + domain.rotate_omega( *x, at), + )) + }) + } + + // Compute and hash fixed evals (shared across all circuit instances) + meta.fixed_queries.iter().for_each(|&(column, at)| { + inputs.push((&pk.fixed_polys[column.index()], domain.rotate_omega( *x, at))) + }); + + for eval in inputs + .into_par_iter() + .map(|(a, b)| eval_polynomial_st(a, b)) + .collect::>() + { + transcript.write_scalar(eval)?; + } + + end_timer!(timer); + let timer = start_timer!(|| "eval poly vanishing"); + let vanishing = vanishing.evaluate(x, xn, domain, transcript)?; + + end_timer!(timer); + let timer = start_timer!(|| "eval poly permutation"); + // Evaluate common permutation data + pk.permutation.evaluate(x, transcript)?; + + // Evaluate the permutations, if any, at omega^i x. + let permutations: Vec> = permutations + .into_iter() + .map(|permutation| -> Result<_, _> { permutation.construct().evaluate(pk, x, transcript) }) + .collect::, _>>()?; + + end_timer!(timer); + + let timer = start_timer!(|| "eval poly lookups"); + // Evaluate the lookups, if any, at omega^i x. + let (lookups, evals): ( + Vec>>, + Vec>>, + ) = lookups + .into_iter() + .map(|lookups| lookups.into_par_iter().map(|p| p.evaluate(pk, x)).unzip()) + .unzip(); + evals.into_iter().for_each(|evals| { + evals.into_iter().for_each(|evals| { + evals + .into_iter() + .for_each(|eval| transcript.write_scalar(eval).unwrap()) + }) + }); + end_timer!(timer); + + let timer = start_timer!(|| "multi open"); + let instances = instance + .iter() + .zip(advice.iter()) + .zip(permutations.iter()) + .zip(lookups.iter()) + .flat_map(|(((instance, advice), permutation), lookups)| { + iter::empty() + .chain( + pk.vk + .cs + .instance_queries + .iter() + .map(move |&(column, at)| ProverQuery { + point: domain.rotate_omega( *x, at), + rotation: at, + poly: &instance.instance_polys[column.index()], + }), + ) + .chain( + pk.vk + .cs + .advice_queries + .iter() + .map(move |&(column, at)| ProverQuery { + point: domain.rotate_omega( *x, at), + rotation: at, + poly: &advice.advice_polys[column.index()], + }), + ) + .chain(permutation.open(pk, x)) + .chain(lookups.iter().flat_map(move |p| p.open(pk, x)).into_iter()) + }) + .chain( + pk.vk + .cs + .fixed_queries + .iter() + .map(|&(column, at)| ProverQuery { + point: domain.rotate_omega( *x, at), + rotation: at, + poly: &pk.fixed_polys[column.index()], + }), + ) + .chain(pk.permutation.open(x)) + // We query the h(X) polynomial at x + .chain(vanishing.open(x)); + + let res = if use_gwc { + multiopen::gwc::create_proof(params, transcript, instances).map_err(|_| Error::Opening) + } else { + multiopen::shplonk::create_proof(params, transcript, instances).map_err(|_| Error::Opening) + }; + end_timer!(timer); + res + } + *) + Definition create_proof_from_witness (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; E; R; T ], [ params; pk; instances; rng; transcript; fd; use_gwc ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let pk := M.alloc (| pk |) in + let instances := M.alloc (| instances |) in + let rng := M.alloc (| rng |) in + let transcript := M.alloc (| transcript |) in + let fd := M.alloc (| fd |) in + let use_gwc := M.alloc (| use_gwc |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let meta := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + |) in + let domain := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + |) in + let timer := + M.alloc (| Value.StructTuple "ark_std::perf_trace::inner::TimerInfo" [] |) in + let instance := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::prover::InstanceSingle") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::prover::create_single_instances", + [ C; E; T ] + |), + [ + M.read (| params |); + M.read (| pk |); + M.read (| instances |); + M.read (| transcript |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple "ark_std::perf_trace::inner::TimerInfo" [] + |) in + let get_scalar_bits := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.read (| + let repr := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::PrimeField", + Ty.associated, + [], + "to_repr", + [] + |), + [ x ] + |) + |) in + let max_scalar_repr_ref := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] + ], + "as_ref", + [] + |), + [ repr ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "u8" ] + ], + [], + "fold", + [ + Ty.path "usize"; + Ty.function + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ Ty.path "u8" ] + ] + ] + ] + (Ty.path "usize") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "u8" ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "u8" ], + "iter", + [] + |), + [ M.read (| max_scalar_repr_ref |) ] + |) + ] + |); + Value.Integer 0; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let idx := + M.copy (| γ0_0 |) in + let v := + M.copy (| γ0_1 |) in + M.read (| + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| + M.read (| + v + |) + |)) + (Value.Integer + 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + acc)); + fun γ => + ltac:(M.monadic + (M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.mul (| + Integer.Usize, + M.read (| + idx + |), + Value.Integer + 8 + |), + Value.Integer + 8 + |), + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path + "u8", + "leading_zeros", + [] + |), + [ + M.read (| + M.read (| + v + |) + |) + ] + |)) + |) + |))) + ] + |) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let find_max_scalar_bits := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [ Ty.associated ] ] + (Ty.path "usize"), + [ Ty.tuple [ Ty.associated ] ], + "call", + [] + |), + [ + get_scalar_bits; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.associated ], + [], + "fold", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.associated; + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ] + ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ark_std::iterable::Iterable", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "iter", + [] + |), + [ x ] + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "zero", + [] + |), + [] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := + M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let x := + M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.associated, + [], + "max", + [] + |), + [ + M.read (| + acc + |); + M.read (| + M.read (| x |) + |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let advice := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ] + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] + ] + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ] + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] + ] + ] + ] + ], + "iter", + [] + |), + [ M.read (| instances |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let unusable_rows_start := + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)), + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "blinding_factors", + [] + |), + [ M.read (| meta |) ] + |), + Value.Integer 1 + |) + |) + |) in + let advice := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::helpers::AssignWitnessCollection") + [ C ], + "fetch_witness", + [] + |), + [ + M.read (| params |); + M.read (| fd |) + ] + |); + M.read (| + Value.String + "fetch witness should not fail" + |) + ] + |) + |) in + let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::slice::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelRefMutIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "par_iter_mut", + [] + |), + [ advice ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let advice := + M.copy (| γ |) in + M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ], + [ + Ty.apply + (Ty.path + "core::ops::range::RangeFrom") + [ + Ty.path + "usize" + ] + ], + "index_mut", + [] + |), + [ + M.read (| + advice + |); + Value.StructRecord + "core::ops::range::RangeFrom" + [ + ("start", + M.read (| + unusable_rows_start + |)) + ] + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + Ty.associated + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + cell := + M.copy (| + γ0_0 + |) in + let + _ := + M.write (| + M.read (| + cell + |), + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.associated, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_trait_method (| + "ark_std::rand_helper::UniformRand", + Ty.path + "u16", + [], + "rand", + [ + Ty.path + "rand_core::os::OsRng" + ] + |), + [ + M.alloc (| + Value.StructTuple + "rand_core::os::OsRng" + [] + |) + ] + |)) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let advice_commitments_projective := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path + "rayon::slice::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + Ty.associated + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::slice::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + Ty.associated; + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelRefIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "par_iter", + [] + |), + [ advice ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + advice := + M.copy (| + γ + |) in + M.read (| + let + max_bits := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + (Ty.path + "usize"), + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ], + "call", + [] + |), + [ + find_max_scalar_bits; + Value.Tuple + [ + M.SubPointer.get_struct_record_field (| + M.read (| + advice + |), + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::Params") + [ + C + ], + "commit_lagrange_with_bound", + [] + |), + [ + M.read (| + params + |); + M.read (| + advice + |); + M.read (| + max_bits + |) + ] + |) + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let advice_commitments := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ C ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "group::prime::PrimeCurveAffine", + C, + [], + "identity", + [] + |), + [] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ + advice_commitments_projective + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::Curve", + Ty.associated, + [], + "batch_normalize", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + advice_commitments_projective + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ advice_commitments + ] + |) + ] + |) + |) in + let advice_commitments := + M.copy (| + advice_commitments + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::mem::drop", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.read (| + advice_commitments_projective + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + advice_commitments + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + C + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + commitment := + M.copy (| + γ0_0 + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "std::io::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ + C; + E + ], + "write_point", + [] + |), + [ + M.read (| + transcript + |); + M.read (| + M.read (| + commitment + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + advice)) + ] + |))) + ] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let theta := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ C; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::plonk::Theta" ] + |), + [ M.read (| transcript |) ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple "ark_std::perf_trace::inner::TimerInfo" [] + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "array") [ C ]; + Ty.path "alloc::alloc::Global" + ] + ]) + ], + [], + "unzip", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "array") [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "array") [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "map", + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "array") [ C ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "array") [ C ]; + Ty.path "alloc::alloc::Global" + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ instance ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ advice ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let instance := M.copy (| γ0_0 |) in + let advice := M.copy (| γ0_1 |) in + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.apply + (Ty.path "array") + [ C ] + ]) + ], + [], + "unzip", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.apply (Ty.path "array") [ C ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "array") + [ C ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.apply + (Ty.path "array") + [ C ] + ]); + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C ]; + Ty.apply + (Ty.path "array") + [ C ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelRefIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "par_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "lookups" + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let lookup := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ + C + ]; + Ty.apply + (Ty.path + "array") + [ + C + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ + Ty.associated + ], + "commit_permuted", + [ + C; + Ty.apply + (Ty.path + "&mut") + [ + Ty.path + "rand_core::os::OsRng" + ] + ] + |), + [ + M.read (| + lookup + |); + M.read (| + pk + |); + M.read (| + params + |); + M.read (| + domain + |); + M.read (| + theta + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + advice + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "fixed_values" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + instance + |), + "halo2_proofs::plonk::prover::InstanceSingle", + "instance_values" + |) + ] + |); + M.alloc (| + Value.StructTuple + "rand_core::os::OsRng" + [] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let lookups := M.copy (| γ0_0 |) in + let lookups_commitments := M.copy (| γ0_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "array") [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "array") [ C ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "array") [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| lookups_commitments |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "array") + [ C ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "array") + [ C ] + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "array") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "array") + [ C ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ x ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := + M.copy (| + γ + |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "std::io::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ + C; + E + ], + "write_point", + [] + |), + [ + M.read (| + transcript + |); + M.read (| + M.SubPointer.get_array_field (| + M.read (| + x + |), + M.alloc (| + Value.Integer + 0 + |) + |) + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "std::io::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ + C; + E + ], + "write_point", + [] + |), + [ + M.read (| + transcript + |); + M.read (| + M.SubPointer.get_array_field (| + M.read (| + x + |), + M.alloc (| + Value.Integer + 1 + |) + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let beta := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ C; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::plonk::Beta" ] + |), + [ M.read (| transcript |) ] + |) + |) in + let gamma := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ C; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::plonk::Gamma" ] + |), + [ M.read (| transcript |) ] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_function (| + "std::thread::scoped::scope", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "std::thread::scoped::Scope" + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ C ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ C ]; + Ty.path "alloc::alloc::Global" + ] + ]); + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ C ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let s := M.copy (| γ |) in + M.read (| + let permutations := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "std::thread::scoped::Scope", + "spawn", + [ + Ty.function + [ Ty.tuple [] + ] + (Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]); + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.read (| s |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + instance + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + advice + ] + |) + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + instance := + M.copy (| + γ0_0 + |) in + let + advice := + M.copy (| + γ0_1 + |) in + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::plonk::permutation::Argument", + "commit", + [ + C; + Ty.apply + (Ty.path + "&mut") + [ + Ty.path + "rand_core::os::OsRng" + ] + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |); + M.read (| + params + |); + M.read (| + pk + |); + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "permutation" + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + advice + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "fixed_values" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + instance + |), + "halo2_proofs::plonk::prover::InstanceSingle", + "instance_values" + |) + ] + |); + M.read (| + beta + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Gamma" + ], + [], + "clone", + [] + |), + [ + gamma + ] + |); + M.alloc (| + Value.StructTuple + "rand_core::os::OsRng" + [] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) in + let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let lookups := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + lookups + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + lookups := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ + C + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ + C + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ + C + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ + C + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]); + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_par_iter", + [] + |), + [ + M.read (| + lookups + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + lookup := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Permuted") + [ + C + ], + "commit_product", + [] + |), + [ + M.read (| + lookup + |); + M.read (| + pk + |); + M.read (| + params + |); + M.read (| + beta + |); + M.read (| + gamma + |) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let lookups := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + lookups + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + lookups := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + lookups + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + γ0_2 := + M.SubPointer.get_tuple_field (| + γ, + 2 + |) in + let + l0 := + M.copy (| + γ0_0 + |) in + let + l1 := + M.copy (| + γ0_1 + |) in + let + z := + M.copy (| + γ0_2 + |) in + M.read (| + let + _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "usize" + ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + Value.Integer + 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ + Ty.associated + ], + "blinding_factors", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |)) + ] + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "usize" + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + z; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "random", + [ + Ty.apply + (Ty.path + "&mut") + [ + R + ] + ] + |), + [ + rng + ] + |) + ] + |) + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + M.alloc (| + Value.Tuple + [ + M.read (| + l0 + |); + M.read (| + l1 + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "lagrange_from_vec", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| + z + |) + ] + |) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let + timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ]) + ], + [], + "unzip", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + lookups + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + lookups := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "unzip", + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + (Ty.tuple + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ] + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + (Ty.tuple + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ] + ]); + Ty.tuple + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_par_iter", + [] + |), + [ + M.read (| + lookups + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + l := + M.copy (| + γ + |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::Params") + [ + C + ], + "commit_lagrange_and_ifft", + [] + |), + [ + M.read (| + params + |); + M.read (| + M.SubPointer.get_tuple_field (| + l, + 2 + |) + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "get_omega_inv", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |) + |); + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |), + "halo2_proofs::poly::domain::EvaluationDomain", + "ifft_divisor" + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + product_poly := + M.copy (| + γ0_0 + |) in + let + c := + M.copy (| + γ0_1 + |) in + let + c := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::Curve", + Ty.associated, + [], + "to_affine", + [] + |), + [ + c + ] + |) + |) in + M.alloc (| + Value.Tuple + [ + M.read (| + c + |); + Value.StructRecord + "halo2_proofs::plonk::lookup::prover::Committed" + [ + ("permuted_input_poly", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "lagrange_to_coeff_st", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| + M.SubPointer.get_tuple_field (| + l, + 0 + |) + |) + ] + |)); + ("permuted_table_poly", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "lagrange_to_coeff_st", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| + M.SubPointer.get_tuple_field (| + l, + 1 + |) + |) + ] + |)); + ("product_poly", + M.read (| + product_poly + |)) + ] + ] + |))) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + lookups_z_commitments := + M.copy (| + γ0_0 + |) in + let + lookups := + M.copy (| + γ0_1 + |) in + M.match_operator (| + timer, + [ + fun + γ => + ltac:(M.monadic + (let + timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let + permutations := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.dyn + [ + ("core::any::Any::Trait", + []) + ]; + Ty.path + "alloc::alloc::Global" + ] + ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::thread::scoped::ScopedJoinHandle") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ], + "join", + [] + |), + [ + M.read (| + permutations + |) + ] + |); + M.read (| + Value.String + "permutations thread failed unexpectedly" + |) + ] + |) + |) in + let + permutations := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + permutations + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + permutations := + M.copy (| + γ + |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + (Ty.tuple + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ] + ]) + ], + [], + "unzip", + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + (Ty.tuple + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ] + ]); + Ty.tuple + [ + C; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::CommittedSet") + [ + C + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_par_iter", + [] + |), + [ + M.read (| + permutations + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + z := + M.copy (| + γ + |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::Params") + [ + C + ], + "commit_lagrange_and_ifft", + [] + |), + [ + M.read (| + params + |); + M.read (| + z + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "get_omega_inv", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |) + |); + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |), + "halo2_proofs::poly::domain::EvaluationDomain", + "ifft_divisor" + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + permutation_product_poly := + M.copy (| + γ0_0 + |) in + let + permutation_product_commitment_projective := + M.copy (| + γ0_1 + |) in + let + permutation_product_coset := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "coeff_to_extended", + [] + |), + [ + M.read (| + domain + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [], + "clone", + [] + |), + [ + permutation_product_poly + ] + |) + ] + |) + |) in + let + permutation_product_commitment := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::Curve", + Ty.associated, + [], + "to_affine", + [] + |), + [ + permutation_product_commitment_projective + ] + |) + |) in + M.alloc (| + Value.Tuple + [ + M.read (| + permutation_product_commitment + |); + Value.StructRecord + "halo2_proofs::plonk::permutation::prover::CommittedSet" + [ + ("permutation_product_poly", + M.read (| + permutation_product_poly + |)); + ("permutation_product_coset", + M.read (| + permutation_product_coset + |)) + ] + ] + |))) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + c := + M.copy (| + γ0_0 + |) in + let + sets := + M.copy (| + γ0_1 + |) in + M.alloc (| + Value.Tuple + [ + M.read (| + c + |); + Value.StructRecord + "halo2_proofs::plonk::permutation::prover::Committed" + [ + ("sets", + M.read (| + sets + |)) + ] + ] + |))) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let + _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + permutations + ] + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + γ0_0 := + M.read (| + γ0_0 + |) in + let + γ2_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let + γ2_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + cl := + M.alloc (| + γ2_0 + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.read (| + cl + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + C + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + c := + M.copy (| + γ0_0 + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "std::io::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ + C; + E + ], + "write_point", + [] + |), + [ + M.read (| + transcript + |); + M.read (| + M.read (| + c + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + let + permutations := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + permutations + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + x := + M.copy (| + γ + |) in + M.read (| + M.SubPointer.get_tuple_field (| + x, + 1 + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun + γ => + ltac:(M.monadic + (let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + lookups_z_commitments + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + lookups_z_commitments := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + C; + Ty.path + "alloc::alloc::Global" + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + C + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + lookups_z_commitments + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + lookups_z_commitment := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "std::io::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ + C; + E + ], + "write_point", + [] + |), + [ + M.read (| + transcript + |); + M.read (| + lookups_z_commitment + |) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.Tuple + [ + M.read (| + lookups + |); + M.read (| + permutations + |) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let lookups := M.copy (| γ0_0 |) in + let permutations := M.copy (| γ0_1 |) in + let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let vanishing := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::prover::Committed") + [ C ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::Argument") + [ C ], + "commit", + [ E; R; T ] + |), + [ + M.read (| params |); + M.read (| domain |); + M.read (| rng |); + M.read (| transcript |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let y := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ C; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::plonk::Y" ] + |), + [ M.read (| transcript |) ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let advice := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ C ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ C ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ C ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ C ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| advice |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + advice := + M.copy (| + γ + |) in + M.read (| + let + timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let + advice_polys := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]); + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_par_iter", + [] + |), + [ + M.read (| + advice + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + poly := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "lagrange_to_coeff_st", + [] + |), + [ + M.read (| + domain + |); + M.read (| + poly + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun + γ => + ltac:(M.monadic + (let + advice_cosets := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + advice_polys + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + poly := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "coeff_to_extended", + [] + |), + [ + M.read (| + domain + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [], + "clone", + [] + |), + [ + M.read (| + poly + |) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle" + [ + ("advice_polys", + M.read (| + advice_polys + |)); + ("advice_cosets", + M.read (| + advice_cosets + |)) + ] + |))) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let h_poly := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::evaluation::Evaluator") + [ C ], + "evaluate_h", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "ev" + |); + M.read (| pk |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ C ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ C ] + ] + ] + ] + (Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ C ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ C + ] + ] + ] + ] + (Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ C ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ advice ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.SubPointer.get_struct_record_field (| + M.read (| + a + |), + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle", + "advice_cosets" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ] + ] + ] + ] + (Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C + ] + ] + ] + ] + (Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::ExtendedLagrangeCoeff" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ C ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ instance ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + i := + M.copy (| + γ + |) in + M.SubPointer.get_struct_record_field (| + M.read (| + i + |), + "halo2_proofs::plonk::prover::InstanceSingle", + "instance_cosets" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Y" + ], + [], + "deref", + [] + |), + [ y ] + |) + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Beta" + ], + [], + "deref", + [] + |), + [ beta ] + |) + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Gamma" + ], + [], + "deref", + [] + |), + [ gamma ] + |) + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::Theta" + ], + [], + "deref", + [] + |), + [ theta ] + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ C ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ lookups ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ C ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ permutations ] + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let vanishing := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::prover::Constructed") + [ C ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::prover::Committed") + [ C ], + "construct", + [ E; T ] + |), + [ + M.read (| + vanishing + |); + M.read (| + params + |); + M.read (| + domain + |); + M.read (| + h_poly + |); + M.read (| + transcript + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) + |) in + let x := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ C; E ], + "squeeze_challenge_scalar", + [ + Ty.path + "halo2_proofs::plonk::X" + ] + |), + [ + M.read (| + transcript + |) + ] + |) + |) in + let xn := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::fields::BaseExt", + Ty.associated, + [], + "pow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ x ] + |); + M.alloc (| + Value.Array + [ + M.read (| + M.use + (M.SubPointer.get_struct_record_field (| + M.read (| + params + |), + "halo2_proofs::poly::commitment::Params", + "n" + |)) + |); + Value.Integer + 0; + Value.Integer + 0; + Value.Integer + 0 + ] + |) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let inputs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + instance + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + instance := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + meta + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "instance_queries" + |) + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.read (| + γ + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + column := + M.copy (| + γ1_0 + |) in + let + at_ := + M.copy (| + γ1_1 + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + inputs; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + instance + |), + "halo2_proofs::plonk::prover::InstanceSingle", + "instance_polys" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ], + "index", + [] + |), + [ + column + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "rotate_omega", + [] + |), + [ + M.read (| + domain + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ + x + ] + |) + |); + M.read (| + at_ + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + advice + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + advice := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + meta + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "advice_queries" + |) + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.read (| + γ + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + column := + M.copy (| + γ1_0 + |) in + let + at_ := + M.copy (| + γ1_1 + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + inputs; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + advice + |), + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle", + "advice_polys" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ], + "index", + [] + |), + [ + column + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "rotate_omega", + [] + |), + [ + M.read (| + domain + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ + x + ] + |) + |); + M.read (| + at_ + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + meta + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "fixed_queries" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match + γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.read (| + γ + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + column := + M.copy (| + γ1_0 + |) in + let + at_ := + M.copy (| + γ1_1 + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + inputs; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "fixed_polys" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ], + "index", + [] + |), + [ + column + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "rotate_omega", + [] + |), + [ + M.read (| + domain + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ + x + ] + |) + |); + M.read (| + at_ + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ] + ] + ] + Ty.associated + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ] + ] + ] + Ty.associated; + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ]; + Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_par_iter", + [] + |), + [ + M.read (| + inputs + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + a := + M.copy (| + γ0_0 + |) in + let + b := + M.copy (| + γ0_1 + |) in + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::eval_polynomial_st", + [ + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [], + "deref", + [] + |), + [ + M.read (| + a + |) + ] + |); + M.read (| + b + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + eval := + M.copy (| + γ0_0 + |) in + let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ + C; + E + ], + "write_scalar", + [] + |), + [ + M.read (| + transcript + |); + M.read (| + eval + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let + timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let + vanishing := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::prover::Evaluated") + [ + C + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::prover::Constructed") + [ + C + ], + "evaluate", + [ + E; + T + ] + |), + [ + M.read (| + vanishing + |); + M.read (| + x + |); + M.read (| + xn + |); + M.read (| + domain + |); + M.read (| + transcript + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun γ => + ltac:(M.monadic + (let + timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::ProvingKey") + [ + C + ], + "evaluate", + [ + E; + T + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "permutation" + |); + M.read (| + x + |); + M.read (| + transcript + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let + permutations := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + permutations + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + permutation := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Constructed") + [ + C + ], + "evaluate", + [ + E; + T + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Committed") + [ + C + ], + "construct", + [] + |), + [ + M.read (| + permutation + |) + ] + |); + M.read (| + pk + |); + M.read (| + x + |); + M.read (| + transcript + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun + γ => + ltac:(M.monadic + (let + timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]) + ], + [], + "unzip", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + lookups + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + lookups := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]) + ], + [], + "unzip", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path + "rayon::vec::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]); + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_par_iter", + [] + |), + [ + M.read (| + lookups + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + p := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Committed") + [ + C + ], + "evaluate", + [] + |), + [ + M.read (| + p + |); + M.read (| + pk + |); + M.read (| + x + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + lookups := + M.copy (| + γ0_0 + |) in + let + evals := + M.copy (| + γ0_1 + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + evals + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + evals := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + evals + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + evals := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.associated + ] + ] + (Ty.tuple + []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + evals + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + eval := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "std::io::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ + C; + E + ], + "write_scalar", + [] + |), + [ + M.read (| + transcript + |); + M.read (| + eval + |) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun + γ => + ltac:(M.monadic + (let + timer := + M.alloc (| + Value.StructTuple + "ark_std::perf_trace::inner::TimerInfo" + [] + |) in + let + instances := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]) + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ], + [], + "chain", + [ + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]) + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ], + [], + "chain", + [ + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]) + ], + [], + "chain", + [ + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ] + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + instance + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + advice + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + permutations + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + lookups + ] + |) + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + γ2_0 := + M.SubPointer.get_tuple_field (| + γ1_0, + 0 + |) in + let + γ2_1 := + M.SubPointer.get_tuple_field (| + γ1_0, + 1 + |) in + let + instance := + M.copy (| + γ2_0 + |) in + let + advice := + M.copy (| + γ2_1 + |) in + let + permutation := + M.copy (| + γ1_1 + |) in + let + lookups := + M.copy (| + γ0_1 + |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ], + [], + "chain", + [ + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ], + [], + "chain", + [ + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "core::iter::sources::empty::empty", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ] + |), + [] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "instance_queries" + |) + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.read (| + γ + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + column := + M.copy (| + γ1_0 + |) in + let + at_ := + M.copy (| + γ1_1 + |) in + Value.StructRecord + "halo2_proofs::poly::multiopen::ProverQuery" + [ + ("point", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "rotate_omega", + [] + |), + [ + M.read (| + domain + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ + x + ] + |) + |); + M.read (| + at_ + |) + ] + |)); + ("rotation", + M.read (| + at_ + |)); + ("poly", + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + instance + |), + "halo2_proofs::plonk::prover::InstanceSingle", + "instance_polys" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ], + "index", + [] + |), + [ + column + ] + |) + ] + |)) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "advice_queries" + |) + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.read (| + γ + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + column := + M.copy (| + γ1_0 + |) in + let + at_ := + M.copy (| + γ1_1 + |) in + Value.StructRecord + "halo2_proofs::poly::multiopen::ProverQuery" + [ + ("point", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "rotate_omega", + [] + |), + [ + M.read (| + domain + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ + x + ] + |) + |); + M.read (| + at_ + |) + ] + |)); + ("rotation", + M.read (| + at_ + |)); + ("poly", + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + advice + |), + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle", + "advice_polys" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ], + "index", + [] + |), + [ + column + ] + |) + ] + |)) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ], + "open", + [] + |), + [ + M.read (| + permutation + |); + M.read (| + pk + |); + M.read (| + x + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ], + [], + "flat_map", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ark_std::iterable::Iterable", + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ], + [], + "iter", + [] + |), + [ + lookups + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + p := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ], + "open", + [] + |), + [ + M.read (| + p + |); + M.read (| + pk + |); + M.read (| + x + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "fixed_queries" + |) + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.read (| + γ + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + column := + M.copy (| + γ1_0 + |) in + let + at_ := + M.copy (| + γ1_1 + |) in + Value.StructRecord + "halo2_proofs::poly::multiopen::ProverQuery" + [ + ("point", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "rotate_omega", + [] + |), + [ + M.read (| + domain + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ + x + ] + |) + |); + M.read (| + at_ + |) + ] + |)); + ("rotation", + M.read (| + at_ + |)); + ("poly", + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "fixed_polys" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ], + "index", + [] + |), + [ + column + ] + |) + ] + |)) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::ProvingKey") + [ + C + ], + "open", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + pk + |), + "halo2_proofs::plonk::ProvingKey", + "permutation" + |); + M.read (| + x + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::prover::Evaluated") + [ + C + ], + "open", + [] + |), + [ + vanishing; + M.read (| + x + |) + ] + |) + ] + |) + |) in + let + res := + M.copy (| + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + use_gwc in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "std::io::error::Error" + ], + "map_err", + [ + Ty.path + "halo2_proofs::plonk::error::Error"; + Ty.function + [ + Ty.tuple + [ + Ty.path + "std::io::error::Error" + ] + ] + (Ty.path + "halo2_proofs::plonk::error::Error") + ] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::poly::multiopen::gwc::prover::create_proof", + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]) + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.associated + ]; + C; + E; + T + ] + |), + [ + M.read (| + params + |); + M.read (| + transcript + |); + M.read (| + instances + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::plonk::error::Error::Opening" + [])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "std::io::error::Error" + ], + "map_err", + [ + Ty.path + "halo2_proofs::plonk::error::Error"; + Ty.function + [ + Ty.tuple + [ + Ty.path + "std::io::error::Error" + ] + ] + (Ty.path + "halo2_proofs::plonk::error::Error") + ] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::poly::multiopen::shplonk::prover::create_proof", + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::InstanceSingle") + [ + C + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::create_proof_from_witness::AdviceSingle") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::prover::Evaluated") + [ + C + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::prover::Evaluated") + [ + C + ] + ] + ] + ] + Ty.associated + ] + ]) + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ]) + ] + ]; + Ty.associated + ]; + Ty.associated + ]; + C; + E; + T + ] + |), + [ + M.read (| + params + |); + M.read (| + transcript + |); + M.read (| + instances + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::plonk::error::Error::Opening" + [])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |))) + ] + |) + |) in + M.match_operator (| + timer, + [ + fun + γ => + ltac:(M.monadic + res) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Module create_proof_from_witness. + (* StructRecord + { + name := "AdviceSingle"; + ty_params := [ "C" ]; + fields := + [ + ("advice_polys", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]; + Ty.path "alloc::alloc::Global" + ]); + ("advice_cosets", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::ExtendedLagrangeCoeff" ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + End create_proof_from_witness. + + (* + pub fn generate_advice_from_synthesize<'a, C: CurveAffine, ConcreteCircuit: Circuit>( + params: &'a Params, + pk: &'a ProvingKey, + circuit: &'a ConcreteCircuit, + instances: &'a [&'a [C::Scalar]], + advices: &'a [*mut [C::Scalar]], + ) { + use Assigned; + use Column; + use Error; + use FloorPlanner; + + let mut meta = ConstraintSystem::default(); + let config = ConcreteCircuit::configure(&mut meta); + + let meta = &pk.vk.cs; + + #[derive(Clone)] + struct WitnessCollection<'a, F: Field> { + pub advice: &'a [*mut [F]], + instances: &'a [&'a [F]], + usable_rows: core::ops::RangeTo, + _marker: std::marker::PhantomData, + } + + impl<'a, F: Field> Assignment for WitnessCollection<'a, F> { + fn is_in_prove_mode(&self) -> bool { + true + } + + fn enter_region(&self, _: N) + where + NR: Into, + N: FnOnce() -> NR, + { + } + fn exit_region(&self) {} + + fn enable_selector(&self, _: A, _: &Selector, _: usize) -> Result<(), Error> + where + A: FnOnce() -> AR, + AR: Into, + { + Ok(()) + } + + fn query_instance(&self, column: Column, row: usize) -> Result, Error> { + if !self.usable_rows.contains(&row) { + assert!(false) + } + + Ok(self + .instances + .get(column.index()) + .and_then(|column| column.get(row)) + .map(|v| Some( *v)) + .unwrap()) + } + + fn assign_advice( + &self, + _: A, + column: Column, + row: usize, + to: V, + ) -> Result<(), Error> + where + V: FnOnce() -> Result, + VR: Into>, + A: FnOnce() -> AR, + AR: Into, + { + if !self.usable_rows.contains(&row) { + assert!(false) + } + + let assigned: Assigned = to()?.into(); + let v = if let Some(inv) = assigned.denominator() { + assigned.numerator() * inv.invert().unwrap() + } else { + assigned.numerator() + }; + + *self + .advice + .get(column.index()) + .and_then(|v| unsafe { ( *v).as_mut().unwrap() }.get_mut(row)) + .ok_or(Error::BoundsFailure)? = v; + + Ok(()) + } + + fn assign_fixed( + &self, + _: A, + _: Column, + _: usize, + _: V, + ) -> Result<(), Error> + where + V: FnOnce() -> Result, + VR: Into>, + A: FnOnce() -> AR, + AR: Into, + { + // We only care about advice columns here + + Ok(()) + } + + fn copy(&self, _: Column, _: usize, _: Column, _: usize) -> Result<(), Error> { + // We only care about advice columns here + + Ok(()) + } + + fn fill_from_row( + &self, + _: Column, + _: usize, + _: Option>, + ) -> Result<(), Error> { + Ok(()) + } + + fn push_namespace(&self, _: N) + where + NR: Into, + N: FnOnce() -> NR, + { + // Do nothing; we don't care about namespaces in this context. + } + + fn pop_namespace(&self, _: Option) { + // Do nothing; we don't care about namespaces in this context. + } + } + + let unusable_rows_start = params.n as usize - (meta.blinding_factors() + 1); + + let mut witness = WitnessCollection { + advice: advices, + instances, + // The prover will not be allowed to assign values to advice + // cells that exist within inactive rows, which include some + // number of blinding factors and an extra row for use in the + // permutation argument. + usable_rows: ..unusable_rows_start, + _marker: std::marker::PhantomData, + }; + + let timer = start_timer!(|| "synthesize"); + // Synthesize the circuit to obtain the witness and other information. + ConcreteCircuit::FloorPlanner::synthesize( + &mut witness, + circuit, + config.clone(), + meta.constants.clone(), + ) + .unwrap(); + end_timer!(timer); + } + *) + Definition generate_advice_from_synthesize (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; ConcreteCircuit ], [ params; pk; circuit; instances; advices ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let pk := M.alloc (| pk |) in + let circuit := M.alloc (| circuit |) in + let instances := M.alloc (| instances |) in + let advices := M.alloc (| advices |) in + M.read (| + let meta := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + [], + "default", + [] + |), + [] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::Circuit", + ConcreteCircuit, + [ Ty.associated ], + "configure", + [] + |), + [ meta ] + |) + |) in + let meta := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| pk |), + "halo2_proofs::plonk::ProvingKey", + "vk" + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + |) in + let unusable_rows_start := + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)), + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "blinding_factors", + [] + |), + [ M.read (| meta |) ] + |), + Value.Integer 1 + |) + |) + |) in + let witness := + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::prover::generate_advice_from_synthesize::WitnessCollection" + [ + ("advice", M.read (| advices |)); + ("instances", M.read (| instances |)); + ("usable_rows", + Value.StructRecord + "core::ops::range::RangeTo" + [ ("end_", M.read (| unusable_rows_start |)) ]); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ] + |) in + let timer := + M.alloc (| Value.StructTuple "ark_std::perf_trace::inner::TimerInfo" [] |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::circuit::FloorPlanner", + Ty.associated, + [], + "synthesize", + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::generate_advice_from_synthesize::WitnessCollection") + [ Ty.associated ]; + ConcreteCircuit + ] + |), + [ + witness; + M.read (| circuit |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.associated, + [], + "clone", + [] + |), + [ config ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| meta |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "constants" + |) + ] + |) + ] + |) + ] + |) + |) in + M.match_operator (| + timer, + [ fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) ] + |) + |))) + | _, _ => M.impossible + end. + + Module generate_advice_from_synthesize. + (* StructRecord + { + name := "WitnessCollection"; + ty_params := [ "F" ]; + fields := + [ + ("advice", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.apply (Ty.path "*mut") [ Ty.apply (Ty.path "slice") [ F ] ] ] + ]); + ("instances", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "slice") [ F ] ] ] + ]); + ("usable_rows", Ty.apply (Ty.path "core::ops::range::RangeTo") [ Ty.path "usize" ]); + ("_marker", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_for_halo2_proofs_plonk_prover_generate_advice_from_synthesize_WitnessCollection_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::generate_advice_from_synthesize::WitnessCollection") + [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::plonk::prover::generate_advice_from_synthesize::WitnessCollection" + [ + ("advice", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.apply (Ty.path "*mut") [ Ty.apply (Ty.path "slice") [ F ] ] ] + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::prover::generate_advice_from_synthesize::WitnessCollection", + "advice" + |) + ] + |)); + ("instances", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "slice") [ F ] ] ] + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::prover::generate_advice_from_synthesize::WitnessCollection", + "instances" + |) + ] + |)); + ("usable_rows", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::ops::range::RangeTo") [ Ty.path "usize" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::prover::generate_advice_from_synthesize::WitnessCollection", + "usable_rows" + |) + ] + |)); + ("_marker", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::prover::generate_advice_from_synthesize::WitnessCollection", + "_marker" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_ff_Field_F_for_halo2_proofs_plonk_prover_generate_advice_from_synthesize_WitnessCollection_F. + + Module Impl_halo2_proofs_plonk_circuit_Assignment_where_ff_Field_F_F_for_halo2_proofs_plonk_prover_generate_advice_from_synthesize_WitnessCollection_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "halo2_proofs::plonk::prover::generate_advice_from_synthesize::WitnessCollection") + [ F ]. + + (* + fn is_in_prove_mode(&self) -> bool { + true + } + *) + Definition is_in_prove_mode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.Bool true)) + | _, _ => M.impossible + end. + + (* + fn enter_region(&self, _: N) + where + NR: Into, + N: FnOnce() -> NR, + { + } + *) + Definition enter_region (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ NR; N ], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Tuple [])) ] |))) + | _, _ => M.impossible + end. + + (* fn exit_region(&self) {} *) + Definition exit_region (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.Tuple [])) + | _, _ => M.impossible + end. + + (* + fn enable_selector(&self, _: A, _: &Selector, _: usize) -> Result<(), Error> + where + A: FnOnce() -> AR, + AR: Into, + { + Ok(()) + } + *) + Definition enable_selector (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ A; AR ], [ self; β1; β2; β3 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let β2 := M.alloc (| β2 |) in + let β3 := M.alloc (| β3 |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β2, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β3, + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ])) + ] + |))) + ] + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn query_instance(&self, column: Column, row: usize) -> Result, Error> { + if !self.usable_rows.contains(&row) { + assert!(false) + } + + Ok(self + .instances + .get(column.index()) + .and_then(|column| column.get(row)) + .map(|v| Some( *v)) + .unwrap()) + } + *) + Definition query_instance (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; column; row ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let column := M.alloc (| column |) in + let row := M.alloc (| row |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::RangeTo") + [ Ty.path "usize" ], + "contains", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::prover::generate_advice_from_synthesize::WitnessCollection", + "usable_rows" + |); + row + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use (M.alloc (| UnOp.Pure.not (Value.Bool false) |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "assertion failed: false" |) ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "core::option::Option") [ F ] ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ F ] ], + "map", + [ + Ty.apply (Ty.path "core::option::Option") [ F ]; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ F ] ] ] + (Ty.apply (Ty.path "core::option::Option") [ F ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ F ] ] + ] + ], + "and_then", + [ + Ty.apply (Ty.path "&") [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ F ] ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ F ] ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ F ] ] + ], + "get", + [ Ty.path "usize" ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::prover::generate_advice_from_synthesize::WitnessCollection", + "instances" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ], + "index", + [] + |), + [ column ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let column := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "get", + [ Ty.path "usize" ] + |), + [ + M.read (| M.read (| column |) |); + M.read (| row |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let v := M.copy (| γ |) in + Value.StructTuple + "core::option::Option::Some" + [ M.read (| M.read (| v |) |) ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + fn assign_advice( + &self, + _: A, + column: Column, + row: usize, + to: V, + ) -> Result<(), Error> + where + V: FnOnce() -> Result, + VR: Into>, + A: FnOnce() -> AR, + AR: Into, + { + if !self.usable_rows.contains(&row) { + assert!(false) + } + + let assigned: Assigned = to()?.into(); + let v = if let Some(inv) = assigned.denominator() { + assigned.numerator() * inv.invert().unwrap() + } else { + assigned.numerator() + }; + + *self + .advice + .get(column.index()) + .and_then(|v| unsafe { ( *v).as_mut().unwrap() }.get_mut(row)) + .ok_or(Error::BoundsFailure)? = v; + + Ok(()) + } + *) + Definition assign_advice (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ V; VR; A; AR ], [ self; β1; column; row; to ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let column := M.alloc (| column |) in + let row := M.alloc (| row |) in + let to := M.alloc (| to |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::RangeTo") + [ Ty.path "usize" ], + "contains", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::prover::generate_advice_from_synthesize::WitnessCollection", + "usable_rows" + |); + row + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not (Value.Bool false) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic", + [] + |), + [ + M.read (| + Value.String "assertion failed: false" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let assigned := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + VR, + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ], + "into", + [] + |), + [ + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ VR; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + V, + [ Ty.tuple [] ], + "call_once", + [] + |), + [ M.read (| to |); Value.Tuple [] ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) + ] + |) + |) in + let v := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ], + "denominator", + [] + |), + [ assigned ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let inv := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ F ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ], + "numerator", + [] + |), + [ assigned ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "subtle::CtOption") [ F ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "invert", + [] + |), + [ inv ] + |) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ], + "numerator", + [] + |), + [ assigned ] + |) + |))) + ] + |) + |) in + let _ := + M.write (| + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "&mut") [ F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&mut") [ F ] ], + "ok_or", + [ Ty.path "halo2_proofs::plonk::error::Error" ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "*mut") + [ Ty.apply (Ty.path "slice") [ F ] ] + ] + ], + "and_then", + [ + Ty.apply (Ty.path "&mut") [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "*mut") + [ Ty.apply (Ty.path "slice") [ F ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&mut") [ F ] ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "*mut") + [ Ty.apply (Ty.path "slice") [ F ] ] + ], + "get", + [ Ty.path "usize" ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::prover::generate_advice_from_synthesize::WitnessCollection", + "advice" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ], + "index", + [] + |), + [ column ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let v := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ F ], + "get_mut", + [ Ty.path "usize" ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "slice") + [ F ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "*mut") + [ + Ty.apply + (Ty.path + "slice") + [ F ] + ], + "as_mut", + [] + |), + [ + M.read (| + M.read (| v |) + |) + ] + |) + ] + |); + M.read (| row |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::error::Error::BoundsFailure" + [] + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |), + M.read (| v |) + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |) + |))) + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign_fixed( + &self, + _: A, + _: Column, + _: usize, + _: V, + ) -> Result<(), Error> + where + V: FnOnce() -> Result, + VR: Into>, + A: FnOnce() -> AR, + AR: Into, + { + // We only care about advice columns here + + Ok(()) + } + *) + Definition assign_fixed (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ V; VR; A; AR ], [ self; β1; β2; β3; β4 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let β2 := M.alloc (| β2 |) in + let β3 := M.alloc (| β3 |) in + let β4 := M.alloc (| β4 |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β2, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β3, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β4, + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ])) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn copy(&self, _: Column, _: usize, _: Column, _: usize) -> Result<(), Error> { + // We only care about advice columns here + + Ok(()) + } + *) + Definition copy (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1; β2; β3; β4 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let β2 := M.alloc (| β2 |) in + let β3 := M.alloc (| β3 |) in + let β4 := M.alloc (| β4 |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β2, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β3, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β4, + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ])) + ] + |))) + ] + |))) + ] + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn fill_from_row( + &self, + _: Column, + _: usize, + _: Option>, + ) -> Result<(), Error> { + Ok(()) + } + *) + Definition fill_from_row (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1; β2; β3 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let β2 := M.alloc (| β2 |) in + let β3 := M.alloc (| β3 |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β2, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β3, + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ])) + ] + |))) + ] + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn push_namespace(&self, _: N) + where + NR: Into, + N: FnOnce() -> NR, + { + // Do nothing; we don't care about namespaces in this context. + } + *) + Definition push_namespace (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ NR; N ], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Tuple [])) ] |))) + | _, _ => M.impossible + end. + + (* + fn pop_namespace(&self, _: Option) { + // Do nothing; we don't care about namespaces in this context. + } + *) + Definition pop_namespace (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Tuple [])) ] |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "halo2_proofs::plonk::circuit::Assignment" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("is_in_prove_mode", InstanceField.Method (is_in_prove_mode F)); + ("enter_region", InstanceField.Method (enter_region F)); + ("exit_region", InstanceField.Method (exit_region F)); + ("enable_selector", InstanceField.Method (enable_selector F)); + ("query_instance", InstanceField.Method (query_instance F)); + ("assign_advice", InstanceField.Method (assign_advice F)); + ("assign_fixed", InstanceField.Method (assign_fixed F)); + ("copy", InstanceField.Method (copy F)); + ("fill_from_row", InstanceField.Method (fill_from_row F)); + ("push_namespace", InstanceField.Method (push_namespace F)); + ("pop_namespace", InstanceField.Method (pop_namespace F)) + ]. + End Impl_halo2_proofs_plonk_circuit_Assignment_where_ff_Field_F_F_for_halo2_proofs_plonk_prover_generate_advice_from_synthesize_WitnessCollection_F. + End generate_advice_from_synthesize. + End prover. +End plonk. diff --git a/CoqOfRust/halo2_proofs/plonk/vanishing.v b/CoqOfRust/halo2_proofs/plonk/vanishing.v new file mode 100644 index 000000000..5fc9fbbcf --- /dev/null +++ b/CoqOfRust/halo2_proofs/plonk/vanishing.v @@ -0,0 +1,13 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module plonk. + Module vanishing. + (* StructRecord + { + name := "Argument"; + ty_params := [ "C" ]; + fields := [ ("_marker", Ty.apply (Ty.path "core::marker::PhantomData") [ C ]) ]; + } *) + End vanishing. +End plonk. diff --git a/CoqOfRust/halo2_proofs/plonk/vanishing/prover.v b/CoqOfRust/halo2_proofs/plonk/vanishing/prover.v new file mode 100644 index 000000000..9ca852297 --- /dev/null +++ b/CoqOfRust/halo2_proofs/plonk/vanishing/prover.v @@ -0,0 +1,1754 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module plonk. + Module vanishing. + Module prover. + (* StructRecord + { + name := "Committed"; + ty_params := [ "C" ]; + fields := + [ + ("random_poly", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]) + ]; + } *) + + (* StructRecord + { + name := "Constructed"; + ty_params := [ "C" ]; + fields := + [ + ("h_pieces", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]; + Ty.path "alloc::alloc::Global" + ]); + ("committed", + Ty.apply (Ty.path "halo2_proofs::plonk::vanishing::prover::Committed") [ C ]) + ]; + } *) + + (* StructRecord + { + name := "Evaluated"; + ty_params := [ "C" ]; + fields := + [ + ("h_poly", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]); + ("committed", + Ty.apply (Ty.path "halo2_proofs::plonk::vanishing::prover::Committed") [ C ]) + ]; + } *) + + Module Impl_halo2_proofs_plonk_vanishing_Argument_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::vanishing::Argument") [ C ]. + + (* + pub(in crate::plonk) fn commit, R: RngCore, T: TranscriptWrite>( + params: &Params, + domain: &EvaluationDomain, + mut rng: R, + transcript: &mut T, + ) -> Result, Error> { + // Sample a random polynomial of degree n - 1 + let mut random_poly = domain.empty_coeff(); + + let random = vec![0; domain.k() as usize] + .iter() + .map(|_| C::ScalarExt::random(&mut rng)) + .collect::>(); + + random_poly.par_iter_mut().for_each(|coeff| { + let mut rng = thread_rng(); + *coeff = (C::ScalarExt::random(&mut rng) + + random[rng.next_u64() as usize % domain.k() as usize]) + * (C::ScalarExt::random(&mut rng) + + random[rng.next_u64() as usize % domain.k() as usize]) + }); + + // Commit + let c = params.commit(&random_poly).to_affine(); + transcript.write_point(c)?; + + Ok(Committed { random_poly }) + } + *) + Definition commit (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ E; R; T ], [ params; domain; rng; transcript ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let domain := M.alloc (| domain |) in + let rng := M.alloc (| rng |) in + let transcript := M.alloc (| transcript |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let random_poly := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "empty_coeff", + [] + |), + [ M.read (| domain |) ] + |) + |) in + let random := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.path "i32" ]; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "i32" ] ] ] + Ty.associated + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.path "i32" ], + [], + "map", + [ + Ty.associated; + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "i32" ] ] ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "i32" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "i32"; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ Ty.path "i32" ] + |), + [ + Value.Integer 0; + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "k", + [] + |), + [ M.read (| domain |) ] + |)) + ] + |) + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "random", + [ Ty.apply (Ty.path "&mut") [ R ] ] + |), + [ rng ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply (Ty.path "rayon::slice::IterMut") [ Ty.associated ], + [], + "for_each", + [ + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelRefMutIterator", + Ty.apply (Ty.path "slice") [ Ty.associated ], + [], + "par_iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ], + [], + "deref_mut", + [] + |), + [ random_poly ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let coeff := M.copy (| γ |) in + M.read (| + let rng := + M.alloc (| + M.call_closure (| + M.get_function (| + "rand::rngs::thread::thread_rng", + [] + |), + [] + |) + |) in + M.write (| + M.read (| coeff |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.associated ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ Ty.associated ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "random", + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.path + "rand::rngs::thread::ThreadRng" + ] + ] + |), + [ rng ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + random; + BinOp.Panic.rem (| + Integer.Usize, + M.rust_cast + (M.call_closure (| + M.get_trait_method (| + "rand_core::RngCore", + Ty.path + "rand::rngs::thread::ThreadRng", + [], + "next_u64", + [] + |), + [ rng ] + |)), + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "k", + [] + |), + [ M.read (| domain |) ] + |)) + |) + ] + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ Ty.associated ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "random", + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.path + "rand::rngs::thread::ThreadRng" + ] + ] + |), + [ rng ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + random; + BinOp.Panic.rem (| + Integer.Usize, + M.rust_cast + (M.call_closure (| + M.get_trait_method (| + "rand_core::RngCore", + Ty.path + "rand::rngs::thread::ThreadRng", + [], + "next_u64", + [] + |), + [ rng ] + |)), + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "k", + [] + |), + [ M.read (| domain |) ] + |)) + |) + ] + |) + |) + ] + |) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let c := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::Curve", + Ty.associated, + [], + "to_affine", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Params") [ C ], + "commit", + [] + |), + [ M.read (| params |); random_poly ] + |) + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ C; E ], + "write_point", + [] + |), + [ M.read (| transcript |); M.read (| c |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::prover::Committed") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::vanishing::prover::Committed" + [ ("random_poly", M.read (| random_poly |)) ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_commit : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "commit" (commit C). + End Impl_halo2_proofs_plonk_vanishing_Argument_C. + + Module Impl_halo2_proofs_plonk_vanishing_prover_Committed_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::vanishing::prover::Committed") [ C ]. + + (* + pub(in crate::plonk) fn construct, T: TranscriptWrite>( + self, + params: &Params, + domain: &EvaluationDomain, + h_poly: Polynomial, + transcript: &mut T, + ) -> Result, Error> { + // Divide by t(X) = X^{params.n} - 1. + let h_poly = domain.divide_by_vanishing_poly(h_poly); + + // Obtain final h(X) polynomial + let h_poly = domain.extended_to_coeff(h_poly); + + // Split h(X) up into pieces + let h_pieces = h_poly + .par_chunks_exact(params.n as usize) + .map(|v| domain.coeff_from_vec(v.to_vec())) + .collect::>(); + drop(h_poly); + + // Compute commitments to each h(X) piece + let h_commitments_projective: Vec<_> = h_pieces + .iter() + .map(|h_piece| params.commit(h_piece)) + .collect(); + let mut h_commitments = vec![C::identity(); h_commitments_projective.len()]; + C::Curve::batch_normalize(&h_commitments_projective, &mut h_commitments); + + // Hash each h(X) piece + for c in h_commitments.iter() { + transcript.write_point( *c)?; + } + + Ok(Constructed { + h_pieces, + committed: self, + }) + } + *) + Definition construct (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ E; T ], [ self; params; domain; h_poly; transcript ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let params := M.alloc (| params |) in + let domain := M.alloc (| domain |) in + let h_poly := M.alloc (| h_poly |) in + let transcript := M.alloc (| transcript |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let h_poly := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "divide_by_vanishing_poly", + [] + |), + [ M.read (| domain |); M.read (| h_poly |) ] + |) + |) in + let h_poly := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "extended_to_coeff", + [] + |), + [ M.read (| domain |); M.read (| h_poly |) ] + |) + |) in + let h_pieces := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path "rayon::slice::chunks::ChunksExact") + [ Ty.associated ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::slice::chunks::ChunksExact") + [ Ty.associated ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]); + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::slice::ParallelSlice", + Ty.apply (Ty.path "slice") [ Ty.associated ], + [ Ty.associated ], + "par_chunks_exact", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ h_poly ] + |); + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let v := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "coeff_from_vec", + [] + |), + [ + M.read (| domain |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "to_vec", + [] + |), + [ M.read (| v |) ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::mem::drop", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + |), + [ M.read (| h_poly |) ] + |) + |) in + let h_commitments_projective := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ] + ] + ] + Ty.associated + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ], + [], + "map", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" + ] + ] + ] + ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ h_pieces ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let h_piece := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::Params") + [ C ], + "commit", + [] + |), + [ M.read (| params |); M.read (| h_piece |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let h_commitments := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ C ] |), + [ + M.call_closure (| + M.get_trait_method (| + "group::prime::PrimeCurveAffine", + C, + [], + "identity", + [] + |), + [] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ h_commitments_projective ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::Curve", + Ty.associated, + [], + "batch_normalize", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ h_commitments_projective ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ h_commitments ] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ C ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ C ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ h_commitments ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ C ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let c := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ C; E ], + "write_point", + [] + |), + [ + M.read (| transcript |); + M.read (| M.read (| c |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::prover::Constructed") + [ C ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::vanishing::prover::Constructed" + [ ("h_pieces", M.read (| h_pieces |)); ("committed", M.read (| self |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_construct : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "construct" (construct C). + End Impl_halo2_proofs_plonk_vanishing_prover_Committed_C. + + Module Impl_halo2_proofs_plonk_vanishing_prover_Constructed_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::vanishing::prover::Constructed") [ C ]. + + (* + pub(in crate::plonk) fn evaluate, T: TranscriptWrite>( + self, + x: ChallengeX, + xn: C::Scalar, + domain: &EvaluationDomain, + transcript: &mut T, + ) -> Result, Error> { + let h_poly = self + .h_pieces + .iter() + .rev() + .fold(domain.empty_coeff(), |acc, eval| acc * xn + eval); + + let random_eval = eval_polynomial(&self.committed.random_poly, *x); + transcript.write_scalar(random_eval)?; + + Ok(Evaluated { + h_poly, + committed: self.committed, + }) + } + *) + Definition evaluate (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ E; T ], [ self; x; xn; domain; transcript ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let x := M.alloc (| x |) in + let xn := M.alloc (| xn |) in + let domain := M.alloc (| domain |) in + let transcript := M.alloc (| transcript |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let h_poly := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ] + ], + [], + "fold", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ], + [], + "rev", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::vanishing::prover::Constructed", + "h_pieces" + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "empty_coeff", + [] + |), + [ M.read (| domain |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let eval := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ], + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ], + [ Ty.associated ], + "mul", + [] + |), + [ M.read (| acc |); M.read (| xn |) ] + |); + M.read (| eval |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let random_eval := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::eval_polynomial", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::vanishing::prover::Constructed", + "committed" + |), + "halo2_proofs::plonk::vanishing::prover::Committed", + "random_poly" + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ C; E ], + "write_scalar", + [] + |), + [ M.read (| transcript |); M.read (| random_eval |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::prover::Evaluated") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::vanishing::prover::Evaluated" + [ + ("h_poly", M.read (| h_poly |)); + ("committed", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::vanishing::prover::Constructed", + "committed" + |) + |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_evaluate : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "evaluate" (evaluate C). + End Impl_halo2_proofs_plonk_vanishing_prover_Constructed_C. + + Module Impl_halo2_proofs_plonk_vanishing_prover_Evaluated_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::vanishing::prover::Evaluated") [ C ]. + + (* + pub(in crate::plonk) fn open( + &self, + x: ChallengeX, + ) -> impl Iterator> + Clone { + iter::empty() + .chain(Some(ProverQuery { + point: *x, + rotation: Rotation::cur(), + poly: &self.h_poly, + })) + .chain(Some(ProverQuery { + point: *x, + rotation: Rotation::cur(), + poly: &self.committed.random_poly, + })) + } + *) + Definition open (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; x ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let x := M.alloc (| x |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.apply (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") [ C ] ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") [ C ] ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") [ C ] ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.apply (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") [ C ] ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") [ C ] ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "core::iter::sources::empty::empty", + [ Ty.apply (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") [ C ] ] + |), + [] + |); + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "halo2_proofs::poly::multiopen::ProverQuery" + [ + ("point", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |)); + ("rotation", + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |)); + ("poly", + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::vanishing::prover::Evaluated", + "h_poly" + |)) + ] + ] + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "halo2_proofs::poly::multiopen::ProverQuery" + [ + ("point", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |)); + ("rotation", + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |)); + ("poly", + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::vanishing::prover::Evaluated", + "committed" + |), + "halo2_proofs::plonk::vanishing::prover::Committed", + "random_poly" + |)) + ] + ] + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_open : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "open" (open C). + End Impl_halo2_proofs_plonk_vanishing_prover_Evaluated_C. + End prover. + End vanishing. +End plonk. diff --git a/CoqOfRust/halo2_proofs/plonk/vanishing/verifier.v b/CoqOfRust/halo2_proofs/plonk/vanishing/verifier.v new file mode 100644 index 000000000..654b7fde0 --- /dev/null +++ b/CoqOfRust/halo2_proofs/plonk/vanishing/verifier.v @@ -0,0 +1,1036 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module plonk. + Module vanishing. + Module verifier. + (* StructRecord + { + name := "Committed"; + ty_params := [ "C" ]; + fields := [ ("random_poly_commitment", C) ]; + } *) + + (* StructRecord + { + name := "Constructed"; + ty_params := [ "C" ]; + fields := + [ + ("h_commitments", + Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ]); + ("random_poly_commitment", C) + ]; + } *) + + (* StructRecord + { + name := "PartiallyEvaluated"; + ty_params := [ "C" ]; + fields := + [ + ("h_commitments", + Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ]); + ("random_poly_commitment", C); + ("random_eval", Ty.associated) + ]; + } *) + + (* StructRecord + { + name := "Evaluated"; + ty_params := [ "C" ]; + fields := + [ + ("h_commitment", Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ]); + ("random_poly_commitment", C); + ("expected_h_eval", Ty.associated); + ("random_eval", Ty.associated) + ]; + } *) + + Module Impl_halo2_proofs_plonk_vanishing_Argument_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::vanishing::Argument") [ C ]. + + (* + pub(in crate::plonk) fn read_commitments_before_y< + E: EncodedChallenge, + T: TranscriptRead, + >( + transcript: &mut T, + ) -> Result, Error> { + let random_poly_commitment = transcript.read_point()?; + + Ok(Committed { + random_poly_commitment, + }) + } + *) + Definition read_commitments_before_y (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ E; T ], [ transcript ] => + ltac:(M.monadic + (let transcript := M.alloc (| transcript |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let random_poly_commitment := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptRead", + T, + [ C; E ], + "read_point", + [] + |), + [ M.read (| transcript |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::verifier::Committed") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::vanishing::verifier::Committed" + [ ("random_poly_commitment", M.read (| random_poly_commitment |)) ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_read_commitments_before_y : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "read_commitments_before_y" (read_commitments_before_y C). + End Impl_halo2_proofs_plonk_vanishing_Argument_C. + + Module Impl_halo2_proofs_plonk_vanishing_verifier_Committed_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::vanishing::verifier::Committed") [ C ]. + + (* + pub(in crate::plonk) fn read_commitments_after_y< + E: EncodedChallenge, + T: TranscriptRead, + >( + self, + vk: &VerifyingKey, + transcript: &mut T, + ) -> Result, Error> { + // Obtain a commitment to h(X) in the form of multiple pieces of degree n - 1 + let h_commitments = read_n_points(transcript, vk.domain.get_quotient_poly_degree())?; + + Ok(Constructed { + h_commitments, + random_poly_commitment: self.random_poly_commitment, + }) + } + *) + Definition read_commitments_after_y (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ E; T ], [ self; vk; transcript ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let vk := M.alloc (| vk |) in + let transcript := M.alloc (| transcript |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let h_commitments := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::transcript::read_n_points", + [ C; E; T ] + |), + [ + M.read (| transcript |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "get_quotient_poly_degree", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::verifier::Constructed") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::vanishing::verifier::Constructed" + [ + ("h_commitments", M.read (| h_commitments |)); + ("random_poly_commitment", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::vanishing::verifier::Committed", + "random_poly_commitment" + |) + |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_read_commitments_after_y : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "read_commitments_after_y" (read_commitments_after_y C). + End Impl_halo2_proofs_plonk_vanishing_verifier_Committed_C. + + Module Impl_halo2_proofs_plonk_vanishing_verifier_Constructed_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::vanishing::verifier::Constructed") [ C ]. + + (* + pub(in crate::plonk) fn evaluate_after_x, T: TranscriptRead>( + self, + transcript: &mut T, + ) -> Result, Error> { + let random_eval = transcript.read_scalar()?; + + Ok(PartiallyEvaluated { + h_commitments: self.h_commitments, + random_poly_commitment: self.random_poly_commitment, + random_eval, + }) + } + *) + Definition evaluate_after_x (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ E; T ], [ self; transcript ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let transcript := M.alloc (| transcript |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let random_eval := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptRead", + T, + [ C; E ], + "read_scalar", + [] + |), + [ M.read (| transcript |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::verifier::PartiallyEvaluated") + [ C ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::vanishing::verifier::PartiallyEvaluated" + [ + ("h_commitments", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::vanishing::verifier::Constructed", + "h_commitments" + |) + |)); + ("random_poly_commitment", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::vanishing::verifier::Constructed", + "random_poly_commitment" + |) + |)); + ("random_eval", M.read (| random_eval |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_evaluate_after_x : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "evaluate_after_x" (evaluate_after_x C). + End Impl_halo2_proofs_plonk_vanishing_verifier_Constructed_C. + + Module Impl_halo2_proofs_plonk_vanishing_verifier_PartiallyEvaluated_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::vanishing::verifier::PartiallyEvaluated") [ C ]. + + (* + pub(in crate::plonk) fn verify( + self, + expressions: impl Iterator, + y: ChallengeY, + xn: C::Scalar, + ) -> Evaluated { + let expected_h_eval = expressions.fold(C::Scalar::zero(), |h_eval, v| h_eval * &*y + &v); + let expected_h_eval = expected_h_eval * ((xn - C::Scalar::one()).invert().unwrap()); + + let h_commitment = + self.h_commitments + .iter() + .rev() + .fold(MSM::new(), |mut acc, commitment| { + acc.scale(xn); + acc.append_term(C::Scalar::one(), *commitment); + acc + }); + + Evaluated { + expected_h_eval, + h_commitment, + random_poly_commitment: self.random_poly_commitment, + random_eval: self.random_eval, + } + } + *) + Definition verify (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ impl_Iterator_Item___C_Scalar_ ], [ self; expressions; y; xn ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let expressions := M.alloc (| expressions |) in + let y := M.alloc (| y |) in + let xn := M.alloc (| xn |) in + M.read (| + let expected_h_eval := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___C_Scalar_, + [], + "fold", + [ + Ty.associated; + Ty.function [ Ty.tuple [ Ty.associated; Ty.associated ] ] Ty.associated + ] + |), + [ + M.read (| expressions |); + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "zero", [] |), + [] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let h_eval := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let v := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] + ], + "mul", + [] + |), + [ + M.read (| h_eval |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::Y" + ], + [], + "deref", + [] + |), + [ y ] + |) + ] + |); + v + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let expected_h_eval := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.associated ], + "mul", + [] + |), + [ + M.read (| expected_h_eval |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "subtle::CtOption") [ Ty.associated ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "invert", [] |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ Ty.associated ], + "sub", + [] + |), + [ + M.read (| xn |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |) + ] + |) + |) + ] + |) + ] + |) + ] + |) + |) in + let h_commitment := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ Ty.apply (Ty.path "core::slice::iter::Iter") [ C ] ], + [], + "fold", + [ + Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ]; + Ty.apply (Ty.path "&") [ C ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ C ], + [], + "rev", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ C ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::vanishing::verifier::PartiallyEvaluated", + "h_commitments" + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ], + "new", + [] + |), + [] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let commitment := M.copy (| γ |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::msm::MSM") + [ C ], + "scale", + [] + |), + [ acc; M.read (| xn |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::msm::MSM") + [ C ], + "append_term", + [] + |), + [ + acc; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |); + M.read (| M.read (| commitment |) |) + ] + |) + |) in + acc + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::plonk::vanishing::verifier::Evaluated" + [ + ("expected_h_eval", M.read (| expected_h_eval |)); + ("h_commitment", M.read (| h_commitment |)); + ("random_poly_commitment", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::vanishing::verifier::PartiallyEvaluated", + "random_poly_commitment" + |) + |)); + ("random_eval", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::vanishing::verifier::PartiallyEvaluated", + "random_eval" + |) + |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_verify : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "verify" (verify C). + End Impl_halo2_proofs_plonk_vanishing_verifier_PartiallyEvaluated_C. + + Module Impl_halo2_proofs_plonk_vanishing_verifier_Evaluated_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::vanishing::verifier::Evaluated") [ C ]. + + (* + pub(in crate::plonk) fn queries<'r>( + &'r self, + x: ChallengeX, + ) -> impl Iterator> + Clone + where + 'params: 'r, + { + iter::empty() + .chain(Some(VerifierQuery::new_msm( + &self.h_commitment, + *x, + Rotation::cur(), + self.expected_h_eval, + ))) + .chain(Some(VerifierQuery::new_commitment( + &self.random_poly_commitment, + *x, + Rotation::cur(), + self.random_eval, + ))) + } + *) + Definition queries (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; x ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let x := M.alloc (| x |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.apply (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") [ C ] ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") [ C ] ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") [ C ] ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.apply (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") [ C ] ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") [ C ] + ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "core::iter::sources::empty::empty", + [ Ty.apply (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") [ C ] + ] + |), + [] + |); + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ C ], + "new_msm", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::vanishing::verifier::Evaluated", + "h_commitment" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::vanishing::verifier::Evaluated", + "expected_h_eval" + |) + |) + ] + |) + ] + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") [ C ], + "new_commitment", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::vanishing::verifier::Evaluated", + "random_poly_commitment" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::vanishing::verifier::Evaluated", + "random_eval" + |) + |) + ] + |) + ] + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_queries : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "queries" (queries C). + End Impl_halo2_proofs_plonk_vanishing_verifier_Evaluated_C. + End verifier. + End vanishing. +End plonk. diff --git a/CoqOfRust/halo2_proofs/plonk/verifier.v b/CoqOfRust/halo2_proofs/plonk/verifier.v new file mode 100644 index 000000000..33af80115 --- /dev/null +++ b/CoqOfRust/halo2_proofs/plonk/verifier.v @@ -0,0 +1,14385 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module plonk. + Module verifier. + (* Trait *) + (* Empty module 'VerificationStrategy' *) + + (* StructRecord + { + name := "SingleVerifier"; + ty_params := [ "E" ]; + fields := + [ + ("params", + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "halo2_proofs::poly::commitment::ParamsVerifier") [ E ] ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_E_where_pairing_bn256_arithmetic_pairing_MultiMillerLoop_E_for_halo2_proofs_plonk_verifier_SingleVerifier_E. + Definition Self (E : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::verifier::SingleVerifier") [ E ]. + + (* Debug *) + Definition fmt (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "SingleVerifier" |); + M.read (| Value.String "params" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::verifier::SingleVerifier", + "params" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (E : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self E) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt E)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_E_where_pairing_bn256_arithmetic_pairing_MultiMillerLoop_E_for_halo2_proofs_plonk_verifier_SingleVerifier_E. + + Module Impl_halo2_proofs_plonk_verifier_SingleVerifier_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::verifier::SingleVerifier") [ C ]. + + (* + pub fn new(params: &'a ParamsVerifier) -> Self { + SingleVerifier { params } + } + *) + Definition new (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ params ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + Value.StructRecord + "halo2_proofs::plonk::verifier::SingleVerifier" + [ ("params", M.read (| params |)) ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "new" (new C). + End Impl_halo2_proofs_plonk_verifier_SingleVerifier_C. + + Module Impl_halo2_proofs_plonk_verifier_VerificationStrategy_where_pairing_bn256_arithmetic_pairing_MultiMillerLoop_C_associated_type_for_halo2_proofs_plonk_verifier_SingleVerifier_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::verifier::SingleVerifier") [ C ]. + + (* type Output = (); *) + Definition _Output (C : Ty.t) : Ty.t := Ty.tuple []. + + (* + fn process( + self, + f: impl FnOnce() -> Result, Error>, + ) -> Result { + let guard = f()?; + if Decider::verify(self.params, guard) { + Ok(()) + } else { + Err(Error::ConstraintSystemFailure) + } + } + *) + Definition process (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ impl_FnOnce___arrow_Result_PairMSM_C_G1Affine___Error_ ], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let guard := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::msm::PairMSM") + [ Ty.associated ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce___arrow_Result_PairMSM_C_G1Affine___Error_, + [ Ty.tuple [] ], + "call_once", + [] + |), + [ M.read (| f |); Value.Tuple [] ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::Decider") + [ C ], + "verify", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::verifier::SingleVerifier", + "params" + |) + |); + M.read (| guard |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "halo2_proofs::plonk::error::Error::ConstraintSystemFailure" + [] + ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "halo2_proofs::plonk::verifier::VerificationStrategy" + (Self C) + (* Trait polymorphic types *) [ (* C *) Ty.associated ] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output C)); ("process", InstanceField.Method (process C)) + ]. + End Impl_halo2_proofs_plonk_verifier_VerificationStrategy_where_pairing_bn256_arithmetic_pairing_MultiMillerLoop_C_associated_type_for_halo2_proofs_plonk_verifier_SingleVerifier_C. + + (* StructRecord + { + name := "BatchVerifier"; + ty_params := [ "E"; "R" ]; + fields := + [ + ("params", + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "halo2_proofs::poly::commitment::ParamsVerifier") [ E ] ]); + ("msm", Ty.apply (Ty.path "halo2_proofs::poly::msm::PairMSM") [ Ty.associated ]); + ("rng", R) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_E_where_pairing_bn256_arithmetic_pairing_MultiMillerLoop_E_where_core_fmt_Debug_R_where_rand_core_RngCore_R_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_verifier_BatchVerifier_E_R. + Definition Self (E R : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::verifier::BatchVerifier") [ E; R ]. + + (* Debug *) + Definition fmt (E R : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E R in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "BatchVerifier" |); + M.read (| Value.String "params" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::verifier::BatchVerifier", + "params" + |)); + M.read (| Value.String "msm" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::verifier::BatchVerifier", + "msm" + |)); + M.read (| Value.String "rng" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::plonk::verifier::BatchVerifier", + "rng" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (E R : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self E R) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt E R)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_E_where_pairing_bn256_arithmetic_pairing_MultiMillerLoop_E_where_core_fmt_Debug_R_where_rand_core_RngCore_R_where_core_fmt_Debug_associated_type_for_halo2_proofs_plonk_verifier_BatchVerifier_E_R. + + Module Impl_halo2_proofs_plonk_verifier_BatchVerifier_E_R. + Definition Self (E R : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::verifier::BatchVerifier") [ E; R ]. + + (* + pub fn new(params: &'a ParamsVerifier, rng: R) -> Self { + BatchVerifier { + params, + msm: PairMSM::default(), + rng, + } + } + *) + Definition new (E R : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E R in + match τ, α with + | [], [ params; rng ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let rng := M.alloc (| rng |) in + Value.StructRecord + "halo2_proofs::plonk::verifier::BatchVerifier" + [ + ("params", M.read (| params |)); + ("msm", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply (Ty.path "halo2_proofs::poly::msm::PairMSM") [ Ty.associated ], + [], + "default", + [] + |), + [] + |)); + ("rng", M.read (| rng |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (E R : Ty.t), + M.IsAssociatedFunction (Self E R) "new" (new E R). + + (* + pub fn finalize(self) -> bool { + Decider::verify(self.params, self.msm) + } + *) + Definition finalize (E R : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E R in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::Decider") [ E ], + "verify", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::verifier::BatchVerifier", + "params" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::verifier::BatchVerifier", + "msm" + |) + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_finalize : + forall (E R : Ty.t), + M.IsAssociatedFunction (Self E R) "finalize" (finalize E R). + End Impl_halo2_proofs_plonk_verifier_BatchVerifier_E_R. + + Module Impl_halo2_proofs_plonk_verifier_VerificationStrategy_where_pairing_bn256_arithmetic_pairing_MultiMillerLoop_C_where_rand_core_RngCore_R_associated_type_for_halo2_proofs_plonk_verifier_BatchVerifier_C_R. + Definition Self (C R : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::verifier::BatchVerifier") [ C; R ]. + + (* type Output = Self; *) + Definition _Output (C R : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::plonk::verifier::BatchVerifier") [ C; R ]. + + (* + fn process( + mut self, + f: impl FnOnce() -> Result, Error>, + ) -> Result { + // Scale the MSM by a random factor to ensure that if the existing MSM + // has is_zero() == false then this argument won't be able to interfere + // with it to make it true, with high probability. + self.msm.scale(C::Scalar::random(&mut self.rng)); + let to_add = f()?; + self.msm.add_msm(to_add); + + Ok(Self { + msm: self.msm, + rng: self.rng, + params: self.params, + }) + } + *) + Definition process (C R : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C R in + match τ, α with + | [ impl_FnOnce___arrow_Result_PairMSM_C_G1Affine___Error_ ], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::msm::PairMSM") [ Ty.associated ], + "scale", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::verifier::BatchVerifier", + "msm" + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "random", + [ Ty.apply (Ty.path "&mut") [ R ] ] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::verifier::BatchVerifier", + "rng" + |) + ] + |) + ] + |) + |) in + let to_add := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::msm::PairMSM") + [ Ty.associated ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce___arrow_Result_PairMSM_C_G1Affine___Error_, + [ Ty.tuple [] ], + "call_once", + [] + |), + [ M.read (| f |); Value.Tuple [] ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::verifier::BatchVerifier") + [ C; R ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::msm::PairMSM") [ Ty.associated ], + "add_msm", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::verifier::BatchVerifier", + "msm" + |); + M.read (| to_add |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::plonk::verifier::BatchVerifier" + [ + ("msm", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::verifier::BatchVerifier", + "msm" + |) + |)); + ("rng", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::verifier::BatchVerifier", + "rng" + |) + |)); + ("params", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::plonk::verifier::BatchVerifier", + "params" + |) + |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C R : Ty.t), + M.IsTraitInstance + "halo2_proofs::plonk::verifier::VerificationStrategy" + (Self C R) + (* Trait polymorphic types *) [ (* C *) Ty.associated ] + (* Instance *) + [ + ("Output", InstanceField.Ty (_Output C R)); + ("process", InstanceField.Method (process C R)) + ]. + End Impl_halo2_proofs_plonk_verifier_VerificationStrategy_where_pairing_bn256_arithmetic_pairing_MultiMillerLoop_C_where_rand_core_RngCore_R_associated_type_for_halo2_proofs_plonk_verifier_BatchVerifier_C_R. + + (* + pub fn get_advice_commitments_from_transcript< + 'params, + C: MultiMillerLoop, + E: EncodedChallenge, + T: TranscriptRead, + >( + vk: &VerifyingKey, + transcript: &mut T, + ) -> Result, Error> { + let res = read_n_points(transcript, vk.cs.num_advice_columns)?; + Ok(res) + } + *) + Definition get_advice_commitments_from_transcript (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; E; T ], [ vk; transcript ] => + ltac:(M.monadic + (let vk := M.alloc (| vk |) in + let transcript := M.alloc (| transcript |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let res := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::transcript::read_n_points", + [ Ty.associated; E; T ] + |), + [ + M.read (| transcript |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_columns" + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| res |) ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + pub fn verify_proof_ext< + 'params, + C: MultiMillerLoop, + E: EncodedChallenge, + T: TranscriptRead, + V: VerificationStrategy, + >( + params: &'params ParamsVerifier, + vk: &VerifyingKey, + strategy: V, + instances: &[&[&[C::Scalar]]], + transcript: &mut T, + use_gwc: bool, + ) -> Result { + // Check that instances matches the expected number of instance columns + for instances in instances.iter() { + if instances.len() != vk.cs.num_instance_columns { + return Err(Error::InvalidInstances); + } + } + + let instance_commitments = instances + .iter() + .map(|instance| { + instance + .iter() + .map(|instance| { + if instance.len() > params.n as usize - (vk.cs.blinding_factors() + 1) { + return Err(Error::InstanceTooLarge); + } + + Ok(params.commit_lagrange(instance.to_vec()).to_affine()) + }) + .collect::, _>>() + }) + .collect::, _>>()?; + + let num_proofs = instance_commitments.len(); + + // Hash verification key into transcript + vk.hash_into(transcript)?; + + for instance_commitments in instance_commitments.iter() { + // Hash the instance (external) commitments into the transcript + for commitment in instance_commitments { + transcript.common_point( *commitment)? + } + } + + let advice_commitments = (0..num_proofs) + .map(|_| -> Result, _> { + // Hash the prover's advice commitments into the transcript + read_n_points(transcript, vk.cs.num_advice_columns) + }) + .collect::, _>>()?; + + // Sample theta challenge for keeping lookup columns linearly independent + let theta: ChallengeTheta<_> = transcript.squeeze_challenge_scalar(); + + let lookups_permuted = (0..num_proofs) + .map(|_| -> Result, _> { + // Hash each lookup permuted commitment + vk.cs + .lookups + .iter() + .map(|argument| argument.read_permuted_commitments(transcript)) + .collect::, _>>() + }) + .collect::, _>>()?; + + // Sample beta challenge + let beta: ChallengeBeta<_> = transcript.squeeze_challenge_scalar(); + + // Sample gamma challenge + let gamma: ChallengeGamma<_> = transcript.squeeze_challenge_scalar(); + + let permutations_committed = (0..num_proofs) + .map(|_| { + // Hash each permutation product commitment + vk.cs.permutation.read_product_commitments(vk, transcript) + }) + .collect::, _>>()?; + + let lookups_committed = lookups_permuted + .into_iter() + .map(|lookups| { + // Hash each lookup product commitment + lookups + .into_iter() + .map(|lookup| lookup.read_product_commitment(transcript)) + .collect::, _>>() + }) + .collect::, _>>()?; + + let vanishing = vanishing::Argument::read_commitments_before_y(transcript)?; + + // Sample y challenge, which keeps the gates linearly independent. + let y: ChallengeY<_> = transcript.squeeze_challenge_scalar(); + + let vanishing = vanishing.read_commitments_after_y(vk, transcript)?; + + // Sample x challenge, which is used to ensure the circuit is + // satisfied with high probability. + let x: ChallengeX<_> = transcript.squeeze_challenge_scalar(); + let instance_evals = (0..num_proofs) + .map(|_| -> Result, _> { read_n_scalars(transcript, vk.cs.instance_queries.len()) }) + .collect::, _>>()?; + + let advice_evals = (0..num_proofs) + .map(|_| -> Result, _> { read_n_scalars(transcript, vk.cs.advice_queries.len()) }) + .collect::, _>>()?; + + let fixed_evals = read_n_scalars(transcript, vk.cs.fixed_queries.len())?; + + let vanishing = vanishing.evaluate_after_x(transcript)?; + + let permutations_common = vk.permutation.evaluate(transcript)?; + + let permutations_evaluated = permutations_committed + .into_iter() + .map(|permutation| permutation.evaluate(transcript)) + .collect::, _>>()?; + + let lookups_evaluated = lookups_committed + .into_iter() + .map(|lookups| -> Result, _> { + lookups + .into_iter() + .map(|lookup| lookup.evaluate(transcript)) + .collect::, _>>() + }) + .collect::, _>>()?; + + // This check ensures the circuit is satisfied so long as the polynomial + // commitments open to the correct values. + let vanishing = { + // x^n + let xn = x.pow(&[params.n as u64, 0, 0, 0]); + + let blinding_factors = vk.cs.blinding_factors(); + let l_evals = vk + .domain + .l_i_range( *x, xn, (-((blinding_factors + 1) as i32))..=0); + assert_eq!(l_evals.len(), 2 + blinding_factors); + let l_last = l_evals[0]; + let l_blind: C::Scalar = l_evals[1..(1 + blinding_factors)] + .iter() + .fold(C::Scalar::zero(), |acc, eval| acc + eval); + let l_0 = l_evals[1 + blinding_factors]; + + // Compute the expected value of h(x) + let expressions = advice_evals + .iter() + .zip(instance_evals.iter()) + .zip(permutations_evaluated.iter()) + .zip(lookups_evaluated.iter()) + .flat_map(|(((advice_evals, instance_evals), permutation), lookups)| { + let fixed_evals = &fixed_evals; + std::iter::empty() + // Evaluate the circuit using the custom gates provided + .chain(vk.cs.gates.iter().flat_map(move |gate| { + gate.polynomials().iter().map(move |poly| { + poly.evaluate( + &|scalar| scalar, + &|_| panic!("virtual selectors are removed during optimization"), + &|index, _, _| fixed_evals[index], + &|index, _, _| advice_evals[index], + &|index, _, _| instance_evals[index], + &|a| -a, + &|a, b| a + &b, + &|a, b| a() * &b(), + &|a, scalar| a * &scalar, + ) + }) + })) + .chain(permutation.expressions( + vk, + &vk.cs.permutation, + &permutations_common, + advice_evals, + fixed_evals, + instance_evals, + l_0, + l_last, + l_blind, + beta, + gamma, + x, + )) + .chain( + lookups + .iter() + .zip(vk.cs.lookups.iter()) + .flat_map(move |(p, argument)| { + p.expressions( + l_0, + l_last, + l_blind, + argument, + theta, + beta, + gamma, + advice_evals, + fixed_evals, + instance_evals, + ) + }) + .into_iter(), + ) + }); + + vanishing.verify(expressions, y, xn) + }; + + let queries = instance_commitments + .iter() + .zip(instance_evals.iter()) + .zip(advice_commitments.iter()) + .zip(advice_evals.iter()) + .zip(permutations_evaluated.iter()) + .zip(lookups_evaluated.iter()) + .flat_map( + |( + ( + (((instance_commitments, instance_evals), advice_commitments), advice_evals), + permutation, + ), + lookups, + )| { + iter::empty() + .chain(vk.cs.instance_queries.iter().enumerate().map( + move |(query_index, &(column, at))| { + VerifierQuery::new_commitment( + &instance_commitments[column.index()], + vk.domain.rotate_omega( *x, at), + at, + instance_evals[query_index], + ) + }, + )) + .chain(vk.cs.advice_queries.iter().enumerate().map( + move |(query_index, &(column, at))| { + VerifierQuery::new_commitment( + &advice_commitments[column.index()], + vk.domain.rotate_omega( *x, at), + at, + advice_evals[query_index], + ) + }, + )) + .chain(permutation.queries(vk, x)) + .chain( + lookups + .iter() + .flat_map(move |p| p.queries(vk, x)) + .into_iter(), + ) + }, + ) + .chain( + vk.cs + .fixed_queries + .iter() + .enumerate() + .map(|(query_index, &(column, at))| { + VerifierQuery::new_commitment( + &vk.fixed_commitments[column.index()], + vk.domain.rotate_omega( *x, at), + at, + fixed_evals[query_index], + ) + }), + ) + .chain(permutations_common.queries(&vk.permutation, x)) + .chain(vanishing.queries(x)); + + // We are now convinced the circuit is satisfied so long as the + // polynomial commitments open to the correct values. + if use_gwc { + strategy.process(|| { + multiopen::gwc::verify_proof(params, transcript, queries).map_err(|_| Error::Opening) + }) + } else { + strategy.process(|| { + multiopen::shplonk::verify_proof(params, transcript, queries) + .map_err(|_| Error::Opening) + }) + } + } + *) + Definition verify_proof_ext (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; E; T; V ], [ params; vk; strategy; instances; transcript; use_gwc ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let vk := M.alloc (| vk |) in + let strategy := M.alloc (| strategy |) in + let instances := M.alloc (| instances |) in + let transcript := M.alloc (| transcript |) in + let use_gwc := M.alloc (| use_gwc |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] + ] + ] + ], + "iter", + [] + |), + [ M.read (| instances |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ] + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let instances := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ] + ], + "len", + [] + |), + [ M.read (| M.read (| instances |) |) ] + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_instance_columns" + |) + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "halo2_proofs::plonk::error::Error::InvalidInstances" + [] + ] + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let instance_commitments := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ] + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ] + ] + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ] + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] + ] + ] + ] + ], + "iter", + [] + |), + [ M.read (| instances |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let instance := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.associated; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.associated; + Ty.path + "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.associated; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ] + ], + "iter", + [] + |), + [ M.read (| M.read (| instance |) |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let instance := + M.copy (| γ |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ], + "len", + [] + |), + [ + M.read (| + M.read (| + instance + |) + |) + ] + |)) + (BinOp.Panic.sub (| + Integer.Usize, + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + params + |), + "halo2_proofs::poly::commitment::ParamsVerifier", + "n" + |) + |)), + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ + Ty.associated + ], + "blinding_factors", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + vk + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |), + Value.Integer + 1 + |) + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "halo2_proofs::plonk::error::Error::InstanceTooLarge" + [] + ] + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "group::Curve", + Ty.associated, + [], + "to_affine", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::ParamsVerifier") + [ C + ], + "commit_lagrange", + [] + |), + [ + M.read (| + params + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ], + "to_vec", + [] + |), + [ + M.read (| + M.read (| + instance + |) + |) + ] + |) + ] + |) + |) + ] + |) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.associated; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let num_proofs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ instance_commitments ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::VerifyingKey") + [ Ty.associated ], + "hash_into", + [ E; T ] + |), + [ M.read (| vk |); M.read (| transcript |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ instance_commitments ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let instance_commitments := M.copy (| γ0_0 |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ M.read (| instance_commitments |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.associated ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let commitment := + M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ Ty.associated; E ], + "common_point", + [] + |), + [ + M.read (| + transcript + |); + M.read (| + M.read (| + commitment + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.associated; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| γ0_0 |) in + val)) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let advice_commitments := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ]) + ] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", M.read (| num_proofs |)) + ]; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_function (| + "halo2_proofs::transcript::read_n_points", + [ Ty.associated; E; T ] + |), + [ + M.read (| transcript |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "num_advice_columns" + |) + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.associated; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let theta := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ Ty.associated; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::plonk::Theta" ] + |), + [ M.read (| transcript |) ] + |) + |) in + let lookups_permuted := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", M.read (| num_proofs |)) + ]; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ Ty.associated ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ Ty.associated ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ Ty.associated ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "lookups" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let argument := + M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ], + "read_permuted_commitments", + [ + Ty.associated; + E; + T + ] + |), + [ + M.read (| + argument + |); + M.read (| + transcript + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.associated; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let beta := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ Ty.associated; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::plonk::Beta" ] + |), + [ M.read (| transcript |) ] + |) + |) in + let gamma := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ Ty.associated; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::plonk::Gamma" ] + |), + [ M.read (| transcript |) ] + |) + |) in + let permutations_committed := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Committed") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Committed") + [ Ty.associated ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Committed") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Committed") + [ Ty.associated ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Committed") + [ Ty.associated ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", M.read (| num_proofs |)) + ]; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::plonk::permutation::Argument", + "read_product_commitments", + [ Ty.associated; E; T ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |); + M.read (| vk |); + M.read (| transcript |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.associated; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let lookups_committed := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| lookups_permuted |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let lookups := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ Ty.associated ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ Ty.associated ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ Ty.associated ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ Ty.associated ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ Ty.associated ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| lookups |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let lookup := + M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::PermutationCommitments") + [ Ty.associated ], + "read_product_commitment", + [ E; T ] + |), + [ + M.read (| lookup |); + M.read (| + transcript + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.associated; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let vanishing := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::vanishing::verifier::Committed") + [ Ty.associated ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::vanishing::Argument") + [ Ty.associated ], + "read_commitments_before_y", + [ E; T ] + |), + [ M.read (| transcript |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.associated; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let y := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ Ty.associated; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::plonk::Y" ] + |), + [ M.read (| transcript |) ] + |) + |) in + let vanishing := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::vanishing::verifier::Constructed") + [ Ty.associated ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::vanishing::verifier::Committed") + [ Ty.associated ], + "read_commitments_after_y", + [ E; T ] + |), + [ M.read (| vanishing |); M.read (| vk |); M.read (| transcript |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.associated; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let x := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ Ty.associated; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::plonk::X" ] + |), + [ M.read (| transcript |) ] + |) + |) in + let instance_evals := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ]) + ] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", M.read (| num_proofs |)) + ]; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_function (| + "halo2_proofs::transcript::read_n_scalars", + [ Ty.associated; E; T ] + |), + [ + M.read (| transcript |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "instance_queries" + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.associated; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let advice_evals := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "std::io::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ]) + ] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", M.read (| num_proofs |)) + ]; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_function (| + "halo2_proofs::transcript::read_n_scalars", + [ Ty.associated; E; T ] + |), + [ + M.read (| transcript |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "advice_queries" + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.associated; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let fixed_evals := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::transcript::read_n_scalars", + [ Ty.associated; E; T ] + |), + [ + M.read (| transcript |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "fixed_queries" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.associated; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let vanishing := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::vanishing::verifier::PartiallyEvaluated") + [ Ty.associated ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::vanishing::verifier::Constructed") + [ Ty.associated ], + "evaluate_after_x", + [ E; T ] + |), + [ M.read (| vanishing |); M.read (| transcript |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.associated; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let permutations_common := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::CommonEvaluated") + [ Ty.associated ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::permutation::VerifyingKey") + [ Ty.associated ], + "evaluate", + [ E; T ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "permutation" + |); + M.read (| transcript |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.associated; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let permutations_evaluated := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Committed") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Committed") + [ Ty.associated ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Committed") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Committed") + [ Ty.associated ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Committed") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| permutations_committed |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let permutation := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Committed") + [ Ty.associated ], + "evaluate", + [ E; T ] + |), + [ + M.read (| permutation |); + M.read (| transcript |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.associated; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let lookups_evaluated := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| lookups_committed |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let lookups := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ Ty.associated ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ Ty.associated ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| lookups |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let lookup := + M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Committed") + [ Ty.associated ], + "evaluate", + [ E; T ] + |), + [ + M.read (| lookup |); + M.read (| + transcript + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.associated; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let vanishing := + M.copy (| + let xn := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::fields::BaseExt", + Ty.associated, + [], + "pow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ Ty.associated; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |); + M.alloc (| + Value.Array + [ + M.read (| + M.use + (M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::ParamsVerifier", + "n" + |)) + |); + Value.Integer 0; + Value.Integer 0; + Value.Integer 0 + ] + |) + ] + |) + |) in + let blinding_factors := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ Ty.associated ], + "blinding_factors", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |) + ] + |) + |) in + let l_evals := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "l_i_range", + [ + Ty.apply + (Ty.path "core::ops::range::RangeInclusive") + [ Ty.path "i32" ] + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ Ty.associated; Ty.path "halo2_proofs::plonk::X" ], + [], + "deref", + [] + |), + [ x ] + |) + |); + M.read (| xn |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::RangeInclusive") + [ Ty.path "i32" ], + "new", + [] + |), + [ + UnOp.Panic.neg (| + Integer.I32, + M.rust_cast + (BinOp.Panic.add (| + Integer.Usize, + M.read (| blinding_factors |), + Value.Integer 1 + |)) + |); + Value.Integer 0 + ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ l_evals ] + |) + |); + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + Value.Integer 2, + M.read (| blinding_factors |) + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let l_last := + M.copy (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ Ty.path "usize" ], + "index", + [] + |), + [ l_evals; Value.Integer 0 ] + |) + |) in + let l_blind := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.associated ], + [], + "fold", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ Ty.associated; Ty.apply (Ty.path "&") [ Ty.associated ] ] + ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ] + ], + "index", + [] + |), + [ + l_evals; + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 1); + ("end_", + BinOp.Panic.add (| + Integer.Usize, + Value.Integer 1, + M.read (| blinding_factors |) + |)) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "zero", [] |), + [] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let eval := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] + ], + "add", + [] + |), + [ M.read (| acc |); M.read (| eval |) ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let l_0 := + M.copy (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + l_evals; + BinOp.Panic.add (| + Integer.Usize, + Value.Integer 1, + M.read (| blinding_factors |) + |) + ] + |) + |) in + let expressions := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.associated ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ] + ] + ] + ] + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.associated ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ] + ] + ] + ] + Ty.associated + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ] + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ advice_evals ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ instance_evals ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ permutations_evaluated ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ lookups_evaluated ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let γ2_0 := + M.SubPointer.get_tuple_field (| γ1_0, 0 |) in + let γ2_1 := + M.SubPointer.get_tuple_field (| γ1_0, 1 |) in + let advice_evals := M.copy (| γ2_0 |) in + let instance_evals := M.copy (| γ2_1 |) in + let permutation := M.copy (| γ1_1 |) in + let lookups := M.copy (| γ0_1 |) in + M.read (| + let fixed_evals := M.alloc (| fixed_evals |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ Ty.associated ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated + ] + ] + ] + ] + Ty.associated + ]) + ] + ]; + Ty.associated + ], + [], + "chain", + [ + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ] + ] + ] + ] + Ty.associated + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ Ty.associated ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated + ] + ] + ] + ] + Ty.associated + ]) + ] + ], + [], + "chain", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ Ty.associated ], + [], + "chain", + [ + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated + ] + ] + ] + ] + Ty.associated + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + Ty.associated + ] + ] + ] + ] + Ty.associated + ]) + ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "core::iter::sources::empty::empty", + [ Ty.associated ] + |), + [] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated + ] + ] + ] + ] + Ty.associated + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + Ty.associated + ] + ] + ] + ] + Ty.associated + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "gates" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let gate := + M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + Ty.associated + ] + ], + [], + "map", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + Ty.associated + ] + ] + ] + ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + Ty.associated + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ + Ty.associated + ], + "polynomials", + [] + |), + [ + M.read (| + gate + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + poly := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + Ty.associated + ], + "evaluate", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.associated + ] + ] + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.path + "halo2_proofs::plonk::circuit::Selector" + ] + ] + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.path + "usize"; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.associated + ] + ] + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.associated; + Ty.associated + ] + ] + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ] + ] + ] + ] + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.associated; + Ty.associated + ] + ] + Ty.associated + ] + |), + [ + M.read (| + poly + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + scalar := + M.copy (| + γ + |) in + M.read (| + scalar + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.never_to_any (| + M.call_closure (| + M.get_function (| + "std::panicking::begin_panic", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + Value.String + "virtual selectors are removed during optimization" + |) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1; + α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + index := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + fixed_evals + |); + M.read (| + index + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1; + α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + index := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + advice_evals + |); + M.read (| + index + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1; + α2 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + index := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + α2 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + instance_evals + |); + M.read (| + index + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Neg", + Ty.associated, + [], + "neg", + [] + |), + [ + M.read (| + a + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + b := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "add", + [] + |), + [ + M.read (| + a + |); + b + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + b := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ], + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.read (| + a + |); + Value.Tuple + [] + ] + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("core::ops::function::Fn::Trait", + []) + ], + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.read (| + b + |); + Value.Tuple + [] + ] + |) + |) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0; + α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + a := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + scalar := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "mul", + [] + |), + [ + M.read (| + a + |); + scalar + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ], + "expressions", + [] + |), + [ + M.read (| permutation |); + M.read (| vk |); + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "permutation" + |); + permutations_common; + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| advice_evals |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| fixed_evals |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| instance_evals |) ] + |); + M.read (| l_0 |); + M.read (| l_last |); + M.read (| l_blind |); + M.read (| beta |); + M.read (| gamma |); + M.read (| x |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ] + ] + ] + ] + Ty.associated + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ] + ], + [], + "flat_map", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ] + ] + ] + ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| lookups |) ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "lookups" + |) + ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let p := + M.copy (| γ0_0 |) in + let argument := + M.copy (| γ0_1 |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ], + "expressions", + [] + |), + [ + M.read (| p |); + M.read (| l_0 |); + M.read (| l_last |); + M.read (| + l_blind + |); + M.read (| + argument + |); + M.read (| theta |); + M.read (| beta |); + M.read (| gamma |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + advice_evals + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + fixed_evals + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.read (| + instance_evals + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::vanishing::verifier::PartiallyEvaluated") + [ Ty.associated ], + "verify", + [ + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.associated ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ] + ] + ] + ] + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ Ty.associated ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Gate") + [ Ty.associated ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::Argument") + [ Ty.associated ] + ] + ] + ] + ] + Ty.associated + ] + ]) + ] + ] + |), + [ + M.read (| vanishing |); + M.read (| expressions |); + M.read (| y |); + M.read (| xn |) + ] + |) + |) + |) in + let queries := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ] + ]) + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.associated + ], + [], + "chain", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ] + ]) + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ], + [], + "chain", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ] + ]) + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "flat_map", + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ] + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ instance_commitments ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ instance_evals ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ advice_commitments ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ advice_evals ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ permutations_evaluated ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ lookups_evaluated ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let γ2_0 := + M.SubPointer.get_tuple_field (| γ1_0, 0 |) in + let γ2_1 := + M.SubPointer.get_tuple_field (| γ1_0, 1 |) in + let γ3_0 := + M.SubPointer.get_tuple_field (| γ2_0, 0 |) in + let γ3_1 := + M.SubPointer.get_tuple_field (| γ2_0, 1 |) in + let γ4_0 := + M.SubPointer.get_tuple_field (| γ3_0, 0 |) in + let γ4_1 := + M.SubPointer.get_tuple_field (| γ3_0, 1 |) in + let instance_commitments := M.copy (| γ4_0 |) in + let instance_evals := M.copy (| γ4_1 |) in + let advice_commitments := M.copy (| γ3_1 |) in + let advice_evals := M.copy (| γ2_1 |) in + let permutation := M.copy (| γ1_1 |) in + let lookups := M.copy (| γ0_1 |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.associated + ], + [], + "chain", + [ + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ], + [], + "chain", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ] + |), + [ + M.call_closure (| + M.get_function (| + "core::iter::sources::empty::empty", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ] + |), + [] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + vk + |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "instance_queries" + |) + ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + query_index := + M.copy (| + γ0_0 + |) in + let γ0_1 := + M.read (| + γ0_1 + |) in + let γ2_0 := + M.SubPointer.get_tuple_field (| + γ0_1, + 0 + |) in + let γ2_1 := + M.SubPointer.get_tuple_field (| + γ0_1, + 1 + |) in + let + column := + M.copy (| + γ2_0 + |) in + let at_ := + M.copy (| + γ2_1 + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ + Ty.associated + ], + "new_commitment", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + instance_commitments + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ], + "index", + [] + |), + [ + column + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "rotate_omega", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + vk + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + Ty.associated; + Ty.path + "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ + x + ] + |) + |); + M.read (| + at_ + |) + ] + |); + M.read (| + at_ + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + instance_evals + |); + M.read (| + query_index + |) + ] + |) + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "advice_queries" + |) + ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + query_index := + M.copy (| + γ0_0 + |) in + let γ0_1 := + M.read (| + γ0_1 + |) in + let γ2_0 := + M.SubPointer.get_tuple_field (| + γ0_1, + 0 + |) in + let γ2_1 := + M.SubPointer.get_tuple_field (| + γ0_1, + 1 + |) in + let column := + M.copy (| + γ2_0 + |) in + let at_ := + M.copy (| + γ2_1 + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ + Ty.associated + ], + "new_commitment", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + advice_commitments + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ], + "index", + [] + |), + [ + column + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ + Ty.associated + ], + "rotate_omega", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + vk + |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + Ty.associated; + Ty.path + "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ x + ] + |) + |); + M.read (| + at_ + |) + ] + |); + M.read (| + at_ + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + advice_evals + |); + M.read (| + query_index + |) + ] + |) + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ Ty.associated ], + "queries", + [] + |), + [ + M.read (| permutation |); + M.read (| vk |); + M.read (| x |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ], + [], + "flat_map", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ] + ] + ] + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ Ty.associated ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| lookups |) ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let p := + M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ + Ty.associated + ], + "queries", + [] + |), + [ + M.read (| p |); + M.read (| vk |); + M.read (| x |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path "halo2_proofs::poly::Rotation" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "cs" + |), + "halo2_proofs::plonk::circuit::ConstraintSystem", + "fixed_queries" + |) + ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let query_index := M.copy (| γ0_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_tuple_field (| γ0_1, 0 |) in + let γ2_1 := + M.SubPointer.get_tuple_field (| γ0_1, 1 |) in + let column := M.copy (| γ2_0 |) in + let at_ := M.copy (| γ2_1 |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ], + "new_commitment", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "fixed_commitments" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ], + "index", + [] + |), + [ column ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ Ty.associated ], + "rotate_omega", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "domain" + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + Ty.associated; + Ty.path + "halo2_proofs::plonk::X" + ], + [], + "deref", + [] + |), + [ x ] + |) + |); + M.read (| at_ |) + ] + |); + M.read (| at_ |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ fixed_evals; M.read (| query_index |) + ] + |) + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::CommonEvaluated") + [ Ty.associated ], + "queries", + [] + |), + [ + permutations_common; + M.SubPointer.get_struct_record_field (| + M.read (| vk |), + "halo2_proofs::plonk::VerifyingKey", + "permutation" + |); + M.read (| x |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::vanishing::verifier::Evaluated") + [ Ty.associated ], + "queries", + [] + |), + [ vanishing; M.read (| x |) ] + |) + ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use use_gwc in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::verifier::VerificationStrategy", + V, + [ Ty.associated ], + "process", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::msm::PairMSM") + [ Ty.associated ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.read (| strategy |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::msm::PairMSM") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::Error" + ], + "map_err", + [ + Ty.path "halo2_proofs::plonk::error::Error"; + Ty.function + [ + Ty.tuple + [ Ty.path "halo2_proofs::poly::Error" ] + ] + (Ty.path "halo2_proofs::plonk::error::Error") + ] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::poly::multiopen::gwc::verifier::verify_proof", + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ + Ty.associated + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ + Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ + Ty.associated + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ + Ty.associated + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ + Ty.associated + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ + Ty.associated + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ + Ty.associated + ] + ] + ] + ] + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ + Ty.associated + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ + Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ + Ty.associated + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ + Ty.associated + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ + Ty.associated + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ + Ty.associated + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ + Ty.associated + ] + ] + ] + ] + Ty.associated + ] + ]) + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.associated + ]; + Ty.associated + ]; + C; + E; + T + ] + |), + [ + M.read (| params |); + M.read (| transcript |); + M.read (| queries |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::plonk::error::Error::Opening" + [])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::plonk::verifier::VerificationStrategy", + V, + [ Ty.associated ], + "process", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::msm::PairMSM") + [ Ty.associated ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.read (| strategy |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::msm::PairMSM") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::Error" + ], + "map_err", + [ + Ty.path "halo2_proofs::plonk::error::Error"; + Ty.function + [ + Ty.tuple + [ Ty.path "halo2_proofs::poly::Error" ] + ] + (Ty.path "halo2_proofs::plonk::error::Error") + ] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::poly::multiopen::shplonk::verifier::verify_proof", + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ + Ty.associated + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ + Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ + Ty.associated + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ + Ty.associated + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ + Ty.associated + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ + Ty.associated + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ + Ty.associated + ] + ] + ] + ] + Ty.associated + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::permutation::verifier::Evaluated") + [ + Ty.associated + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ + Ty.associated + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path + "core::iter::sources::empty::Empty") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ + Ty.associated + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Instance" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ + Ty.associated + ]) + ] + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path + "usize"; + Ty.apply + (Ty.path + "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ + Ty.associated + ]) + ] + ]; + Ty.associated + ]; + Ty.apply + (Ty.path + "core::iter::adapters::flatten::FlatMap") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ + Ty.associated + ] + ]; + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::lookup::verifier::Evaluated") + [ + Ty.associated + ] + ] + ] + ] + Ty.associated + ] + ]) + ]; + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Fixed" + ]; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]) + ] + ]; + Ty.associated + ]; + Ty.associated + ]; + C; + E; + T + ] + |), + [ + M.read (| params |); + M.read (| transcript |); + M.read (| queries |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::plonk::error::Error::Opening" + [])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + pub fn verify_proof< + 'params, + C: MultiMillerLoop, + E: EncodedChallenge, + T: TranscriptRead, + V: VerificationStrategy, + >( + params: &'params ParamsVerifier, + vk: &VerifyingKey, + strategy: V, + instances: &[&[&[C::Scalar]]], + transcript: &mut T, + ) -> Result { + verify_proof_ext(params, vk, strategy, instances, transcript, true) + } + *) + Definition verify_proof (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; E; T; V ], [ params; vk; strategy; instances; transcript ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let vk := M.alloc (| vk |) in + let strategy := M.alloc (| strategy |) in + let instances := M.alloc (| instances |) in + let transcript := M.alloc (| transcript |) in + M.call_closure (| + M.get_function (| "halo2_proofs::plonk::verifier::verify_proof_ext", [ C; E; T; V ] |), + [ + M.read (| params |); + M.read (| vk |); + M.read (| strategy |); + M.read (| instances |); + M.read (| transcript |); + Value.Bool true + ] + |))) + | _, _ => M.impossible + end. + + (* + pub fn verify_proof_with_shplonk< + 'params, + C: MultiMillerLoop, + E: EncodedChallenge, + T: TranscriptRead, + V: VerificationStrategy, + >( + params: &'params ParamsVerifier, + vk: &VerifyingKey, + strategy: V, + instances: &[&[&[C::Scalar]]], + transcript: &mut T, + ) -> Result { + verify_proof_ext(params, vk, strategy, instances, transcript, false) + } + *) + Definition verify_proof_with_shplonk (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; E; T; V ], [ params; vk; strategy; instances; transcript ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let vk := M.alloc (| vk |) in + let strategy := M.alloc (| strategy |) in + let instances := M.alloc (| instances |) in + let transcript := M.alloc (| transcript |) in + M.call_closure (| + M.get_function (| "halo2_proofs::plonk::verifier::verify_proof_ext", [ C; E; T; V ] |), + [ + M.read (| params |); + M.read (| vk |); + M.read (| strategy |); + M.read (| instances |); + M.read (| transcript |); + Value.Bool false + ] + |))) + | _, _ => M.impossible + end. + End verifier. +End plonk. diff --git a/CoqOfRust/halo2_proofs/poly.v b/CoqOfRust/halo2_proofs/poly.v new file mode 100644 index 000000000..2fe042e90 --- /dev/null +++ b/CoqOfRust/halo2_proofs/poly.v @@ -0,0 +1,3379 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module poly. + (* + Enum Error + { + ty_params := []; + variants := + [ + { + name := "OpeningError"; + item := StructTuple []; + discriminant := None; + }; + { + name := "SamplingError"; + item := StructTuple []; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_fmt_Debug_for_halo2_proofs_poly_Error. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::Error". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ + M.read (| f |); + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| M.read (| Value.String "OpeningError" |) |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| M.read (| Value.String "SamplingError" |) |))) + ] + |) + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_poly_Error. + + (* Trait *) + (* Empty module 'Basis' *) + + (* StructTuple + { + name := "Coeff"; + ty_params := []; + fields := []; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_poly_Coeff. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::Coeff". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| M.read (| self |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_poly_Coeff. + + Module Impl_core_marker_Copy_for_halo2_proofs_poly_Coeff. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::Coeff". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_poly_Coeff. + + Module Impl_core_fmt_Debug_for_halo2_proofs_poly_Coeff. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::Coeff". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ M.read (| f |); M.read (| Value.String "Coeff" |) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_poly_Coeff. + + Module Impl_halo2_proofs_poly_Basis_for_halo2_proofs_poly_Coeff. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::Coeff". + + Axiom Implements : + M.IsTraitInstance + "halo2_proofs::poly::Basis" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_halo2_proofs_poly_Basis_for_halo2_proofs_poly_Coeff. + + (* StructTuple + { + name := "LagrangeCoeff"; + ty_params := []; + fields := []; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_poly_LagrangeCoeff. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::LagrangeCoeff". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| M.read (| self |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_poly_LagrangeCoeff. + + Module Impl_core_marker_Copy_for_halo2_proofs_poly_LagrangeCoeff. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::LagrangeCoeff". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_poly_LagrangeCoeff. + + Module Impl_core_fmt_Debug_for_halo2_proofs_poly_LagrangeCoeff. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::LagrangeCoeff". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ M.read (| f |); M.read (| Value.String "LagrangeCoeff" |) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_poly_LagrangeCoeff. + + Module Impl_halo2_proofs_poly_Basis_for_halo2_proofs_poly_LagrangeCoeff. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::LagrangeCoeff". + + Axiom Implements : + M.IsTraitInstance + "halo2_proofs::poly::Basis" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_halo2_proofs_poly_Basis_for_halo2_proofs_poly_LagrangeCoeff. + + (* StructTuple + { + name := "ExtendedLagrangeCoeff"; + ty_params := []; + fields := []; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_poly_ExtendedLagrangeCoeff. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::ExtendedLagrangeCoeff". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| M.read (| self |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_poly_ExtendedLagrangeCoeff. + + Module Impl_core_marker_Copy_for_halo2_proofs_poly_ExtendedLagrangeCoeff. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::ExtendedLagrangeCoeff". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_poly_ExtendedLagrangeCoeff. + + Module Impl_core_fmt_Debug_for_halo2_proofs_poly_ExtendedLagrangeCoeff. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::ExtendedLagrangeCoeff". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ M.read (| f |); M.read (| Value.String "ExtendedLagrangeCoeff" |) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_poly_ExtendedLagrangeCoeff. + + Module Impl_halo2_proofs_poly_Basis_for_halo2_proofs_poly_ExtendedLagrangeCoeff. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::ExtendedLagrangeCoeff". + + Axiom Implements : + M.IsTraitInstance + "halo2_proofs::poly::Basis" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_halo2_proofs_poly_Basis_for_halo2_proofs_poly_ExtendedLagrangeCoeff. + + (* StructTuple + { + name := "PreparedExtendedLagrangeCoeff"; + ty_params := []; + fields := []; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_poly_PreparedExtendedLagrangeCoeff. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::PreparedExtendedLagrangeCoeff". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| M.read (| self |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_poly_PreparedExtendedLagrangeCoeff. + + Module Impl_core_marker_Copy_for_halo2_proofs_poly_PreparedExtendedLagrangeCoeff. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::PreparedExtendedLagrangeCoeff". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_poly_PreparedExtendedLagrangeCoeff. + + Module Impl_core_fmt_Debug_for_halo2_proofs_poly_PreparedExtendedLagrangeCoeff. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::PreparedExtendedLagrangeCoeff". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ M.read (| f |); M.read (| Value.String "PreparedExtendedLagrangeCoeff" |) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_poly_PreparedExtendedLagrangeCoeff. + + Module Impl_halo2_proofs_poly_Basis_for_halo2_proofs_poly_PreparedExtendedLagrangeCoeff. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::PreparedExtendedLagrangeCoeff". + + Axiom Implements : + M.IsTraitInstance + "halo2_proofs::poly::Basis" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_halo2_proofs_poly_Basis_for_halo2_proofs_poly_PreparedExtendedLagrangeCoeff. + + (* StructRecord + { + name := "Polynomial"; + ty_params := [ "F"; "B" ]; + fields := + [ + ("values", Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ]); + ("_marker", Ty.apply (Ty.path "core::marker::PhantomData") [ B ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_core_clone_Clone_B_for_halo2_proofs_poly_Polynomial_F_B. + Definition Self (F B : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ]. + + (* Clone *) + Definition clone (F B : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F B in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |)); + ("_marker", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ B ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "_marker" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F B : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F B) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F B)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_core_clone_Clone_B_for_halo2_proofs_poly_Polynomial_F_B. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_core_fmt_Debug_B_for_halo2_proofs_poly_Polynomial_F_B. + Definition Self (F B : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ]. + + (* Debug *) + Definition fmt (F B : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F B in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Polynomial" |); + M.read (| Value.String "values" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "values" + |)); + M.read (| Value.String "_marker" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "_marker" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F B : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F B) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F B)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_core_fmt_Debug_B_for_halo2_proofs_poly_Polynomial_F_B. + + Module Impl_core_ops_index_Index_usize_for_halo2_proofs_poly_Polynomial_F_B. + Definition Self (F B : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ]. + + (* type Output = F; *) + Definition _Output (F B : Ty.t) : Ty.t := F. + + (* + fn index(&self, index: usize) -> &F { + self.values.index(index) + } + *) + Definition index (F B : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F B in + match τ, α with + | [], [ self; index ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let index := M.alloc (| index |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "values" + |); + M.read (| index |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F B : Ty.t), + M.IsTraitInstance + "core::ops::index::Index" + (Self F B) + (* Trait polymorphic types *) [ (* Idx *) Ty.path "usize" ] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F B)); ("index", InstanceField.Method (index F B)) ]. + End Impl_core_ops_index_Index_usize_for_halo2_proofs_poly_Polynomial_F_B. + + Module Impl_core_ops_index_IndexMut_usize_for_halo2_proofs_poly_Polynomial_F_B. + Definition Self (F B : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ]. + + (* + fn index_mut(&mut self, index: usize) -> &mut F { + self.values.index_mut(index) + } + *) + Definition index_mut (F B : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F B in + match τ, α with + | [], [ self; index ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let index := M.alloc (| index |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "values" + |); + M.read (| index |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F B : Ty.t), + M.IsTraitInstance + "core::ops::index::IndexMut" + (Self F B) + (* Trait polymorphic types *) [ (* Idx *) Ty.path "usize" ] + (* Instance *) [ ("index_mut", InstanceField.Method (index_mut F B)) ]. + End Impl_core_ops_index_IndexMut_usize_for_halo2_proofs_poly_Polynomial_F_B. + + Module Impl_core_ops_index_Index_core_ops_range_RangeFrom_usize_for_halo2_proofs_poly_Polynomial_F_B. + Definition Self (F B : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ]. + + (* type Output = [F]; *) + Definition _Output (F B : Ty.t) : Ty.t := Ty.apply (Ty.path "slice") [ F ]. + + (* + fn index(&self, index: RangeFrom) -> &[F] { + self.values.index(index) + } + *) + Definition index (F B : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F B in + match τ, α with + | [], [ self; index ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let index := M.alloc (| index |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + [ Ty.apply (Ty.path "core::ops::range::RangeFrom") [ Ty.path "usize" ] ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "values" + |); + M.read (| index |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F B : Ty.t), + M.IsTraitInstance + "core::ops::index::Index" + (Self F B) + (* Trait polymorphic types *) + [ (* Idx *) Ty.apply (Ty.path "core::ops::range::RangeFrom") [ Ty.path "usize" ] ] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F B)); ("index", InstanceField.Method (index F B)) ]. + End Impl_core_ops_index_Index_core_ops_range_RangeFrom_usize_for_halo2_proofs_poly_Polynomial_F_B. + + Module Impl_core_ops_index_IndexMut_core_ops_range_RangeFrom_usize_for_halo2_proofs_poly_Polynomial_F_B. + Definition Self (F B : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ]. + + (* + fn index_mut(&mut self, index: RangeFrom) -> &mut [F] { + self.values.index_mut(index) + } + *) + Definition index_mut (F B : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F B in + match τ, α with + | [], [ self; index ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let index := M.alloc (| index |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + [ Ty.apply (Ty.path "core::ops::range::RangeFrom") [ Ty.path "usize" ] ], + "index_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "values" + |); + M.read (| index |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F B : Ty.t), + M.IsTraitInstance + "core::ops::index::IndexMut" + (Self F B) + (* Trait polymorphic types *) + [ (* Idx *) Ty.apply (Ty.path "core::ops::range::RangeFrom") [ Ty.path "usize" ] ] + (* Instance *) [ ("index_mut", InstanceField.Method (index_mut F B)) ]. + End Impl_core_ops_index_IndexMut_core_ops_range_RangeFrom_usize_for_halo2_proofs_poly_Polynomial_F_B. + + Module Impl_core_ops_index_Index_core_ops_range_RangeFull_for_halo2_proofs_poly_Polynomial_F_B. + Definition Self (F B : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ]. + + (* type Output = [F]; *) + Definition _Output (F B : Ty.t) : Ty.t := Ty.apply (Ty.path "slice") [ F ]. + + (* + fn index(&self, index: RangeFull) -> &[F] { + self.values.index(index) + } + *) + Definition index (F B : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F B in + match τ, α with + | [], [ self; index ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let index := M.alloc (| index |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "values" + |); + M.read (| index |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F B : Ty.t), + M.IsTraitInstance + "core::ops::index::Index" + (Self F B) + (* Trait polymorphic types *) [ (* Idx *) Ty.path "core::ops::range::RangeFull" ] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F B)); ("index", InstanceField.Method (index F B)) ]. + End Impl_core_ops_index_Index_core_ops_range_RangeFull_for_halo2_proofs_poly_Polynomial_F_B. + + Module Impl_core_ops_index_IndexMut_core_ops_range_RangeFull_for_halo2_proofs_poly_Polynomial_F_B. + Definition Self (F B : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ]. + + (* + fn index_mut(&mut self, index: RangeFull) -> &mut [F] { + self.values.index_mut(index) + } + *) + Definition index_mut (F B : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F B in + match τ, α with + | [], [ self; index ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let index := M.alloc (| index |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "values" + |); + M.read (| index |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F B : Ty.t), + M.IsTraitInstance + "core::ops::index::IndexMut" + (Self F B) + (* Trait polymorphic types *) [ (* Idx *) Ty.path "core::ops::range::RangeFull" ] + (* Instance *) [ ("index_mut", InstanceField.Method (index_mut F B)) ]. + End Impl_core_ops_index_IndexMut_core_ops_range_RangeFull_for_halo2_proofs_poly_Polynomial_F_B. + + Module Impl_core_ops_deref_Deref_for_halo2_proofs_poly_Polynomial_F_B. + Definition Self (F B : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ]. + + (* type Target = [F]; *) + Definition _Target (F B : Ty.t) : Ty.t := Ty.apply (Ty.path "slice") [ F ]. + + (* + fn deref(&self) -> &[F] { + &self.values[..] + } + *) + Definition deref (F B : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F B in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "values" + |); + Value.StructTuple "core::ops::range::RangeFull" [] + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F B : Ty.t), + M.IsTraitInstance + "core::ops::deref::Deref" + (Self F B) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("Target", InstanceField.Ty (_Target F B)); ("deref", InstanceField.Method (deref F B)) ]. + End Impl_core_ops_deref_Deref_for_halo2_proofs_poly_Polynomial_F_B. + + Module Impl_core_ops_deref_DerefMut_for_halo2_proofs_poly_Polynomial_F_B. + Definition Self (F B : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ]. + + (* + fn deref_mut(&mut self) -> &mut [F] { + &mut self.values[..] + } + *) + Definition deref_mut (F B : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F B in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "values" + |); + Value.StructTuple "core::ops::range::RangeFull" [] + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F B : Ty.t), + M.IsTraitInstance + "core::ops::deref::DerefMut" + (Self F B) + (* Trait polymorphic types *) [] + (* Instance *) [ ("deref_mut", InstanceField.Method (deref_mut F B)) ]. + End Impl_core_ops_deref_DerefMut_for_halo2_proofs_poly_Polynomial_F_B. + + Module Impl_halo2_proofs_poly_Polynomial_F_B. + Definition Self (F B : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ]. + + (* + pub fn new(values: Vec) -> Self { + Polynomial { + values, + _marker: PhantomData, + } + } + *) + Definition new (F B : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F B in + match τ, α with + | [], [ values ] => + ltac:(M.monadic + (let values := M.alloc (| values |) in + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", M.read (| values |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F B : Ty.t), + M.IsAssociatedFunction (Self F B) "new" (new F B). + + (* + pub fn iter(&self) -> impl Iterator { + self.values.iter() + } + *) + Definition iter (F B : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F B in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| Ty.apply (Ty.path "slice") [ F ], "iter", [] |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_iter : + forall (F B : Ty.t), + M.IsAssociatedFunction (Self F B) "iter" (iter F B). + + (* + pub fn iter_mut(&mut self) -> impl Iterator { + self.values.iter_mut() + } + *) + Definition iter_mut (F B : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F B in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| Ty.apply (Ty.path "slice") [ F ], "iter_mut", [] |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_iter_mut : + forall (F B : Ty.t), + M.IsAssociatedFunction (Self F B) "iter_mut" (iter_mut F B). + + (* + pub fn num_coeffs(&self) -> usize { + self.values.len() + } + *) + Definition num_coeffs (F B : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F B in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_num_coeffs : + forall (F B : Ty.t), + M.IsAssociatedFunction (Self F B) "num_coeffs" (num_coeffs F B). + End Impl_halo2_proofs_poly_Polynomial_F_B. + + (* + pub(crate) fn batch_invert_assigned( + assigned: Vec, LagrangeCoeff>>, + ) -> Vec> { + let mut assigned_denominators: Vec<_> = assigned + .par_iter() + .map(|f| { + f.iter() + .map(|value| value.denominator()) + .collect::>() + }) + .collect(); + + assigned_denominators.par_iter_mut().for_each(|f| { + f.iter_mut() + // If the denominator is trivial, we can skip it, reducing the + // size of the batch inversion. + .filter_map(|d| d.as_mut()) + .batch_invert(); + }); + + assigned + .iter() + .zip(assigned_denominators.into_iter()) + .map(|(poly, inv_denoms)| poly.invert(inv_denoms)) + .collect() + } + *) + Definition batch_invert_assigned (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ assigned ] => + ltac:(M.monadic + (let assigned := M.alloc (| assigned |) in + M.read (| + let assigned_denominators := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "core::option::Option") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "core::option::Option") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "core::option::Option") [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "core::option::Option") [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelRefIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "par_iter", + [] + |), + [ assigned ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let f := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "core::option::Option") [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "core::option::Option") [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.associated, + [], + "map", + [ + Ty.apply (Ty.path "core::option::Option") [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "core::option::Option") [ F ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ], + "iter", + [] + |), + [ M.read (| f |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let value := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ], + "denominator", + [] + |), + [ M.read (| value |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::slice::IterMut") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "core::option::Option") [ F ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "core::option::Option") [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelRefMutIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "core::option::Option") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "par_iter_mut", + [] + |), + [ assigned_denominators ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let f := M.copy (| γ |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::batch::BatchInvert", + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.apply (Ty.path "core::option::Option") [ F ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "core::option::Option") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&mut") [ F ] ]) + ], + [ F ], + "batch_invert", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.apply (Ty.path "core::option::Option") [ F ] + ], + [], + "filter_map", + [ + Ty.apply (Ty.path "&mut") [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "core::option::Option") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&mut") [ F ] ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "core::option::Option") + [ F ] + ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "core::option::Option") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ M.read (| f |) ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let d := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ F ], + "as_mut", + [] + |), + [ M.read (| d |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "core::option::Option") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "core::option::Option") [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ F; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ F; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "core::option::Option") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ F; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "core::option::Option") [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ F; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "core::option::Option") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ assigned ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "core::option::Option") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| assigned_denominators |) ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let poly := M.copy (| γ0_0 |) in + let inv_denoms := M.copy (| γ0_1 |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ], + "invert", + [] + |), + [ M.read (| poly |); M.read (| inv_denoms |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Module Impl_halo2_proofs_poly_Polynomial_halo2_proofs_plonk_assigned_Assigned_F_halo2_proofs_poly_LagrangeCoeff. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ]; + Ty.path "halo2_proofs::poly::LagrangeCoeff" + ]. + + (* + pub(crate) fn invert(&self, inv_denoms: Vec>) -> Polynomial { + Polynomial { + values: self + .values + .par_iter() + .zip(inv_denoms.into_par_iter()) + .map(|(a, inv_den)| { + inv_den.map_or_else(|| a.numerator(), |inv_den| a.numerator() * inv_den) + }) + .collect(), + _marker: self._marker, + } + } + *) + Definition invert (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; inv_denoms ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let inv_denoms := M.alloc (| inv_denoms |) in + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path "rayon::iter::zip::Zip") + [ + Ty.apply + (Ty.path "rayon::slice::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ] + ]; + Ty.apply + (Ty.path "rayon::vec::IntoIter") + [ Ty.apply (Ty.path "core::option::Option") [ F ] ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ]; + Ty.apply (Ty.path "core::option::Option") [ F ] + ] + ] + ] + F + ], + [], + "collect", + [ Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::zip::Zip") + [ + Ty.apply + (Ty.path "rayon::slice::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ] + ]; + Ty.apply + (Ty.path "rayon::vec::IntoIter") + [ Ty.apply (Ty.path "core::option::Option") [ F ] ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ] + ]; + Ty.apply (Ty.path "core::option::Option") [ F ] + ] + ] + ] + F; + F + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IndexedParallelIterator", + Ty.apply + (Ty.path "rayon::slice::Iter") + [ Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ F ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path "rayon::vec::IntoIter") + [ Ty.apply (Ty.path "core::option::Option") [ F ] ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelRefIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::assigned::Assigned") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "par_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "core::option::Option") [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_par_iter", + [] + |), + [ M.read (| inv_denoms |) ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let a := M.copy (| γ0_0 |) in + let inv_den := M.copy (| γ0_1 |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ F ], + "map_or_else", + [ + F; + Ty.function [ Ty.tuple [] ] F; + Ty.function [ Ty.tuple [ F ] ] F + ] + |), + [ + M.read (| inv_den |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ], + "numerator", + [] + |), + [ M.read (| a |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let inv_den := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ F ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::assigned::Assigned") + [ F ], + "numerator", + [] + |), + [ M.read (| a |) ] + |); + M.read (| inv_den |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |)); + ("_marker", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "_marker" + |) + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_invert : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "invert" (invert F). + End Impl_halo2_proofs_poly_Polynomial_halo2_proofs_plonk_assigned_Assigned_F_halo2_proofs_poly_LagrangeCoeff. + + Module Impl_core_ops_arith_Add_where_ff_Field_F_where_halo2_proofs_poly_Basis_B_ref__halo2_proofs_poly_Polynomial_F_B_for_halo2_proofs_poly_Polynomial_F_B. + Definition Self (F B : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ]. + + (* type Output = Polynomial; *) + Definition _Output (F B : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ]. + + (* + fn add(mut self, rhs: &'a Polynomial) -> Polynomial { + parallelize(&mut self.values, |lhs, start| { + for (lhs, rhs) in lhs.iter_mut().zip(rhs.values[start..].iter()) { + *lhs += *rhs; + } + }); + + self + } + *) + Definition add (F B : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F B in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + F; + Ty.function + [ + Ty.tuple + [ + Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ F ] ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let lhs := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let start := M.copy (| γ |) in + M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ F ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ F ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ F ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ F ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "iter_mut", + [] + |), + [ M.read (| lhs |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.apply + (Ty.path + "core::ops::range::RangeFrom") + [ Ty.path "usize" ] + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| rhs |), + "halo2_proofs::poly::Polynomial", + "values" + |); + Value.StructRecord + "core::ops::range::RangeFrom" + [ + ("start", + M.read (| start |)) + ] + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ F ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let lhs := + M.copy (| γ1_0 |) in + let rhs := + M.copy (| γ1_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::AddAssign", + F, + [ F ], + "add_assign", + [] + |), + [ + M.read (| lhs |); + M.read (| + M.read (| rhs |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + self + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F B : Ty.t), + M.IsTraitInstance + "core::ops::arith::Add" + (Self F B) + (* Trait polymorphic types *) + [ + (* Rhs *) + Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ] ] + ] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F B)); ("add", InstanceField.Method (add F B)) ]. + End Impl_core_ops_arith_Add_where_ff_Field_F_where_halo2_proofs_poly_Basis_B_ref__halo2_proofs_poly_Polynomial_F_B_for_halo2_proofs_poly_Polynomial_F_B. + + Module Impl_core_ops_arith_Sub_where_ff_Field_F_where_halo2_proofs_poly_Basis_B_ref__halo2_proofs_poly_Polynomial_F_B_for_halo2_proofs_poly_Polynomial_F_B. + Definition Self (F B : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ]. + + (* type Output = Polynomial; *) + Definition _Output (F B : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ]. + + (* + fn sub(mut self, rhs: &'a Polynomial) -> Polynomial { + parallelize(&mut self.values, |lhs, start| { + for (lhs, rhs) in lhs.iter_mut().zip(rhs.values[start..].iter()) { + *lhs -= *rhs; + } + }); + + self + } + *) + Definition sub (F B : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F B in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + F; + Ty.function + [ + Ty.tuple + [ + Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ F ] ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let lhs := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let start := M.copy (| γ |) in + M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ F ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ F ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ F ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ F ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "iter_mut", + [] + |), + [ M.read (| lhs |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.apply + (Ty.path + "core::ops::range::RangeFrom") + [ Ty.path "usize" ] + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| rhs |), + "halo2_proofs::poly::Polynomial", + "values" + |); + Value.StructRecord + "core::ops::range::RangeFrom" + [ + ("start", + M.read (| start |)) + ] + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ F ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let lhs := + M.copy (| γ1_0 |) in + let rhs := + M.copy (| γ1_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::SubAssign", + F, + [ F ], + "sub_assign", + [] + |), + [ + M.read (| lhs |); + M.read (| + M.read (| rhs |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + self + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F B : Ty.t), + M.IsTraitInstance + "core::ops::arith::Sub" + (Self F B) + (* Trait polymorphic types *) + [ + (* Rhs *) + Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ] ] + ] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F B)); ("sub", InstanceField.Method (sub F B)) ]. + End Impl_core_ops_arith_Sub_where_ff_Field_F_where_halo2_proofs_poly_Basis_B_ref__halo2_proofs_poly_Polynomial_F_B_for_halo2_proofs_poly_Polynomial_F_B. + + Module Impl_halo2_proofs_poly_Polynomial_F_halo2_proofs_poly_LagrangeCoeff. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ F; Ty.path "halo2_proofs::poly::LagrangeCoeff" ]. + + (* + pub fn rotate(&self, rotation: Rotation) -> Polynomial { + let mut values = self.values.clone(); + if rotation.0 < 0 { + values.rotate_right((-rotation.0) as usize); + } else { + values.rotate_left(rotation.0 as usize); + } + Polynomial { + values, + _marker: PhantomData, + } + } + *) + Definition rotate (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; rotation ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rotation := M.alloc (| rotation |) in + M.read (| + let values := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (M.read (| + M.SubPointer.get_struct_tuple_field (| + rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + |)) + (Value.Integer 0) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "rotate_right", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ values ] + |); + M.rust_cast + (UnOp.Panic.neg (| + Integer.I32, + M.read (| + M.SubPointer.get_struct_tuple_field (| + rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + |) + |)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "rotate_left", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ values ] + |); + M.rust_cast + (M.read (| + M.SubPointer.get_struct_tuple_field (| + rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + |)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", M.read (| values |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_rotate : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "rotate" (rotate F). + End Impl_halo2_proofs_poly_Polynomial_F_halo2_proofs_poly_LagrangeCoeff. + + Module Impl_core_ops_arith_Sub_where_ff_Field_F_where_halo2_proofs_poly_Basis_B_F_for_ref__halo2_proofs_poly_Polynomial_F_B. + Definition Self (F B : Ty.t) : Ty.t := + Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ] ]. + + (* type Output = Polynomial; *) + Definition _Output (F B : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ]. + + (* + fn sub(self, rhs: F) -> Polynomial { + let mut res = self.clone(); + res.values[0] -= rhs; + res + } + *) + Definition sub (F B : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F B in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + M.read (| + let res := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ], + [], + "clone", + [] + |), + [ M.read (| self |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::SubAssign", + F, + [ F ], + "sub_assign", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + res, + "halo2_proofs::poly::Polynomial", + "values" + |); + Value.Integer 0 + ] + |); + M.read (| rhs |) + ] + |) + |) in + res + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F B : Ty.t), + M.IsTraitInstance + "core::ops::arith::Sub" + (Self F B) + (* Trait polymorphic types *) [ (* Rhs *) F ] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F B)); ("sub", InstanceField.Method (sub F B)) ]. + End Impl_core_ops_arith_Sub_where_ff_Field_F_where_halo2_proofs_poly_Basis_B_F_for_ref__halo2_proofs_poly_Polynomial_F_B. + + Module Impl_core_ops_arith_Mul_where_ff_Field_F_where_halo2_proofs_poly_Basis_B_F_for_halo2_proofs_poly_Polynomial_F_B. + Definition Self (F B : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ]. + + (* type Output = Polynomial; *) + Definition _Output (F B : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::Polynomial") [ F; B ]. + + (* + fn mul(mut self, rhs: F) -> Polynomial { + parallelize(&mut self.values, |lhs, _| { + for lhs in lhs.iter_mut() { + *lhs *= rhs; + } + }); + + self + } + *) + Definition mul (F B : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F B in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + F; + Ty.function + [ + Ty.tuple + [ + Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ F ] ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let lhs := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ F ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "iter_mut", + [] + |), + [ M.read (| lhs |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ F ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let lhs := + M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + F, + [ F ], + "mul_assign", + [] + |), + [ + M.read (| lhs |); + M.read (| rhs |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + self + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F B : Ty.t), + M.IsTraitInstance + "core::ops::arith::Mul" + (Self F B) + (* Trait polymorphic types *) [ (* Rhs *) F ] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F B)); ("mul", InstanceField.Method (mul F B)) ]. + End Impl_core_ops_arith_Mul_where_ff_Field_F_where_halo2_proofs_poly_Basis_B_F_for_halo2_proofs_poly_Polynomial_F_B. + + (* StructTuple + { + name := "Rotation"; + ty_params := []; + fields := [ Ty.path "i32" ]; + } *) + + Module Impl_core_marker_Copy_for_halo2_proofs_poly_Rotation. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::Rotation". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_poly_Rotation. + + Module Impl_core_clone_Clone_for_halo2_proofs_poly_Rotation. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::Rotation". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.read (| self |))) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_poly_Rotation. + + Module Impl_core_fmt_Debug_for_halo2_proofs_poly_Rotation. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::Rotation". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Rotation" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::poly::Rotation", + 0 + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_poly_Rotation. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_poly_Rotation. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::Rotation". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_poly_Rotation. + + Module Impl_core_cmp_PartialEq_for_halo2_proofs_poly_Rotation. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::Rotation". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::poly::Rotation", + 0 + |) + |)) + (M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| other |), + "halo2_proofs::poly::Rotation", + 0 + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_halo2_proofs_poly_Rotation. + + Module Impl_core_cmp_PartialOrd_for_halo2_proofs_poly_Rotation. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::Rotation". + + (* PartialOrd *) + Definition partial_cmp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "i32", + [ Ty.path "i32" ], + "partial_cmp", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::poly::Rotation", + 0 + |); + M.SubPointer.get_struct_tuple_field (| + M.read (| other |), + "halo2_proofs::poly::Rotation", + 0 + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialOrd" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("partial_cmp", InstanceField.Method partial_cmp) ]. + End Impl_core_cmp_PartialOrd_for_halo2_proofs_poly_Rotation. + + Module Impl_core_marker_StructuralEq_for_halo2_proofs_poly_Rotation. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::Rotation". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralEq_for_halo2_proofs_poly_Rotation. + + Module Impl_core_cmp_Eq_for_halo2_proofs_poly_Rotation. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::Rotation". + + (* Eq *) + Definition assert_receiver_is_total_eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Eq" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("assert_receiver_is_total_eq", InstanceField.Method assert_receiver_is_total_eq) ]. + End Impl_core_cmp_Eq_for_halo2_proofs_poly_Rotation. + + Module Impl_core_cmp_Ord_for_halo2_proofs_poly_Rotation. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::Rotation". + + (* Ord *) + Definition cmp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.call_closure (| + M.get_trait_method (| "core::cmp::Ord", Ty.path "i32", [], "cmp", [] |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::poly::Rotation", + 0 + |); + M.SubPointer.get_struct_tuple_field (| + M.read (| other |), + "halo2_proofs::poly::Rotation", + 0 + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Ord" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("cmp", InstanceField.Method cmp) ]. + End Impl_core_cmp_Ord_for_halo2_proofs_poly_Rotation. + + Module Impl_halo2_proofs_poly_Rotation. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::Rotation". + + (* + pub fn cur() -> Rotation { + Rotation(0) + } + *) + Definition cur (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [] => + ltac:(M.monadic (Value.StructTuple "halo2_proofs::poly::Rotation" [ Value.Integer 0 ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_cur : M.IsAssociatedFunction Self "cur" cur. + + (* + pub fn prev() -> Rotation { + Rotation(-1) + } + *) + Definition prev (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [] => + ltac:(M.monadic (Value.StructTuple "halo2_proofs::poly::Rotation" [ Value.Integer (-1) ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_prev : M.IsAssociatedFunction Self "prev" prev. + + (* + pub fn next() -> Rotation { + Rotation(1) + } + *) + Definition next (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [] => + ltac:(M.monadic (Value.StructTuple "halo2_proofs::poly::Rotation" [ Value.Integer 1 ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_next : M.IsAssociatedFunction Self "next" next. + End Impl_halo2_proofs_poly_Rotation. +End poly. diff --git a/CoqOfRust/halo2_proofs/poly/commitment.v b/CoqOfRust/halo2_proofs/poly/commitment.v new file mode 100644 index 000000000..5a900fc9f --- /dev/null +++ b/CoqOfRust/halo2_proofs/poly/commitment.v @@ -0,0 +1,6648 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module poly. + Module commitment. + (* StructRecord + { + name := "Params"; + ty_params := [ "C" ]; + fields := + [ + ("k", Ty.path "u32"); + ("n", Ty.path "u64"); + ("g", Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ]); + ("g_lagrange", + Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ]); + ("additional_data", + Ty.apply (Ty.path "alloc::vec::Vec") [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_poly_commitment_Params_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Params") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field5_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Params" |); + M.read (| Value.String "k" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "k" + |)); + M.read (| Value.String "n" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "n" + |)); + M.read (| Value.String "g" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "g" + |)); + M.read (| Value.String "g_lagrange" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "g_lagrange" + |)); + M.read (| Value.String "additional_data" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "additional_data" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_poly_commitment_Params_C. + + (* StructRecord + { + name := "ParamsVerifier"; + ty_params := [ "E" ]; + fields := + [ + ("k", Ty.path "u32"); + ("n", Ty.path "u64"); + ("g1", Ty.associated); + ("g2", Ty.associated); + ("s_g2", Ty.associated); + ("g_lagrange", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_E_where_pairing_bn256_arithmetic_pairing_Engine_E_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_poly_commitment_ParamsVerifier_E. + Definition Self (E : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::commitment::ParamsVerifier") [ E ]. + + (* Debug *) + Definition fmt (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let names := + M.alloc (| + M.alloc (| + Value.Array + [ + M.read (| Value.String "k" |); + M.read (| Value.String "n" |); + M.read (| Value.String "g1" |); + M.read (| Value.String "g2" |); + M.read (| Value.String "s_g2" |); + M.read (| Value.String "g_lagrange" |) + ] + |) + |) in + let values := + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::ParamsVerifier", + "k" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::ParamsVerifier", + "n" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::ParamsVerifier", + "g1" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::ParamsVerifier", + "g2" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::ParamsVerifier", + "s_g2" + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::ParamsVerifier", + "g_lagrange" + |) + |)) + ] + |)) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_fields_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "ParamsVerifier" |); + (* Unsize *) M.pointer_coercion (M.read (| names |)); + M.read (| values |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (E : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self E) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt E)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_E_where_pairing_bn256_arithmetic_pairing_Engine_E_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_poly_commitment_ParamsVerifier_E. + + Module Impl_halo2_proofs_poly_commitment_Params_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Params") [ C ]. + + (* + pub fn unsafe_setup(k: u32) -> Params { + // TODO: Make this function only available in test mod + // Largest root of unity exponent of the Engine is `2^E::Scalar::S`, so we can + // only support FFTs of polynomials below degree `2^E::Scalar::S`. + assert!(k <= E::Scalar::S); + let n: u64 = 1 << k; + + // Calculate g = [G1, [s] G1, [s^2] G1, ..., [s^(n-1)] G1] in parallel. + let g1 = ::generator(); + let s = E::Scalar::random(OsRng); + + let mut g_projective = vec![E::G1::group_zero(); n as usize]; + parallelize(&mut g_projective, |g, start| { + let mut current_g: E::G1 = g1.into(); + current_g *= s.pow_vartime(&[start as u64]); + for g in g.iter_mut() { + *g = current_g; + current_g *= s; + } + }); + + let g = { + let mut g = vec![E::G1Affine::identity(); n as usize]; + parallelize(&mut g, |g, starts| { + E::G1::batch_normalize(&g_projective[starts..(starts + g.len())], g); + }); + g + }; + + let mut g_lagrange_projective = vec![E::G1::group_zero(); n as usize]; + let mut root = E::Scalar::ROOT_OF_UNITY_INV.invert().unwrap(); + for _ in k..E::Scalar::S { + root = root.square(); + } + let n_inv = Option::::from(E::Scalar::from(n).invert()) + .expect("inversion should be ok for n = 1<::generator(); + let s_g2 = g2 * s; + let additional_data = Vec::from(s_g2.to_bytes().as_ref()); + Params { + k, + n, + g, + g_lagrange, + additional_data, + } + } + *) + Definition unsafe_setup (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ E ], [ k ] => + ltac:(M.monadic + (let k := M.alloc (| k |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.le + (M.read (| k |)) + (M.read (| M.get_constant (| "ff::PrimeField::S" |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "assertion failed: k <= E::Scalar::S" |) ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let n := M.alloc (| BinOp.Panic.shl (| Value.Integer 1, M.read (| k |) |) |) in + let g1 := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::prime::PrimeCurveAffine", + Ty.associated, + [], + "generator", + [] + |), + [] + |) + |) in + let s := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "random", + [ Ty.path "rand_core::os::OsRng" ] + |), + [ Value.StructTuple "rand_core::os::OsRng" [] ] + |) + |) in + let g_projective := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ Ty.associated ] |), + [ + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + Ty.associated, + [], + "group_zero", + [] + |), + [] + |); + M.rust_cast (M.read (| n |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ g_projective ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let g := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let start := M.copy (| γ |) in + M.read (| + let current_g := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.associated, + [ Ty.associated ], + "into", + [] + |), + [ M.read (| g1 |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ Ty.associated ], + "mul_assign", + [] + |), + [ + current_g; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "pow_vartime", + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "u64" ] + ] + ] + |), + [ + s; + M.alloc (| + Value.Array + [ M.rust_cast (M.read (| start |)) ] + |) + ] + |) + ] + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "iter_mut", + [] + |), + [ M.read (| g |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let g := + M.copy (| γ0_0 |) in + let _ := + M.write (| + M.read (| g |), + M.read (| current_g |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ Ty.associated ], + "mul_assign", + [] + |), + [ + current_g; + M.read (| s |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let g := + M.copy (| + let g := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ Ty.associated ] |), + [ + M.call_closure (| + M.get_trait_method (| + "group::prime::PrimeCurveAffine", + Ty.associated, + [], + "identity", + [] + |), + [] + |); + M.rust_cast (M.read (| n |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ g ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let g := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let starts := M.copy (| γ |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::Curve", + Ty.associated, + [], + "batch_normalize", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ] + ], + "index", + [] + |), + [ + g_projective; + Value.StructRecord + "core::ops::range::Range" + [ + ("start", M.read (| starts |)); + ("end_", + BinOp.Panic.add (| + Integer.Usize, + M.read (| starts |), + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "len", + [] + |), + [ M.read (| g |) ] + |) + |)) + ] + ] + |); + M.read (| g |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + g + |) in + let g_lagrange_projective := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ Ty.associated ] |), + [ + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + Ty.associated, + [], + "group_zero", + [] + |), + [] + |); + M.rust_cast (M.read (| n |)) + ] + |) + |) in + let root := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "subtle::CtOption") [ Ty.associated ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "invert", [] |), + [ + M.get_constant (| + "pairing_bn256::arithmetic::fields::FieldExt::ROOT_OF_UNITY_INV" + |) + ] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", M.read (| k |)); + ("end_", M.read (| M.get_constant (| "ff::PrimeField::S" |) |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let _ := + M.write (| + root, + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "square", + [] + |), + [ root ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let n_inv := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.associated ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.apply (Ty.path "core::option::Option") [ Ty.associated ], + [ Ty.apply (Ty.path "subtle::CtOption") [ Ty.associated ] ], + "from", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "invert", [] |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.associated, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| n |) ] + |) + |) + ] + |) + ] + |); + M.read (| Value.String "inversion should be ok for n = 1< + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let g := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let start := M.copy (| γ |) in + M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "iter_mut", + [] + |), + [ M.read (| g |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let idx := + M.copy (| γ1_0 |) in + let g := + M.copy (| γ1_1 |) in + let offset := + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.read (| start |), + M.read (| idx |) + |) + |) in + let root_pow := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "pow_vartime", + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.path + "u64" + ] + ] + ] + |), + [ + root; + M.alloc (| + Value.Array + [ + M.rust_cast + (M.read (| + offset + |)) + ] + |) + ] + |) + |) in + let scalar := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.associated ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + multiplier + |); + M.read (| + root_pow + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "subtle::CtOption") + [ + Ty.associated + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "invert", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ + Ty.associated + ], + "sub", + [] + |), + [ + M.read (| + s + |); + M.read (| + root_pow + |) + ] + |) + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.write (| + M.read (| g |), + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.associated ], + "mul", + [] + |), + [ + M.read (| g1 |); + M.read (| scalar |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let g_lagrange := + M.copy (| + let g_lagrange := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ Ty.associated ] |), + [ + M.call_closure (| + M.get_trait_method (| + "group::prime::PrimeCurveAffine", + Ty.associated, + [], + "identity", + [] + |), + [] + |); + M.rust_cast (M.read (| n |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ g_lagrange ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let g_lagrange := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let starts := M.copy (| γ |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::Curve", + Ty.associated, + [], + "batch_normalize", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ] + ], + "index", + [] + |), + [ + g_lagrange_projective; + Value.StructRecord + "core::ops::range::Range" + [ + ("start", M.read (| starts |)); + ("end_", + BinOp.Panic.add (| + Integer.Usize, + M.read (| starts |), + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "len", + [] + |), + [ M.read (| g_lagrange |) + ] + |) + |)) + ] + ] + |); + M.read (| g_lagrange |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::mem::drop", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + |), + [ M.read (| g_lagrange_projective |) ] + |) + |) in + g_lagrange + |) in + let g2 := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::prime::PrimeCurveAffine", + Ty.associated, + [], + "generator", + [] + |), + [] + |) + |) in + let s_g2 := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.associated ], + "mul", + [] + |), + [ M.read (| g2 |); M.read (| s |) ] + |) + |) in + let additional_data := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ], + [ Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ] ], + "from", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::GroupEncoding", + Ty.associated, + [], + "to_bytes", + [] + |), + [ s_g2 ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::poly::commitment::Params" + [ + ("k", M.read (| k |)); + ("n", M.read (| n |)); + ("g", M.read (| g |)); + ("g_lagrange", M.read (| g_lagrange |)); + ("additional_data", M.read (| additional_data |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_unsafe_setup : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "unsafe_setup" (unsafe_setup C). + + (* + pub fn commit(&self, poly: &Polynomial) -> C::Curve { + let size = poly.values.len(); + assert!(self.g.len() >= size); + best_multiexp_gpu_cond(&poly.values[..], &self.g[0..size]) + } + *) + Definition commit (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; poly ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let poly := M.alloc (| poly |) in + M.read (| + let size := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| poly |), + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.ge + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "g" + |) + ] + |)) + (M.read (| size |))) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "assertion failed: self.g.len() >= size" |) ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| "halo2_proofs::arithmetic::best_multiexp_gpu_cond", [ C ] |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| poly |), + "halo2_proofs::poly::Polynomial", + "values" + |); + Value.StructTuple "core::ops::range::RangeFull" [] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ], + [ Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ] ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "g" + |); + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| size |)) ] + ] + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_commit : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "commit" (commit C). + + (* + pub fn commit_lagrange(&self, poly: &Polynomial) -> C::Curve { + let size = poly.values.len(); + assert!(self.g.len() >= size); + best_multiexp_gpu_cond(&poly.values[..], &self.g_lagrange[0..size]) + } + *) + Definition commit_lagrange (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; poly ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let poly := M.alloc (| poly |) in + M.read (| + let size := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| poly |), + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.ge + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "g" + |) + ] + |)) + (M.read (| size |))) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "assertion failed: self.g.len() >= size" |) ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| "halo2_proofs::arithmetic::best_multiexp_gpu_cond", [ C ] |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| poly |), + "halo2_proofs::poly::Polynomial", + "values" + |); + Value.StructTuple "core::ops::range::RangeFull" [] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ], + [ Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ] ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "g_lagrange" + |); + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| size |)) ] + ] + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_commit_lagrange : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "commit_lagrange" (commit_lagrange C). + + (* + pub fn commit_lagrange_and_ifft( + &self, + mut poly: Polynomial, + omega: &C::Scalar, + ifft_divisor: &C::Scalar, + ) -> (Polynomial, C::Curve) { + let c = self.commit_lagrange(&poly); + best_fft(&mut poly.values[..], *omega, self.k); + parallelize(&mut poly.values[..], |a, _| { + for a in a { + // Finish iFFT + a.group_scale(&ifft_divisor); + } + }); + ( + Polynomial { + values: poly.values, + _marker: PhantomData, + }, + c, + ) + } + *) + Definition commit_lagrange_and_ifft (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; poly; omega; ifft_divisor ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let poly := M.alloc (| poly |) in + let omega := M.alloc (| omega |) in + let ifft_divisor := M.alloc (| ifft_divisor |) in + M.read (| + let c := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Params") [ C ], + "commit_lagrange", + [] + |), + [ M.read (| self |); poly ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| "halo2_proofs::arithmetic::best_fft", [ Ty.associated ] |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + poly, + "halo2_proofs::poly::Polynomial", + "values" + |); + Value.StructTuple "core::ops::range::RangeFull" [] + ] + |); + M.read (| M.read (| omega |) |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "k" + |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + poly, + "halo2_proofs::poly::Polynomial", + "values" + |); + Value.StructTuple "core::ops::range::RangeFull" [] + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ M.read (| a |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let a := + M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + Ty.associated, + [], + "group_scale", + [] + |), + [ + M.read (| a |); + M.read (| + ifft_divisor + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.Tuple + [ + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", + M.read (| + M.SubPointer.get_struct_record_field (| + poly, + "halo2_proofs::poly::Polynomial", + "values" + |) + |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ]; + M.read (| c |) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_commit_lagrange_and_ifft : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "commit_lagrange_and_ifft" (commit_lagrange_and_ifft C). + + (* + pub fn commit_lagrange_with_bound( + &self, + poly: &Polynomial, + _max_bits: usize, + ) -> C::Curve { + let mut scalars = vec![]; + let mut bases = vec![]; + + for (s, b) in poly.values.iter().zip(self.g_lagrange.iter()) { + if !s.is_zero_vartime() { + scalars.push( *s); + bases.push( *b); + } + } + + #[cfg(feature = "cuda")] + let res = + crate::arithmetic::gpu_multiexp_single_gpu_with_bound(&scalars, &bases[..], _max_bits); + + #[cfg(not(feature = "cuda"))] + let res = best_multiexp_gpu_cond(&scalars, &bases[..]); + + res + } + *) + Definition commit_lagrange_with_bound (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; poly; _max_bits ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let poly := M.alloc (| poly |) in + let _max_bits := M.alloc (| _max_bits |) in + M.read (| + let scalars := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |) + |) in + let bases := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.associated ]; + Ty.apply (Ty.path "core::slice::iter::Iter") [ C ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.associated ], + [], + "zip", + [ Ty.apply (Ty.path "core::slice::iter::Iter") [ C ] ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| poly |), + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ C ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "g_lagrange" + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.associated ]; + Ty.apply (Ty.path "core::slice::iter::Iter") [ C ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let s := M.copy (| γ1_0 |) in + let b := M.copy (| γ1_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "is_zero_vartime", + [] + |), + [ M.read (| s |) ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ scalars; M.read (| M.read (| s |) |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ bases; M.read (| M.read (| b |) |) ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "halo2_proofs::arithmetic::best_multiexp_gpu_cond", [ C ] |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ scalars ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index", + [] + |), + [ bases; Value.StructTuple "core::ops::range::RangeFull" [] ] + |) + ] + |) + |) in + res + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_commit_lagrange_with_bound : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "commit_lagrange_with_bound" (commit_lagrange_with_bound C). + + (* + pub fn empty_msm(&self) -> MSM { + MSM::new() + } + *) + Definition empty_msm (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ], + "new", + [] + |), + [] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_empty_msm : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "empty_msm" (empty_msm C). + + (* + pub fn get_g(&self) -> Vec { + self.g.clone() + } + *) + Definition get_g (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "g" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get_g : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "get_g" (get_g C). + + (* + pub fn get_g_lagrange(&self) -> &Vec { + &self.g_lagrange + } + *) + Definition get_g_lagrange (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "g_lagrange" + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get_g_lagrange : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "get_g_lagrange" (get_g_lagrange C). + + (* + pub fn write(&self, writer: &mut W) -> io::Result<()> { + writer.write_all(&self.k.to_le_bytes())?; + for el in &self.g { + writer.write_all(el.to_bytes().as_ref())?; + } + for el in &self.g_lagrange { + writer.write_all(el.to_bytes().as_ref())?; + } + let additional_data_len = self.additional_data.len() as u32; + writer.write_all(&additional_data_len.to_le_bytes())?; + writer.write_all(&self.additional_data)?; + Ok(()) + } + *) + Definition write (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ W ], [ self; writer ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write_all", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "k" + |) + |) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ] + ], + [], + "into_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "g" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ C ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let el := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "std::io::Write", + W, + [], + "write_all", + [] + |), + [ + M.read (| writer |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ + Ty.apply + (Ty.path "slice") + [ Ty.path "u8" ] + ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::GroupEncoding", + C, + [], + "to_bytes", + [] + |), + [ M.read (| el |) ] + |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ] + ], + [], + "into_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "g_lagrange" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ C ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let el := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "std::io::Write", + W, + [], + "write_all", + [] + |), + [ + M.read (| writer |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ + Ty.apply + (Ty.path "slice") + [ Ty.path "u8" ] + ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::GroupEncoding", + C, + [], + "to_bytes", + [] + |), + [ M.read (| el |) ] + |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let additional_data_len := + M.alloc (| + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "additional_data" + |) + ] + |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write_all", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ M.read (| additional_data_len |) ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write_all", [] |), + [ + M.read (| writer |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "additional_data" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_write : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "write" (write C). + + (* + pub fn read(mut reader: R) -> io::Result { + let mut k = [0u8; 4]; + reader.read_exact(&mut k[..])?; + let k = u32::from_le_bytes(k); + let n = 1 << k; + + let load_points_from_file_parallelly = |reader: &mut R| -> io::Result> { + let mut points_compressed: Vec = vec![C::Repr::default(); n]; + for points_compressed in points_compressed.iter_mut() { + reader.read_exact(( *points_compressed).as_mut())?; + } + + let mut points = vec![C::default(); n]; + parallelize(&mut points, |points, chunks| { + for (i, point) in points.iter_mut().enumerate() { + *point = Option::from(C::from_bytes(&points_compressed[chunks + i])).unwrap(); + } + }); + Ok(points) + }; + + let g = load_points_from_file_parallelly(&mut reader)?; + let g_lagrange = load_points_from_file_parallelly(&mut reader)?; + + let mut additional_data_len = [0u8; 4]; + reader.read_exact(&mut additional_data_len[..])?; + let additional_data_len = u32::from_le_bytes(additional_data_len); + let mut additional_data = vec![0u8; additional_data_len as usize]; + + reader.read_exact(&mut additional_data[..])?; + + Ok(Params { + k, + n: n as u64, + g, + g_lagrange, + additional_data, + }) + } + *) + Definition read (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ R ], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let k := M.alloc (| repeat (Value.Integer 0) 4 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Read", R, [], "read_exact", [] |), + [ + reader; + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply (Ty.path "array") [ Ty.path "u8" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index_mut", + [] + |), + [ k; Value.StructTuple "core::ops::range::RangeFull" [] ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::commitment::Params") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let k := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "from_le_bytes", [] |), + [ M.read (| k |) ] + |) + |) in + let n := M.alloc (| BinOp.Panic.shl (| Value.Integer 1, M.read (| k |) |) |) in + let load_points_from_file_parallelly := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let reader := M.copy (| γ |) in + M.read (| + let points_compressed := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.associated, + [], + "default", + [] + |), + [] + |); + M.read (| n |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ points_compressed ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let points_compressed := + M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "std::io::Read", + R, + [], + "read_exact", + [] + |), + [ + M.read (| reader |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsMut", + Ty.associated, + [ + Ty.apply + (Ty.path + "slice") + [ + Ty.path + "u8" + ] + ], + "as_mut", + [] + |), + [ + M.read (| + points_compressed + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + C; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let points := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ C ] |), + [ + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + C, + [], + "default", + [] + |), + [] + |); + M.read (| n |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + C; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "slice") [ C ] ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ points ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let points := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let chunks := + M.copy (| γ |) in + M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ C ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ C ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ C ], + "iter_mut", + [] + |), + [ + M.read (| + points + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ + C + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let + γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + i := + M.copy (| + γ1_0 + |) in + let + point := + M.copy (| + γ1_1 + |) in + let + _ := + M.write (| + M.read (| + point + |), + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + C + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.apply + (Ty.path + "core::option::Option") + [ + C + ], + [ + Ty.apply + (Ty.path + "subtle::CtOption") + [ + C + ] + ], + "from", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "group::GroupEncoding", + C, + [], + "from_bytes", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + points_compressed; + BinOp.Panic.add (| + Integer.Usize, + M.read (| + chunks + |), + M.read (| + i + |) + |) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ M.read (| points |) ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let g := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&mut") [ R ] ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ]), + [ Ty.tuple [ Ty.apply (Ty.path "&mut") [ R ] ] ], + "call", + [] + |), + [ load_points_from_file_parallelly; Value.Tuple [ reader ] ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::commitment::Params") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let g_lagrange := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [ Ty.apply (Ty.path "&mut") [ R ] ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ]), + [ Ty.tuple [ Ty.apply (Ty.path "&mut") [ R ] ] ], + "call", + [] + |), + [ load_points_from_file_parallelly; Value.Tuple [ reader ] ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::commitment::Params") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let additional_data_len := M.alloc (| repeat (Value.Integer 0) 4 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Read", R, [], "read_exact", [] |), + [ + reader; + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply (Ty.path "array") [ Ty.path "u8" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index_mut", + [] + |), + [ + additional_data_len; + Value.StructTuple "core::ops::range::RangeFull" [] + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::commitment::Params") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let additional_data_len := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "from_le_bytes", [] |), + [ M.read (| additional_data_len |) ] + |) + |) in + let additional_data := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ Ty.path "u8" ] |), + [ Value.Integer 0; M.rust_cast (M.read (| additional_data_len |)) ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Read", R, [], "read_exact", [] |), + [ + reader; + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index_mut", + [] + |), + [ + additional_data; + Value.StructTuple "core::ops::range::RangeFull" [] + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::commitment::Params") + [ C ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::poly::commitment::Params" + [ + ("k", M.read (| k |)); + ("n", M.rust_cast (M.read (| n |))); + ("g", M.read (| g |)); + ("g_lagrange", M.read (| g_lagrange |)); + ("additional_data", M.read (| additional_data |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_read : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "read" (read C). + + (* + pub fn verifier>( + &self, + public_inputs_size: usize, + ) -> io::Result> { + assert!(public_inputs_size < self.n as usize); + let g_lagrange = self.g_lagrange[..public_inputs_size].to_vec(); + let g2 = ::generator(); + + let additional_data = self.additional_data.clone(); + + let s_g2 = E::G2Affine::read(&mut additional_data.as_slice())?; + + Ok(ParamsVerifier { + k: self.k, + n: self.n, + g1: self.g[0], + g_lagrange, + g2, + s_g2, + }) + } + *) + Definition verifier (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [ E ], [ self; public_inputs_size ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let public_inputs_size := M.alloc (| public_inputs_size |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.lt + (M.read (| public_inputs_size |)) + (M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)))) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "assertion failed: public_inputs_size < self.n as usize" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let g_lagrange := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ C ], + "to_vec", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ], + [ Ty.apply (Ty.path "core::ops::range::RangeTo") [ Ty.path "usize" ] + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "g_lagrange" + |); + Value.StructRecord + "core::ops::range::RangeTo" + [ ("end_", M.read (| public_inputs_size |)) ] + ] + |) + ] + |) + |) in + let g2 := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::prime::PrimeCurveAffine", + Ty.associated, + [], + "generator", + [] + |), + [] + |) + |) in + let additional_data := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "additional_data" + |) + ] + |) + |) in + let s_g2 := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::CurveRead", + Ty.associated, + [], + "read", + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ] + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ], + "as_slice", + [] + |), + [ additional_data ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::ParamsVerifier") + [ E ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::poly::commitment::ParamsVerifier" + [ + ("k", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "k" + |) + |)); + ("n", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)); + ("g1", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Params", + "g" + |); + Value.Integer 0 + ] + |) + |)); + ("g_lagrange", M.read (| g_lagrange |)); + ("g2", M.read (| g2 |)); + ("s_g2", M.read (| s_g2 |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_verifier : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "verifier" (verifier C). + End Impl_halo2_proofs_poly_commitment_Params_C. + + (* StructTuple + { + name := "Blind"; + ty_params := [ "F" ]; + fields := [ F ]; + } *) + + Module Impl_core_marker_Copy_where_core_marker_Copy_F_for_halo2_proofs_poly_commitment_Blind_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Blind") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_F_for_halo2_proofs_poly_commitment_Blind_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_for_halo2_proofs_poly_commitment_Blind_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Blind") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructTuple + "halo2_proofs::poly::commitment::Blind" + [ + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", F, [], "clone", [] |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Blind", + 0 + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_for_halo2_proofs_poly_commitment_Blind_F. + + Module Impl_core_marker_StructuralEq_for_halo2_proofs_poly_commitment_Blind_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Blind") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::StructuralEq" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralEq_for_halo2_proofs_poly_commitment_Blind_F. + + Module Impl_core_cmp_Eq_where_core_cmp_Eq_F_for_halo2_proofs_poly_commitment_Blind_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Blind") [ F ]. + + (* Eq *) + Definition assert_receiver_is_total_eq (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::cmp::Eq" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("assert_receiver_is_total_eq", InstanceField.Method (assert_receiver_is_total_eq F)) ]. + End Impl_core_cmp_Eq_where_core_cmp_Eq_F_for_halo2_proofs_poly_commitment_Blind_F. + + Module Impl_core_marker_StructuralPartialEq_for_halo2_proofs_poly_commitment_Blind_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Blind") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::StructuralPartialEq" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_halo2_proofs_poly_commitment_Blind_F. + + Module Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_F_for_halo2_proofs_poly_commitment_Blind_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Blind") [ F ]. + + (* PartialEq *) + Definition eq (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.call_closure (| + M.get_trait_method (| "core::cmp::PartialEq", F, [ F ], "eq", [] |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Blind", + 0 + |); + M.SubPointer.get_struct_tuple_field (| + M.read (| other |), + "halo2_proofs::poly::commitment::Blind", + 0 + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::cmp::PartialEq" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method (eq F)) ]. + End Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_F_for_halo2_proofs_poly_commitment_Blind_F. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_for_halo2_proofs_poly_commitment_Blind_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Blind") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Blind" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Blind", + 0 + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_for_halo2_proofs_poly_commitment_Blind_F. + + Module Impl_core_default_Default_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_halo2_proofs_poly_commitment_Blind_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Blind") [ F ]. + + (* + fn default() -> Self { + Blind(F::one()) + } + *) + Definition default (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [] => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::poly::commitment::Blind" + [ M.call_closure (| M.get_trait_method (| "ff::Field", F, [], "one", [] |), [] |) ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::default::Default" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("default", InstanceField.Method (default F)) ]. + End Impl_core_default_Default_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_halo2_proofs_poly_commitment_Blind_F. + + Module Impl_core_ops_arith_Add_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_halo2_proofs_poly_commitment_Blind_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Blind") [ F ]. + + (* type Output = Self; *) + Definition _Output (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Blind") [ F ]. + + (* + fn add(self, rhs: Blind) -> Self { + Blind(self.0 + rhs.0) + } + *) + Definition add (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + Value.StructTuple + "halo2_proofs::poly::commitment::Blind" + [ + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Add", F, [ F ], "add", [] |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + self, + "halo2_proofs::poly::commitment::Blind", + 0 + |) + |); + M.read (| + M.SubPointer.get_struct_tuple_field (| + rhs, + "halo2_proofs::poly::commitment::Blind", + 0 + |) + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::Add" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F)); ("add", InstanceField.Method (add F)) ]. + End Impl_core_ops_arith_Add_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_halo2_proofs_poly_commitment_Blind_F. + + Module Impl_core_ops_arith_Mul_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_halo2_proofs_poly_commitment_Blind_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Blind") [ F ]. + + (* type Output = Self; *) + Definition _Output (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Blind") [ F ]. + + (* + fn mul(self, rhs: Blind) -> Self { + Blind(self.0 * rhs.0) + } + *) + Definition mul (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + Value.StructTuple + "halo2_proofs::poly::commitment::Blind" + [ + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Mul", F, [ F ], "mul", [] |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + self, + "halo2_proofs::poly::commitment::Blind", + 0 + |) + |); + M.read (| + M.SubPointer.get_struct_tuple_field (| + rhs, + "halo2_proofs::poly::commitment::Blind", + 0 + |) + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::Mul" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("Output", InstanceField.Ty (_Output F)); ("mul", InstanceField.Method (mul F)) ]. + End Impl_core_ops_arith_Mul_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_halo2_proofs_poly_commitment_Blind_F. + + Module Impl_core_ops_arith_AddAssign_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_halo2_proofs_poly_commitment_Blind_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Blind") [ F ]. + + (* + fn add_assign(&mut self, rhs: Blind) { + self.0 += rhs.0; + } + *) + Definition add_assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::AddAssign", + F, + [ F ], + "add_assign", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Blind", + 0 + |); + M.read (| + M.SubPointer.get_struct_tuple_field (| + rhs, + "halo2_proofs::poly::commitment::Blind", + 0 + |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::AddAssign" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("add_assign", InstanceField.Method (add_assign F)) ]. + End Impl_core_ops_arith_AddAssign_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_halo2_proofs_poly_commitment_Blind_F. + + Module Impl_core_ops_arith_MulAssign_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_halo2_proofs_poly_commitment_Blind_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Blind") [ F ]. + + (* + fn mul_assign(&mut self, rhs: Blind) { + self.0 *= rhs.0; + } + *) + Definition mul_assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + F, + [ F ], + "mul_assign", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Blind", + 0 + |); + M.read (| + M.SubPointer.get_struct_tuple_field (| + rhs, + "halo2_proofs::poly::commitment::Blind", + 0 + |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::MulAssign" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("mul_assign", InstanceField.Method (mul_assign F)) ]. + End Impl_core_ops_arith_MulAssign_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_halo2_proofs_poly_commitment_Blind_F. + + Module Impl_core_ops_arith_AddAssign_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_halo2_proofs_poly_commitment_Blind_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Blind") [ F ]. + + (* + fn add_assign(&mut self, rhs: F) { + self.0 += rhs; + } + *) + Definition add_assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::AddAssign", + F, + [ F ], + "add_assign", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Blind", + 0 + |); + M.read (| rhs |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::AddAssign" + (Self F) + (* Trait polymorphic types *) [ (* Rhs *) F ] + (* Instance *) [ ("add_assign", InstanceField.Method (add_assign F)) ]. + End Impl_core_ops_arith_AddAssign_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_halo2_proofs_poly_commitment_Blind_F. + + Module Impl_core_ops_arith_MulAssign_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_halo2_proofs_poly_commitment_Blind_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Blind") [ F ]. + + (* + fn mul_assign(&mut self, rhs: F) { + self.0 *= rhs; + } + *) + Definition mul_assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; rhs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let rhs := M.alloc (| rhs |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + F, + [ F ], + "mul_assign", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::Blind", + 0 + |); + M.read (| rhs |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::ops::arith::MulAssign" + (Self F) + (* Trait polymorphic types *) [ (* Rhs *) F ] + (* Instance *) [ ("mul_assign", InstanceField.Method (mul_assign F)) ]. + End Impl_core_ops_arith_MulAssign_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_halo2_proofs_poly_commitment_Blind_F. + + Module Impl_halo2_proofs_poly_commitment_ParamsVerifier_E. + Definition Self (E : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::commitment::ParamsVerifier") [ E ]. + + (* + pub fn public_inputs_size(&self) -> usize { + self.g_lagrange.len() + } + *) + Definition public_inputs_size (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::ParamsVerifier", + "g_lagrange" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_public_inputs_size : + forall (E : Ty.t), + M.IsAssociatedFunction (Self E) "public_inputs_size" (public_inputs_size E). + + (* + pub fn empty_msm(&self) -> MSM { + MSM::new() + } + *) + Definition empty_msm (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ Ty.associated ], + "new", + [] + |), + [] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_empty_msm : + forall (E : Ty.t), + M.IsAssociatedFunction (Self E) "empty_msm" (empty_msm E). + + (* + pub fn commit_lagrange(&self, scalars: Vec) -> E::G1 { + let bases = &self.g_lagrange; + let size = scalars.len(); + assert!(bases.len() >= size); + best_multiexp_gpu_cond(&scalars, &bases[0..size]) + } + *) + Definition commit_lagrange (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [ self; scalars ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let scalars := M.alloc (| scalars |) in + M.read (| + let bases := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::ParamsVerifier", + "g_lagrange" + |) + |) in + let size := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ scalars ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.ge + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ M.read (| bases |) ] + |)) + (M.read (| size |))) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "assertion failed: bases.len() >= size" |) ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::best_multiexp_gpu_cond", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ scalars ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ] ], + "index", + [] + |), + [ + M.read (| bases |); + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| size |)) ] + ] + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_commit_lagrange : + forall (E : Ty.t), + M.IsAssociatedFunction (Self E) "commit_lagrange" (commit_lagrange E). + + (* + pub fn write(&self, writer: &mut W) -> io::Result<()> { + writer.write_all(&self.k.to_le_bytes())?; + let public_inputs_size = self.public_inputs_size() as u32; + writer.write_all(&public_inputs_size.to_le_bytes())?; + + writer.write_all(self.g1.to_bytes().as_ref())?; + writer.write_all(self.g2.to_bytes().as_ref())?; + writer.write_all(self.s_g2.to_bytes().as_ref())?; + for el in &self.g_lagrange { + writer.write_all(el.to_bytes().as_ref())?; + } + Ok(()) + } + *) + Definition write (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [ W ], [ self; writer ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let writer := M.alloc (| writer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write_all", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::ParamsVerifier", + "k" + |) + |) + ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let public_inputs_size := + M.alloc (| + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::commitment::ParamsVerifier") + [ E ], + "public_inputs_size", + [] + |), + [ M.read (| self |) ] + |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write_all", [] |), + [ + M.read (| writer |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "to_le_bytes", + [] + |), + [ M.read (| public_inputs_size |) ] + |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write_all", [] |), + [ + M.read (| writer |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::GroupEncoding", + Ty.associated, + [], + "to_bytes", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::ParamsVerifier", + "g1" + |) + ] + |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write_all", [] |), + [ + M.read (| writer |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::GroupEncoding", + Ty.associated, + [], + "to_bytes", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::ParamsVerifier", + "g2" + |) + ] + |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write_all", [] |), + [ + M.read (| writer |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::GroupEncoding", + Ty.associated, + [], + "to_bytes", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::ParamsVerifier", + "s_g2" + |) + ] + |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ], + [], + "into_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::commitment::ParamsVerifier", + "g_lagrange" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.associated ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let el := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "std::io::Write", + W, + [], + "write_all", + [] + |), + [ + M.read (| writer |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ + Ty.apply + (Ty.path "slice") + [ Ty.path "u8" ] + ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::GroupEncoding", + Ty.associated, + [], + "to_bytes", + [] + |), + [ M.read (| el |) ] + |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_write : + forall (E : Ty.t), + M.IsAssociatedFunction (Self E) "write" (write E). + + (* + pub fn read(mut reader: R) -> io::Result { + let mut k = [0u8; 4]; + reader.read_exact(&mut k[..])?; + let k = u32::from_le_bytes(k); + + let mut public_inputs_size = [0u8; 4]; + reader.read_exact(&mut public_inputs_size[..])?; + let public_inputs_size = u32::from_le_bytes(public_inputs_size); + + let n = 1 << k; + + let g1 = E::G1Affine::read(&mut reader)?; + let g2 = E::G2Affine::read(&mut reader)?; + let s_g2 = E::G2Affine::read(&mut reader)?; + let g_lagrange: Vec = (0..public_inputs_size) + .map(|_| E::G1Affine::read(&mut reader)) + .collect::>()?; + + Ok(ParamsVerifier { + k, + n, + g1, + g2, + s_g2, + g_lagrange, + }) + } + *) + Definition read (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [ R ], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let k := M.alloc (| repeat (Value.Integer 0) 4 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Read", R, [], "read_exact", [] |), + [ + reader; + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply (Ty.path "array") [ Ty.path "u8" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index_mut", + [] + |), + [ k; Value.StructTuple "core::ops::range::RangeFull" [] ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::ParamsVerifier") + [ E ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let k := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "from_le_bytes", [] |), + [ M.read (| k |) ] + |) + |) in + let public_inputs_size := M.alloc (| repeat (Value.Integer 0) 4 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Read", R, [], "read_exact", [] |), + [ + reader; + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply (Ty.path "array") [ Ty.path "u8" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index_mut", + [] + |), + [ + public_inputs_size; + Value.StructTuple "core::ops::range::RangeFull" [] + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::ParamsVerifier") + [ E ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let public_inputs_size := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "from_le_bytes", [] |), + [ M.read (| public_inputs_size |) ] + |) + |) in + let n := M.alloc (| BinOp.Panic.shl (| Value.Integer 1, M.read (| k |) |) |) in + let g1 := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::CurveRead", + Ty.associated, + [], + "read", + [ R ] + |), + [ reader ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::ParamsVerifier") + [ E ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let g2 := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::CurveRead", + Ty.associated, + [], + "read", + [ R ] + |), + [ reader ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::ParamsVerifier") + [ E ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let s_g2 := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::CurveRead", + Ty.associated, + [], + "read", + [ R ] + |), + [ reader ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::ParamsVerifier") + [ E ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let g_lagrange := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ]; + Ty.function + [ Ty.tuple [ Ty.path "u32" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ]; + Ty.function + [ Ty.tuple [ Ty.path "u32" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ]) + ] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", M.read (| public_inputs_size |)) + ]; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "halo2_proofs::helpers::CurveRead", + Ty.associated, + [], + "read", + [ R ] + |), + [ reader ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::ParamsVerifier") + [ E ]; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "halo2_proofs::poly::commitment::ParamsVerifier" + [ + ("k", M.read (| k |)); + ("n", M.read (| n |)); + ("g1", M.read (| g1 |)); + ("g2", M.read (| g2 |)); + ("s_g2", M.read (| s_g2 |)); + ("g_lagrange", M.read (| g_lagrange |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_read : + forall (E : Ty.t), + M.IsAssociatedFunction (Self E) "read" (read E). + End Impl_halo2_proofs_poly_commitment_ParamsVerifier_E. + End commitment. +End poly. diff --git a/CoqOfRust/halo2_proofs/poly/domain.v b/CoqOfRust/halo2_proofs/poly/domain.v new file mode 100644 index 000000000..c22ab6862 --- /dev/null +++ b/CoqOfRust/halo2_proofs/poly/domain.v @@ -0,0 +1,5441 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module poly. + Module domain. + (* StructRecord + { + name := "EvaluationDomain"; + ty_params := [ "G" ]; + fields := + [ + ("n", Ty.path "u64"); + ("k", Ty.path "u32"); + ("extended_k", Ty.path "u32"); + ("omega", Ty.associated); + ("omega_inv", Ty.associated); + ("extended_omega", Ty.associated); + ("extended_omega_inv", Ty.associated); + ("g_coset", Ty.associated); + ("g_coset_inv", Ty.associated); + ("quotient_poly_degree", Ty.path "u64"); + ("ifft_divisor", Ty.associated); + ("extended_ifft_divisor", Ty.associated); + ("t_evaluations", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]); + ("barycentric_weight", Ty.associated) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_G_where_pairing_bn256_arithmetic_Group_G_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_poly_domain_EvaluationDomain_G. + Definition Self (G : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") [ G ]. + + (* Debug *) + Definition fmt (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let names := + M.alloc (| + M.alloc (| + Value.Array + [ + M.read (| Value.String "n" |); + M.read (| Value.String "k" |); + M.read (| Value.String "extended_k" |); + M.read (| Value.String "omega" |); + M.read (| Value.String "omega_inv" |); + M.read (| Value.String "extended_omega" |); + M.read (| Value.String "extended_omega_inv" |); + M.read (| Value.String "g_coset" |); + M.read (| Value.String "g_coset_inv" |); + M.read (| Value.String "quotient_poly_degree" |); + M.read (| Value.String "ifft_divisor" |); + M.read (| Value.String "extended_ifft_divisor" |); + M.read (| Value.String "t_evaluations" |); + M.read (| Value.String "barycentric_weight" |) + ] + |) + |) in + let values := + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "n" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "k" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_k" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "omega" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "omega_inv" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_omega" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_omega_inv" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "g_coset" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "g_coset_inv" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "quotient_poly_degree" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "ifft_divisor" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_ifft_divisor" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "t_evaluations" + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "barycentric_weight" + |) + |)) + ] + |)) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_fields_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "EvaluationDomain" |); + (* Unsize *) M.pointer_coercion (M.read (| names |)); + M.read (| values |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (G : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self G) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt G)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_G_where_pairing_bn256_arithmetic_Group_G_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_poly_domain_EvaluationDomain_G. + + Module Impl_core_marker_StructuralPartialEq_where_pairing_bn256_arithmetic_Group_G_for_halo2_proofs_poly_domain_EvaluationDomain_G. + Definition Self (G : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") [ G ]. + + Axiom Implements : + forall (G : Ty.t), + M.IsTraitInstance + "core::marker::StructuralPartialEq" + (Self G) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_where_pairing_bn256_arithmetic_Group_G_for_halo2_proofs_poly_domain_EvaluationDomain_G. + + Module Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_G_where_pairing_bn256_arithmetic_Group_G_where_core_cmp_PartialEq_associated_type_where_core_cmp_PartialEq_associated_type_where_core_cmp_PartialEq_associated_type_where_core_cmp_PartialEq_associated_type_where_core_cmp_PartialEq_associated_type_where_core_cmp_PartialEq_associated_type_where_core_cmp_PartialEq_associated_type_where_core_cmp_PartialEq_associated_type_where_core_cmp_PartialEq_associated_type_where_core_cmp_PartialEq_associated_type_for_halo2_proofs_poly_domain_EvaluationDomain_G. + Definition Self (G : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") [ G ]. + + (* PartialEq *) + Definition eq (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + LogicalOp.and (| + LogicalOp.and (| + LogicalOp.and (| + LogicalOp.and (| + LogicalOp.and (| + LogicalOp.and (| + LogicalOp.and (| + LogicalOp.and (| + LogicalOp.and (| + LogicalOp.and (| + LogicalOp.and (| + LogicalOp.and (| + LogicalOp.and (| + BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "n" + |) + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::domain::EvaluationDomain", + "n" + |) + |)), + ltac:(M.monadic + (BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "k" + |) + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::domain::EvaluationDomain", + "k" + |) + |)))) + |), + ltac:(M.monadic + (BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_k" + |) + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_k" + |) + |)))) + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ Ty.associated ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "omega" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::domain::EvaluationDomain", + "omega" + |) + ] + |))) + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ Ty.associated ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "omega_inv" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::domain::EvaluationDomain", + "omega_inv" + |) + ] + |))) + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ Ty.associated ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_omega" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_omega" + |) + ] + |))) + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ Ty.associated ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_omega_inv" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_omega_inv" + |) + ] + |))) + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ Ty.associated ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "g_coset" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::domain::EvaluationDomain", + "g_coset" + |) + ] + |))) + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ Ty.associated ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "g_coset_inv" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::domain::EvaluationDomain", + "g_coset_inv" + |) + ] + |))) + |), + ltac:(M.monadic + (BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "quotient_poly_degree" + |) + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::domain::EvaluationDomain", + "quotient_poly_degree" + |) + |)))) + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ Ty.associated ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "ifft_divisor" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::domain::EvaluationDomain", + "ifft_divisor" + |) + ] + |))) + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ Ty.associated ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_ifft_divisor" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_ifft_divisor" + |) + ] + |))) + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "t_evaluations" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::domain::EvaluationDomain", + "t_evaluations" + |) + ] + |))) + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ Ty.associated ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "barycentric_weight" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::domain::EvaluationDomain", + "barycentric_weight" + |) + ] + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (G : Ty.t), + M.IsTraitInstance + "core::cmp::PartialEq" + (Self G) + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method (eq G)) ]. + End Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_G_where_pairing_bn256_arithmetic_Group_G_where_core_cmp_PartialEq_associated_type_where_core_cmp_PartialEq_associated_type_where_core_cmp_PartialEq_associated_type_where_core_cmp_PartialEq_associated_type_where_core_cmp_PartialEq_associated_type_where_core_cmp_PartialEq_associated_type_where_core_cmp_PartialEq_associated_type_where_core_cmp_PartialEq_associated_type_where_core_cmp_PartialEq_associated_type_where_core_cmp_PartialEq_associated_type_for_halo2_proofs_poly_domain_EvaluationDomain_G. + + Module Impl_core_clone_Clone_where_core_clone_Clone_G_where_pairing_bn256_arithmetic_Group_G_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_for_halo2_proofs_poly_domain_EvaluationDomain_G. + Definition Self (G : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") [ G ]. + + (* Clone *) + Definition clone (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::poly::domain::EvaluationDomain" + [ + ("n", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u64", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "n" + |) + ] + |)); + ("k", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "k" + |) + ] + |)); + ("extended_k", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_k" + |) + ] + |)); + ("omega", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.associated, [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "omega" + |) + ] + |)); + ("omega_inv", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.associated, [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "omega_inv" + |) + ] + |)); + ("extended_omega", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.associated, [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_omega" + |) + ] + |)); + ("extended_omega_inv", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.associated, [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_omega_inv" + |) + ] + |)); + ("g_coset", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.associated, [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "g_coset" + |) + ] + |)); + ("g_coset_inv", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.associated, [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "g_coset_inv" + |) + ] + |)); + ("quotient_poly_degree", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u64", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "quotient_poly_degree" + |) + ] + |)); + ("ifft_divisor", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.associated, [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "ifft_divisor" + |) + ] + |)); + ("extended_ifft_divisor", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.associated, [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_ifft_divisor" + |) + ] + |)); + ("t_evaluations", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "t_evaluations" + |) + ] + |)); + ("barycentric_weight", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.associated, [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "barycentric_weight" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (G : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self G) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone G)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_G_where_pairing_bn256_arithmetic_Group_G_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_for_halo2_proofs_poly_domain_EvaluationDomain_G. + + Module Impl_halo2_proofs_poly_domain_EvaluationDomain_G. + Definition Self (G : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") [ G ]. + + (* + pub fn new(j: u32, k: u32) -> Self { + // quotient_poly_degree * params.n - 1 is the degree of the quotient polynomial + let quotient_poly_degree = (j - 1) as u64; + + // n = 2^k + let n = 1u64 << k; + + debug!("quotient_poly_degree {}", quotient_poly_degree); + + // We need to work within an extended domain, not params.k but params.k + i + // for some integer i such that 2^(params.k + i) is sufficiently large to + // describe the quotient polynomial. + let mut extended_k = k; + while (1 << extended_k) < (n * quotient_poly_degree) { + extended_k += 1; + } + + let mut extended_omega = G::Scalar::root_of_unity(); + + // Get extended_omega, the 2^{extended_k}'th root of unity + // The loop computes extended_omega = omega^{2 ^ (S - extended_k)} + // Notice that extended_omega ^ {2 ^ extended_k} = omega ^ {2^S} = 1. + for _ in extended_k..G::Scalar::S { + extended_omega = extended_omega.square(); + } + let extended_omega = extended_omega; + let mut extended_omega_inv = extended_omega; // Inversion computed later + + // Get omega, the 2^{k}'th root of unity (i.e. n'th root of unity) + // The loop computes omega = extended_omega ^ {2 ^ (extended_k - k)} + // = (omega^{2 ^ (S - extended_k)}) ^ {2 ^ (extended_k - k)} + // = omega ^ {2 ^ (S - k)}. + // Notice that omega ^ {2^k} = omega ^ {2^S} = 1. + let mut omega = extended_omega; + for _ in k..extended_k { + omega = omega.square(); + } + let omega = omega; + let mut omega_inv = omega; // Inversion computed later + + // We use zeta here because we know it generates a coset, and it's available + // already. + // The coset evaluation domain is: + // zeta {1, extended_omega, extended_omega^2, ..., extended_omega^{(2^extended_k) - 1}} + let g_coset = G::Scalar::ZETA; + let g_coset_inv = g_coset.square(); + + let mut t_evaluations = Vec::with_capacity(1 << (extended_k - k)); + { + // Compute the evaluations of t(X) = X^n - 1 in the coset evaluation domain. + // We don't have to compute all of them, because it will repeat. + let orig = G::Scalar::ZETA.pow_vartime(&[n as u64, 0, 0, 0]); + let step = extended_omega.pow_vartime(&[n as u64, 0, 0, 0]); + let mut cur = orig; + loop { + t_evaluations.push(cur); + cur *= &step; + if cur == orig { + break; + } + } + assert_eq!(t_evaluations.len(), 1 << (extended_k - k)); + + // Subtract 1 from each to give us t_evaluations[i] = t(zeta * extended_omega^i) + for coeff in &mut t_evaluations { + *coeff -= &G::Scalar::one(); + } + + // Invert, because we're dividing by this polynomial. + // We invert in a batch, below. + } + + let mut ifft_divisor = G::Scalar::from(1 << k); // Inversion computed later + let mut extended_ifft_divisor = G::Scalar::from(1 << extended_k); // Inversion computed later + + // The barycentric weight of 1 over the evaluation domain + // 1 / \prod_{i != 0} (1 - omega^i) + let mut barycentric_weight = G::Scalar::from(n); // Inversion computed later + + // Compute batch inversion + t_evaluations + .iter_mut() + .chain(Some(&mut ifft_divisor)) + .chain(Some(&mut extended_ifft_divisor)) + .chain(Some(&mut barycentric_weight)) + .chain(Some(&mut extended_omega_inv)) + .chain(Some(&mut omega_inv)) + .batch_invert(); + + EvaluationDomain { + n, + k, + extended_k, + omega, + omega_inv, + extended_omega, + extended_omega_inv, + g_coset, + g_coset_inv, + quotient_poly_degree, + ifft_divisor, + extended_ifft_divisor, + t_evaluations, + barycentric_weight, + } + } + *) + Definition new (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ j; k ] => + ltac:(M.monadic + (let j := M.alloc (| j |) in + let k := M.alloc (| k |) in + M.read (| + let quotient_poly_degree := + M.alloc (| + M.rust_cast (BinOp.Panic.sub (| Integer.U32, M.read (| j |), Value.Integer 1 |)) + |) in + let n := M.alloc (| BinOp.Panic.shl (| Value.Integer 1, M.read (| k |) |) |) in + let _ := + let lvl := M.alloc (| Value.StructTuple "log::Level::Debug" [] |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ lvl; M.get_constant (| "log::STATIC_MAX_LEVEL" |) ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ + lvl; + M.alloc (| + M.call_closure (| + M.get_function (| "log::max_level", [] |), + [] + |) + |) + ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| "log::__private_api::log", [ Ty.tuple [] ] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ M.read (| Value.String "quotient_poly_degree " |) ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "u64" ] + |), + [ quotient_poly_degree ] + |) + ] + |)) + ] + |); + M.read (| lvl |); + M.alloc (| + Value.Tuple + [ + M.read (| Value.String "halo2_proofs::poly::domain" |); + M.read (| Value.String "halo2_proofs::poly::domain" |); + M.read (| Value.String "halo2_proofs/src/poly/domain.rs" |) + ] + |); + Value.Integer 51; + Value.Tuple [] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let extended_k := M.copy (| k |) in + let _ := + M.loop (| + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (BinOp.Panic.shl (| Value.Integer 1, M.read (| extended_k |) |)) + (BinOp.Panic.mul (| + Integer.U64, + M.read (| n |), + M.read (| quotient_poly_degree |) + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let _ := + let β := extended_k in + M.write (| + β, + BinOp.Panic.add (| Integer.U32, M.read (| β |), Value.Integer 1 |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + let _ := + M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |) in + M.alloc (| Value.Tuple [] |) + |) + |) + |))) + ] + |))) + |) in + let extended_omega := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::PrimeField", + Ty.associated, + [], + "root_of_unity", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", M.read (| extended_k |)); + ("end_", M.read (| M.get_constant (| "ff::PrimeField::S" |) |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let _ := + M.write (| + extended_omega, + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "square", + [] + |), + [ extended_omega ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let extended_omega := M.copy (| extended_omega |) in + let extended_omega_inv := M.copy (| extended_omega |) in + let omega := M.copy (| extended_omega |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", M.read (| k |)); ("end_", M.read (| extended_k |)) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let _ := + M.write (| + omega, + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "square", + [] + |), + [ omega ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let omega := M.copy (| omega |) in + let omega_inv := M.copy (| omega |) in + let g_coset := + M.copy (| + M.get_constant (| "pairing_bn256::arithmetic::fields::FieldExt::ZETA" |) + |) in + let g_coset_inv := + M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "square", [] |), + [ g_coset ] + |) + |) in + let t_evaluations := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "with_capacity", + [] + |), + [ + BinOp.Panic.shl (| + Value.Integer 1, + BinOp.Panic.sub (| Integer.U32, M.read (| extended_k |), M.read (| k |) |) + |) + ] + |) + |) in + let _ := + let orig := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "pow_vartime", + [ Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "array") [ Ty.path "u64" ] ] ] + |), + [ + M.get_constant (| "pairing_bn256::arithmetic::fields::FieldExt::ZETA" |); + M.alloc (| + Value.Array + [ + M.read (| M.use n |); + Value.Integer 0; + Value.Integer 0; + Value.Integer 0 + ] + |) + ] + |) + |) in + let step := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "pow_vartime", + [ Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "array") [ Ty.path "u64" ] ] ] + |), + [ + extended_omega; + M.alloc (| + Value.Array + [ + M.read (| M.use n |); + Value.Integer 0; + Value.Integer 0; + Value.Integer 0 + ] + |) + ] + |) + |) in + let cur := M.copy (| orig |) in + let _ := + M.loop (| + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ t_evaluations; M.read (| cur |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul_assign", + [] + |), + [ cur; step ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ Ty.associated ], + "eq", + [] + |), + [ cur; orig ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ t_evaluations ] + |) + |); + M.alloc (| + BinOp.Panic.shl (| + Value.Integer 1, + BinOp.Panic.sub (| + Integer.U32, + M.read (| extended_k |), + M.read (| k |) + |) + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ], + [], + "into_iter", + [] + |), + [ t_evaluations ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let coeff := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::SubAssign", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "sub_assign", + [] + |), + [ + M.read (| coeff |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let ifft_divisor := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.associated, + [ Ty.path "u64" ], + "from", + [] + |), + [ BinOp.Panic.shl (| Value.Integer 1, M.read (| k |) |) ] + |) + |) in + let extended_ifft_divisor := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.associated, + [ Ty.path "u64" ], + "from", + [] + |), + [ BinOp.Panic.shl (| Value.Integer 1, M.read (| extended_k |) |) ] + |) + |) in + let barycentric_weight := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.associated, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| n |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::batch::BatchInvert", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] + ], + [ Ty.associated ], + "batch_invert", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] + ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::chain::Chain") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ]; + Ty.apply + (Ty.path "core::option::IntoIter") + [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] + ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "chain", + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&mut") [ Ty.associated ] ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ t_evaluations ] + |) + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ ifft_divisor ] + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ extended_ifft_divisor ] + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ barycentric_weight ] + ] + |); + Value.StructTuple "core::option::Option::Some" [ extended_omega_inv ] + ] + |); + Value.StructTuple "core::option::Option::Some" [ omega_inv ] + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::poly::domain::EvaluationDomain" + [ + ("n", M.read (| n |)); + ("k", M.read (| k |)); + ("extended_k", M.read (| extended_k |)); + ("omega", M.read (| omega |)); + ("omega_inv", M.read (| omega_inv |)); + ("extended_omega", M.read (| extended_omega |)); + ("extended_omega_inv", M.read (| extended_omega_inv |)); + ("g_coset", M.read (| g_coset |)); + ("g_coset_inv", M.read (| g_coset_inv |)); + ("quotient_poly_degree", M.read (| quotient_poly_degree |)); + ("ifft_divisor", M.read (| ifft_divisor |)); + ("extended_ifft_divisor", M.read (| extended_ifft_divisor |)); + ("t_evaluations", M.read (| t_evaluations |)); + ("barycentric_weight", M.read (| barycentric_weight |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "new" (new G). + + (* + pub fn lagrange_from_vec(&self, values: Vec) -> Polynomial { + assert_eq!(values.len(), self.n as usize); + + Polynomial { + values, + _marker: PhantomData, + } + } + *) + Definition lagrange_from_vec (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self; values ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let values := M.alloc (| values |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ G; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ values ] + |) + |); + M.alloc (| + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "n" + |) + |)) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", M.read (| values |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_lagrange_from_vec : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "lagrange_from_vec" (lagrange_from_vec G). + + (* + pub fn coeff_from_vec(&self, values: Vec) -> Polynomial { + assert_eq!(values.len(), self.n as usize); + + Polynomial { + values, + _marker: PhantomData, + } + } + *) + Definition coeff_from_vec (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self; values ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let values := M.alloc (| values |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ G; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ values ] + |) + |); + M.alloc (| + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "n" + |) + |)) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", M.read (| values |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_coeff_from_vec : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "coeff_from_vec" (coeff_from_vec G). + + (* + pub fn empty_coeff(&self) -> Polynomial { + Polynomial { + values: vec![G::group_zero(); self.n as usize], + _marker: PhantomData, + } + } + *) + Definition empty_coeff (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ G ] |), + [ + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_zero", + [] + |), + [] + |); + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "n" + |) + |)) + ] + |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_empty_coeff : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "empty_coeff" (empty_coeff G). + + (* + pub fn empty_lagrange(&self) -> Polynomial { + Polynomial { + values: vec![G::group_zero(); self.n as usize], + _marker: PhantomData, + } + } + *) + Definition empty_lagrange (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ G ] |), + [ + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_zero", + [] + |), + [] + |); + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "n" + |) + |)) + ] + |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_empty_lagrange : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "empty_lagrange" (empty_lagrange G). + + (* + pub(crate) fn empty_lagrange_assigned(&self) -> Polynomial, LagrangeCoeff> + where + G: Field, + { + Polynomial { + values: vec![G::group_zero().into(); self.n as usize], + _marker: PhantomData, + } + } + *) + Definition empty_lagrange_assigned (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ G ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + G, + [ Ty.apply (Ty.path "halo2_proofs::plonk::assigned::Assigned") [ G ] ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_zero", + [] + |), + [] + |) + ] + |); + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "n" + |) + |)) + ] + |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_empty_lagrange_assigned : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "empty_lagrange_assigned" (empty_lagrange_assigned G). + + (* + pub fn constant_lagrange(&self, scalar: G) -> Polynomial { + Polynomial { + values: vec![scalar; self.n as usize], + _marker: PhantomData, + } + } + *) + Definition constant_lagrange (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self; scalar ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let scalar := M.alloc (| scalar |) in + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ G ] |), + [ + M.read (| scalar |); + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "n" + |) + |)) + ] + |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_constant_lagrange : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "constant_lagrange" (constant_lagrange G). + + (* + pub fn empty_extended(&self) -> Polynomial { + Polynomial { + values: vec![G::group_zero(); self.extended_len()], + _marker: PhantomData, + } + } + *) + Definition empty_extended (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ G ] |), + [ + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_zero", + [] + |), + [] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") [ G ], + "extended_len", + [] + |), + [ M.read (| self |) ] + |) + ] + |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_empty_extended : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "empty_extended" (empty_extended G). + + (* + pub fn constant_extended(&self, scalar: G) -> Polynomial { + Polynomial { + values: vec![scalar; self.extended_len()], + _marker: PhantomData, + } + } + *) + Definition constant_extended (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self; scalar ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let scalar := M.alloc (| scalar |) in + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ G ] |), + [ + M.read (| scalar |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") [ G ], + "extended_len", + [] + |), + [ M.read (| self |) ] + |) + ] + |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_constant_extended : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "constant_extended" (constant_extended G). + + (* + pub fn lagrange_to_coeff(&self, mut a: Polynomial) -> Polynomial { + assert_eq!(a.values.len(), 1 << self.k); + + // Perform inverse FFT to obtain the polynomial in coefficient form + Self::ifft(&mut a.values, self.omega_inv, self.k, self.ifft_divisor); + + Polynomial { + values: a.values, + _marker: PhantomData, + } + } + *) + Definition lagrange_to_coeff (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self; a ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let a := M.alloc (| a |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ G; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |) + |); + M.alloc (| + BinOp.Panic.shl (| + Value.Integer 1, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "k" + |) + |) + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") [ G ], + "ifft", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ G; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "omega_inv" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "k" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "ifft_divisor" + |) + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", + M.read (| + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |) + |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_lagrange_to_coeff : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "lagrange_to_coeff" (lagrange_to_coeff G). + + (* + pub fn lagrange_to_coeff_st( + &self, + mut a: Polynomial, + ) -> Polynomial { + assert_eq!(a.values.len(), 1 << self.k); + + #[cfg(feature = "cuda")] + // Perform inverse FFT to obtain the polynomial in coefficient form + crate::arithmetic::gpu_ifft(&mut a.values, self.omega_inv, self.k, self.ifft_divisor); + + #[cfg(not(feature = "cuda"))] + Self::ifft_st(&mut a.values, self.omega_inv, self.k, self.ifft_divisor); + + Polynomial { + values: a.values, + _marker: PhantomData, + } + } + *) + Definition lagrange_to_coeff_st (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self; a ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let a := M.alloc (| a |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ G; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |) + |); + M.alloc (| + BinOp.Panic.shl (| + Value.Integer 1, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "k" + |) + |) + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") [ G ], + "ifft_st", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ G; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "omega_inv" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "k" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "ifft_divisor" + |) + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", + M.read (| + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |) + |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_lagrange_to_coeff_st : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "lagrange_to_coeff_st" (lagrange_to_coeff_st G). + + (* + pub fn coeff_to_extended( + &self, + mut a: Polynomial, + ) -> Polynomial { + assert_eq!(a.values.len(), 1 << self.k); + + //let timer = start_timer!(|| format!("prepare {}", self.k)); + self.distribute_powers_zeta(&mut a.values, true); + //end_timer!(timer); + + a.values.resize(self.extended_len(), G::group_zero()); + best_fft(&mut a.values, self.extended_omega, self.extended_k); + + Polynomial { + values: a.values, + _marker: PhantomData, + } + } + *) + Definition coeff_to_extended (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self; a ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let a := M.alloc (| a |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ G; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |) + |); + M.alloc (| + BinOp.Panic.shl (| + Value.Integer 1, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "k" + |) + |) + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") [ G ], + "distribute_powers_zeta", + [] + |), + [ + M.read (| self |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ G; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |); + Value.Bool true + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "alloc::vec::Vec") [ G; Ty.path "alloc::alloc::Global" ], + "resize", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") [ G ], + "extended_len", + [] + |), + [ M.read (| self |) ] + |); + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_zero", + [] + |), + [] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| "halo2_proofs::arithmetic::best_fft", [ G ] |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ G; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_omega" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_k" + |) + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", + M.read (| + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |) + |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_coeff_to_extended : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "coeff_to_extended" (coeff_to_extended G). + + (* + pub fn coeff_to_extended_without_fft( + &self, + mut a: Polynomial, + ) -> Polynomial { + assert_eq!(a.values.len(), 1 << self.k); + + self.distribute_powers_zeta(&mut a.values, true); + + Polynomial { + values: a.values, + _marker: PhantomData, + } + } + *) + Definition coeff_to_extended_without_fft (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self; a ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let a := M.alloc (| a |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ G; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |) + |); + M.alloc (| + BinOp.Panic.shl (| + Value.Integer 1, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "k" + |) + |) + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") [ G ], + "distribute_powers_zeta", + [] + |), + [ + M.read (| self |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ G; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |); + Value.Bool true + ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", + M.read (| + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |) + |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_coeff_to_extended_without_fft : + forall (G : Ty.t), + M.IsAssociatedFunction + (Self G) + "coeff_to_extended_without_fft" + (coeff_to_extended_without_fft G). + + (* + pub fn rotate_extended( + &self, + poly: &Polynomial, + rotation: Rotation, + ) -> Polynomial { + let new_rotation = ((1 << (self.extended_k - self.k)) * rotation.0.abs()) as usize; + + let mut poly = poly.clone(); + + if rotation.0 >= 0 { + poly.values.rotate_left(new_rotation); + } else { + poly.values.rotate_right(new_rotation); + } + + poly + } + *) + Definition rotate_extended (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self; poly; rotation ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let poly := M.alloc (| poly |) in + let rotation := M.alloc (| rotation |) in + M.read (| + let new_rotation := + M.alloc (| + M.rust_cast + (BinOp.Panic.mul (| + Integer.I32, + BinOp.Panic.shl (| + Value.Integer 1, + BinOp.Panic.sub (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_k" + |) + |), + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "k" + |) + |) + |) + |), + M.call_closure (| + M.get_associated_function (| Ty.path "i32", "abs", [] |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + |) + ] + |) + |)) + |) in + let poly := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ G; Ty.path "halo2_proofs::poly::ExtendedLagrangeCoeff" ], + [], + "clone", + [] + |), + [ M.read (| poly |) ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ge + (M.read (| + M.SubPointer.get_struct_tuple_field (| + rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ G ], + "rotate_left", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ G; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + poly, + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |); + M.read (| new_rotation |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ G ], + "rotate_right", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ G; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + poly, + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |); + M.read (| new_rotation |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + poly + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_rotate_extended : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "rotate_extended" (rotate_extended G). + + (* + pub fn extended_to_coeff(&self, mut a: Polynomial) -> Vec { + assert_eq!(a.values.len(), self.extended_len()); + + // Inverse FFT + Self::ifft( + &mut a.values, + self.extended_omega_inv, + self.extended_k, + self.extended_ifft_divisor, + ); + + // Distribute powers to move from coset; opposite from the + // transformation we performed earlier. + self.distribute_powers_zeta(&mut a.values, false); + + // Truncate it to match the size of the quotient polynomial; the + // evaluation domain might be slightly larger than necessary because + // it always lies on a power-of-two boundary. + a.values + .truncate((&self.n * self.quotient_poly_degree) as usize); + + a.values + } + *) + Definition extended_to_coeff (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self; a ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let a := M.alloc (| a |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ G; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |) + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ G ], + "extended_len", + [] + |), + [ M.read (| self |) ] + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") [ G ], + "ifft", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ G; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_omega_inv" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_k" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_ifft_divisor" + |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") [ G ], + "distribute_powers_zeta", + [] + |), + [ + M.read (| self |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ G; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |); + Value.Bool false + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "alloc::vec::Vec") [ G; Ty.path "alloc::alloc::Global" ], + "truncate", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |); + M.rust_cast + (M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "&") [ Ty.path "u64" ], + [ Ty.path "u64" ], + "mul", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "n" + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "quotient_poly_degree" + |) + |) + ] + |)) + ] + |) + |) in + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_extended_to_coeff : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "extended_to_coeff" (extended_to_coeff G). + + (* + pub fn divide_by_vanishing_poly( + &self, + mut a: Polynomial, + ) -> Polynomial { + assert_eq!(a.values.len(), self.extended_len()); + + // Divide to obtain the quotient polynomial in the coset evaluation + // domain. + parallelize(&mut a.values, |h, mut index| { + for h in h { + h.group_scale(&self.t_evaluations[index % self.t_evaluations.len()]); + index += 1; + } + }); + + Polynomial { + values: a.values, + _marker: PhantomData, + } + } + *) + Definition divide_by_vanishing_poly (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self; a ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let a := M.alloc (| a |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ G; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |) + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::domain::EvaluationDomain") + [ G ], + "extended_len", + [] + |), + [ M.read (| self |) ] + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + G; + Ty.function + [ + Ty.tuple + [ + Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ G ] ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ G; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let h := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let index := M.copy (| γ |) in + M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "slice") [ G ] ], + [], + "into_iter", + [] + |), + [ M.read (| h |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ G ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let h := + M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_scale", + [] + |), + [ + M.read (| h |); + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::poly::domain::EvaluationDomain", + "t_evaluations" + |); + BinOp.Panic.rem (| + Integer.Usize, + M.read (| + index + |), + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "halo2_proofs::poly::domain::EvaluationDomain", + "t_evaluations" + |) + ] + |) + |) + ] + |) + ] + |) + |) in + let _ := + let β := index in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", + M.read (| + M.SubPointer.get_struct_record_field (| + a, + "halo2_proofs::poly::Polynomial", + "values" + |) + |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_divide_by_vanishing_poly : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "divide_by_vanishing_poly" (divide_by_vanishing_poly G). + + (* + fn distribute_powers_zeta(&self, a: &mut [G], into_coset: bool) { + let coset_powers = if into_coset { + [self.g_coset, self.g_coset_inv] + } else { + [self.g_coset_inv, self.g_coset] + }; + parallelize(a, |a, mut index| { + for a in a { + // Distribute powers to move into/from coset + let i = index % (coset_powers.len() + 1); + if i != 0 { + a.group_scale(&coset_powers[i - 1]); + } + index += 1; + } + }); + } + *) + Definition distribute_powers_zeta (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self; a; into_coset ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let a := M.alloc (| a |) in + let into_coset := M.alloc (| into_coset |) in + M.read (| + let coset_powers := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use into_coset in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + Value.Array + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "g_coset" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "g_coset_inv" + |) + |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Array + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "g_coset_inv" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "g_coset" + |) + |) + ] + |))) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + G; + Ty.function + [ + Ty.tuple + [ + Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ G ] ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.read (| a |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let index := M.copy (| γ |) in + M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "slice") [ G ] ], + [], + "into_iter", + [] + |), + [ M.read (| a |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ G ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let a := + M.copy (| γ0_0 |) in + let i := + M.alloc (| + BinOp.Panic.rem (| + Integer.Usize, + M.read (| index |), + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ], + "len", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + coset_powers + ] + |), + Value.Integer 1 + |) + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.read (| + i + |)) + (Value.Integer + 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_scale", + [] + |), + [ + M.read (| + a + |); + M.SubPointer.get_array_field (| + coset_powers, + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + M.read (| + i + |), + Value.Integer + 1 + |) + |) + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple [] + |))) + ] + |) in + let _ := + let β := index in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_distribute_powers_zeta : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "distribute_powers_zeta" (distribute_powers_zeta G). + + (* + fn ifft(a: &mut [G], omega_inv: G::Scalar, log_n: u32, divisor: G::Scalar) { + #[cfg(not(feature = "cuda"))] + { + best_fft(a, omega_inv, log_n); + parallelize(a, |a, _| { + for a in a { + // Finish iFFT + a.group_scale(&divisor); + } + }); + } + + #[cfg(feature = "cuda")] + crate::arithmetic::gpu_ifft(a, omega_inv, log_n, divisor) + } + *) + Definition ifft (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ a; omega_inv; log_n; divisor ] => + ltac:(M.monadic + (let a := M.alloc (| a |) in + let omega_inv := M.alloc (| omega_inv |) in + let log_n := M.alloc (| log_n |) in + let divisor := M.alloc (| divisor |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| "halo2_proofs::arithmetic::best_fft", [ G ] |), + [ M.read (| a |); M.read (| omega_inv |); M.read (| log_n |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + G; + Ty.function + [ + Ty.tuple + [ + Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ G ] ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.read (| a |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "slice") [ G ] ], + [], + "into_iter", + [] + |), + [ M.read (| a |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ G ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let a := + M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_scale", + [] + |), + [ + M.read (| a |); + divisor + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_ifft : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "ifft" (ifft G). + + (* + fn ifft_st(a: &mut [G], omega_inv: G::Scalar, log_n: u32, divisor: G::Scalar) { + best_fft(a, omega_inv, log_n); + for a in a { + // Finish iFFT + a.group_scale(&divisor); + } + } + *) + Definition ifft_st (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ a; omega_inv; log_n; divisor ] => + ltac:(M.monadic + (let a := M.alloc (| a |) in + let omega_inv := M.alloc (| omega_inv |) in + let log_n := M.alloc (| log_n |) in + let divisor := M.alloc (| divisor |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| "halo2_proofs::arithmetic::best_fft", [ G ] |), + [ M.read (| a |); M.read (| omega_inv |); M.read (| log_n |) ] + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "&mut") [ Ty.apply (Ty.path "slice") [ G ] ], + [], + "into_iter", + [] + |), + [ M.read (| a |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::IterMut") [ G ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let a := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::Group", + G, + [], + "group_scale", + [] + |), + [ M.read (| a |); divisor ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_ifft_st : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "ifft_st" (ifft_st G). + + (* + pub fn k(&self) -> u32 { + self.k + } + *) + Definition k (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "k" + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_k : forall (G : Ty.t), M.IsAssociatedFunction (Self G) "k" (k G). + + (* + pub fn extended_k(&self) -> u32 { + self.extended_k + } + *) + Definition extended_k (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_k" + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_extended_k : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "extended_k" (extended_k G). + + (* + pub fn extended_len(&self) -> usize { + 1 << self.extended_k + } + *) + Definition extended_len (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + BinOp.Panic.shl (| + Value.Integer 1, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_k" + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_extended_len : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "extended_len" (extended_len G). + + (* + pub fn get_omega(&self) -> G::Scalar { + self.omega + } + *) + Definition get_omega (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "omega" + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get_omega : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "get_omega" (get_omega G). + + (* + pub fn get_omega_inv(&self) -> G::Scalar { + self.omega_inv + } + *) + Definition get_omega_inv (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "omega_inv" + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get_omega_inv : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "get_omega_inv" (get_omega_inv G). + + (* + pub fn get_extended_omega(&self) -> G::Scalar { + self.extended_omega + } + *) + Definition get_extended_omega (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_omega" + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get_extended_omega : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "get_extended_omega" (get_extended_omega G). + + (* + pub fn rotate_omega(&self, value: G::Scalar, rotation: Rotation) -> G::Scalar { + let mut point = value; + if rotation.0 >= 0 { + point *= &self.get_omega().pow_vartime(&[rotation.0 as u64]); + } else { + point *= &self + .get_omega_inv() + .pow_vartime(&[(rotation.0 as i64).abs() as u64]); + } + point + } + *) + Definition rotate_omega (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self; value; rotation ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let value := M.alloc (| value |) in + let rotation := M.alloc (| rotation |) in + M.read (| + let point := M.copy (| value |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ge + (M.read (| + M.SubPointer.get_struct_tuple_field (| + rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul_assign", + [] + |), + [ + point; + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "pow_vartime", + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "array") [ Ty.path "u64" ] ] + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ G ], + "get_omega", + [] + |), + [ M.read (| self |) ] + |) + |); + M.alloc (| + Value.Array + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_tuple_field (| + rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + |)) + ] + |) + ] + |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul_assign", + [] + |), + [ + point; + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "pow_vartime", + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "array") [ Ty.path "u64" ] ] + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ G ], + "get_omega_inv", + [] + |), + [ M.read (| self |) ] + |) + |); + M.alloc (| + Value.Array + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path "i64", + "abs", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_tuple_field (| + rotation, + "halo2_proofs::poly::Rotation", + 0 + |) + |)) + ] + |)) + ] + |) + ] + |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + point + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_rotate_omega : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "rotate_omega" (rotate_omega G). + + (* + pub fn l_i_range + Clone>( + &self, + x: G::Scalar, + xn: G::Scalar, + rotations: I, + ) -> Vec { + let mut results; + { + let rotations = rotations.clone().into_iter(); + results = Vec::with_capacity(rotations.size_hint().1.unwrap_or(0)); + for rotation in rotations { + let rotation = Rotation(rotation); + let result = x - self.rotate_omega(G::Scalar::one(), rotation); + results.push(result); + } + batch_invert(&mut results); + } + + let common = (xn - G::Scalar::one()) * self.barycentric_weight; + for (rotation, result) in rotations.into_iter().zip(results.iter_mut()) { + let rotation = Rotation(rotation); + *result = self.rotate_omega( *result * common, rotation); + } + + results + } + *) + Definition l_i_range (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [ _ as I ], [ self; x; xn; rotations ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let x := M.alloc (| x |) in + let xn := M.alloc (| xn |) in + let rotations := M.alloc (| rotations |) in + M.read (| + let results := M.copy (| Value.DeclaredButUndefined |) in + let _ := + let rotations := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + I, + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", I, [], "clone", [] |), + [ rotations ] + |) + ] + |) + |) in + let _ := + M.write (| + results, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "with_capacity", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ], + "unwrap_or", + [] + |), + [ + M.read (| + M.SubPointer.get_tuple_field (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.associated, + [], + "size_hint", + [] + |), + [ rotations ] + |) + |), + 1 + |) + |); + Value.Integer 0 + ] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.associated, + [], + "into_iter", + [] + |), + [ M.read (| rotations |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.associated, + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let rotation := M.copy (| γ0_0 |) in + let rotation := + M.alloc (| + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ M.read (| rotation |) ] + |) in + let result := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ Ty.associated ], + "sub", + [] + |), + [ + M.read (| x |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ G ], + "rotate_omega", + [] + |), + [ + M.read (| self |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |); + M.read (| rotation |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ results; M.read (| result |) ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::batch_invert", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ results ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) in + let common := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.associated ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.associated, + [ Ty.associated ], + "sub", + [] + |), + [ + M.read (| xn |); + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "one", [] |), + [] + |) + ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "barycentric_weight" + |) + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.associated; + Ty.apply (Ty.path "core::slice::iter::IterMut") [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.associated, + [], + "zip", + [ Ty.apply (Ty.path "core::slice::iter::IterMut") [ Ty.associated ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + I, + [], + "into_iter", + [] + |), + [ M.read (| rotations |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ results ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.associated; + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let rotation := M.copy (| γ1_0 |) in + let result := M.copy (| γ1_1 |) in + let rotation := + M.alloc (| + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ M.read (| rotation |) ] + |) in + let _ := + M.write (| + M.read (| result |), + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::domain::EvaluationDomain") + [ G ], + "rotate_omega", + [] + |), + [ + M.read (| self |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.associated ], + "mul", + [] + |), + [ + M.read (| M.read (| result |) |); + M.read (| common |) + ] + |); + M.read (| rotation |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + results + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_l_i_range : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "l_i_range" (l_i_range G). + + (* + pub fn get_quotient_poly_degree(&self) -> usize { + self.quotient_poly_degree as usize + } + *) + Definition get_quotient_poly_degree (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "quotient_poly_degree" + |) + |)))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get_quotient_poly_degree : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "get_quotient_poly_degree" (get_quotient_poly_degree G). + + (* + pub fn pinned(&self) -> PinnedEvaluationDomain<'_, G> { + PinnedEvaluationDomain { + k: &self.k, + extended_k: &self.extended_k, + omega: &self.omega, + } + } + *) + Definition pinned (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::poly::domain::PinnedEvaluationDomain" + [ + ("k", + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "k" + |)); + ("extended_k", + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "extended_k" + |)); + ("omega", + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::EvaluationDomain", + "omega" + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_pinned : + forall (G : Ty.t), + M.IsAssociatedFunction (Self G) "pinned" (pinned G). + End Impl_halo2_proofs_poly_domain_EvaluationDomain_G. + + (* StructRecord + { + name := "PinnedEvaluationDomain"; + ty_params := [ "G" ]; + fields := + [ + ("k", Ty.apply (Ty.path "&") [ Ty.path "u32" ]); + ("extended_k", Ty.apply (Ty.path "&") [ Ty.path "u32" ]); + ("omega", Ty.apply (Ty.path "&") [ Ty.associated ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_G_where_pairing_bn256_arithmetic_Group_G_where_core_fmt_Debug_associated_type_for_halo2_proofs_poly_domain_PinnedEvaluationDomain_G. + Definition Self (G : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::domain::PinnedEvaluationDomain") [ G ]. + + (* Debug *) + Definition fmt (G : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self G in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "PinnedEvaluationDomain" |); + M.read (| Value.String "k" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::PinnedEvaluationDomain", + "k" + |)); + M.read (| Value.String "extended_k" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::PinnedEvaluationDomain", + "extended_k" + |)); + M.read (| Value.String "omega" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::domain::PinnedEvaluationDomain", + "omega" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (G : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self G) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt G)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_G_where_pairing_bn256_arithmetic_Group_G_where_core_fmt_Debug_associated_type_for_halo2_proofs_poly_domain_PinnedEvaluationDomain_G. + End domain. +End poly. diff --git a/CoqOfRust/halo2_proofs/poly/msm.v b/CoqOfRust/halo2_proofs/poly/msm.v new file mode 100644 index 000000000..0fd514838 --- /dev/null +++ b/CoqOfRust/halo2_proofs/poly/msm.v @@ -0,0 +1,2901 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module poly. + Module msm. + (* StructRecord + { + name := "MSM"; + ty_params := [ "C" ]; + fields := + [ + ("scalars", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]); + ("bases", Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_for_halo2_proofs_poly_msm_MSM_C. + Definition Self (C : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "MSM" |); + M.read (| Value.String "scalars" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::MSM", + "scalars" + |)); + M.read (| Value.String "bases" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::MSM", + "bases" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_for_halo2_proofs_poly_msm_MSM_C. + + Module Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_clone_Clone_associated_type_for_halo2_proofs_poly_msm_MSM_C. + Definition Self (C : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ]. + + (* Clone *) + Definition clone (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::poly::msm::MSM" + [ + ("scalars", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::MSM", + "scalars" + |) + ] + |)); + ("bases", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::MSM", + "bases" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone C)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_clone_Clone_associated_type_for_halo2_proofs_poly_msm_MSM_C. + + Module Impl_core_default_Default_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_poly_msm_MSM_C. + Definition Self (C : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ]. + + (* + fn default() -> Self { + Self::new() + } + *) + Definition default (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [] => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ], + "new", + [] + |), + [] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::default::Default" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("default", InstanceField.Method (default C)) ]. + End Impl_core_default_Default_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_poly_msm_MSM_C. + + Module Impl_halo2_proofs_poly_msm_MSM_C. + Definition Self (C : Ty.t) : Ty.t := Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ]. + + (* + pub fn new() -> Self { + MSM { + scalars: vec![], + bases: vec![], + } + } + *) + Definition new (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [] => + ltac:(M.monadic + (Value.StructRecord + "halo2_proofs::poly::msm::MSM" + [ + ("scalars", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |)); + ("bases", + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "new" (new C). + + (* + pub fn add_msm(&mut self, other: &Self) { + self.scalars.extend(other.scalars.iter()); + self.bases.extend(other.bases.iter()); + } + *) + Definition add_msm (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::Extend", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "extend", + [ Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.associated ] ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::MSM", + "scalars" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::msm::MSM", + "scalars" + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::Extend", + Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ], + [ Ty.apply (Ty.path "&") [ C ] ], + "extend", + [ Ty.apply (Ty.path "core::slice::iter::Iter") [ C ] ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::MSM", + "bases" + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ C ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ C; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::msm::MSM", + "bases" + |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_add_msm : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "add_msm" (add_msm C). + + (* + pub fn append_term(&mut self, scalar: C::Scalar, point: C) { + self.scalars.push(scalar); + self.bases.push(point); + } + *) + Definition append_term (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; scalar; point ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let scalar := M.alloc (| scalar |) in + let point := M.alloc (| point |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::MSM", + "scalars" + |); + M.read (| scalar |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::MSM", + "bases" + |); + M.read (| point |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_append_term : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "append_term" (append_term C). + + (* + pub fn scale(&mut self, factor: C::Scalar) { + if !self.scalars.is_empty() { + parallelize(&mut self.scalars, |scalars, _| { + for other_scalar in scalars { + *other_scalar *= &factor; + } + }) + } + } + *) + Definition scale (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; factor ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let factor := M.alloc (| factor |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "is_empty", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::MSM", + "scalars" + |) + ] + |)) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::MSM", + "scalars" + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let scalars := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ M.read (| scalars |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let other_scalar := + M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "mul_assign", + [] + |), + [ + M.read (| + other_scalar + |); + factor + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_scale : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "scale" (scale C). + + (* + pub fn combine_with_base(&mut self, base: C::Scalar) { + use ff::Field; + let mut acc = C::Scalar::one(); + if !self.scalars.is_empty() { + for scalar in self.scalars.iter_mut().rev() { + *scalar *= &acc; + acc *= base; + } + } + } + *) + Definition combine_with_base (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; base ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let base := M.alloc (| base |) in + M.read (| + let acc := + M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "one", [] |), + [] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "is_empty", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::MSM", + "scalars" + |) + ] + |)) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "rev", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::MSM", + "scalars" + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let scalar := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul_assign", + [] + |), + [ M.read (| scalar |); acc ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ Ty.associated ], + "mul_assign", + [] + |), + [ acc; M.read (| base |) ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_combine_with_base : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "combine_with_base" (combine_with_base C). + + (* + pub fn eval(&self) -> C { + best_multiexp(&self.scalars, &self.bases).into() + } + *) + Definition eval (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| "core::convert::Into", Ty.associated, [ C ], "into", [] |), + [ + M.call_closure (| + M.get_function (| "halo2_proofs::arithmetic::best_multiexp", [ C ] |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::MSM", + "scalars" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::MSM", + "bases" + |) + ] + |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_eval : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "eval" (eval C). + + (* + pub fn check(self) -> bool { + bool::from(self.eval().is_identity()) + } + *) + Definition check (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "bool", + [ Ty.path "subtle::Choice" ], + "from", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "group::prime::PrimeCurveAffine", + C, + [], + "is_identity", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ], + "eval", + [] + |), + [ self ] + |) + |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_check : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "check" (check C). + End Impl_halo2_proofs_poly_msm_MSM_C. + + (* StructRecord + { + name := "PairMSM"; + ty_params := [ "C" ]; + fields := + [ + ("left", Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ]); + ("right", Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_poly_msm_PairMSM_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::msm::PairMSM") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "PairMSM" |); + M.read (| Value.String "left" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::PairMSM", + "left" + |)); + M.read (| Value.String "right" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::PairMSM", + "right" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_poly_msm_PairMSM_C. + + Module Impl_core_default_Default_where_core_default_Default_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_poly_msm_PairMSM_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::msm::PairMSM") [ C ]. + + (* Default *) + Definition default (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [] => + ltac:(M.monadic + (Value.StructRecord + "halo2_proofs::poly::msm::PairMSM" + [ + ("left", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ], + [], + "default", + [] + |), + [] + |)); + ("right", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ], + [], + "default", + [] + |), + [] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::default::Default" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("default", InstanceField.Method (default C)) ]. + End Impl_core_default_Default_where_core_default_Default_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_poly_msm_PairMSM_C. + + Module Impl_halo2_proofs_poly_msm_PairMSM_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::msm::PairMSM") [ C ]. + + (* + pub fn with(left: MSM, right: MSM) -> Self { + Self { left, right } + } + *) + Definition with_ (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ _ as left; _ as right ] => + ltac:(M.monadic + (let left := M.alloc (| left |) in + let right := M.alloc (| right |) in + Value.StructRecord + "halo2_proofs::poly::msm::PairMSM" + [ ("left", M.read (| left |)); ("right", M.read (| right |)) ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_with_ : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "with_" (with_ C). + + (* + pub fn eval(&self) -> (C, C) { + (self.left.eval(), self.right.eval()) + } + *) + Definition eval (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ], + "eval", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::PairMSM", + "left" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ], + "eval", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::PairMSM", + "right" + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_eval : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "eval" (eval C). + + (* + pub fn scale(&mut self, e: C::Scalar) { + self.left.scale(e); + self.right.scale(e); + } + *) + Definition scale (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; e ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let e := M.alloc (| e |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ], + "scale", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::PairMSM", + "left" + |); + M.read (| e |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ], + "scale", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::PairMSM", + "right" + |); + M.read (| e |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_scale : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "scale" (scale C). + + (* + pub fn add_msm(&mut self, other: Self) { + self.left.add_msm(&other.left); + self.right.add_msm(&other.right); + } + *) + Definition add_msm (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ], + "add_msm", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::PairMSM", + "left" + |); + M.SubPointer.get_struct_record_field (| + other, + "halo2_proofs::poly::msm::PairMSM", + "left" + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ], + "add_msm", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::PairMSM", + "right" + |); + M.SubPointer.get_struct_record_field (| + other, + "halo2_proofs::poly::msm::PairMSM", + "right" + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_add_msm : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "add_msm" (add_msm C). + End Impl_halo2_proofs_poly_msm_PairMSM_C. + + (* StructRecord + { + name := "ProjectiveMSM"; + ty_params := [ "E" ]; + fields := + [ + ("scalars", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]); + ("bases", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_E_where_pairing_bn256_arithmetic_pairing_Engine_E_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_poly_msm_ProjectiveMSM_E. + Definition Self (E : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::msm::ProjectiveMSM") [ E ]. + + (* Debug *) + Definition fmt (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "ProjectiveMSM" |); + M.read (| Value.String "scalars" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::ProjectiveMSM", + "scalars" + |)); + M.read (| Value.String "bases" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::ProjectiveMSM", + "bases" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (E : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self E) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt E)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_E_where_pairing_bn256_arithmetic_pairing_Engine_E_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_poly_msm_ProjectiveMSM_E. + + Module Impl_core_clone_Clone_where_core_clone_Clone_E_where_pairing_bn256_arithmetic_pairing_Engine_E_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_for_halo2_proofs_poly_msm_ProjectiveMSM_E. + Definition Self (E : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::msm::ProjectiveMSM") [ E ]. + + (* Clone *) + Definition clone (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::poly::msm::ProjectiveMSM" + [ + ("scalars", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::ProjectiveMSM", + "scalars" + |) + ] + |)); + ("bases", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::ProjectiveMSM", + "bases" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (E : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self E) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone E)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_E_where_pairing_bn256_arithmetic_pairing_Engine_E_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_for_halo2_proofs_poly_msm_ProjectiveMSM_E. + + Module Impl_halo2_proofs_poly_msm_ProjectiveMSM_E. + Definition Self (E : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::msm::ProjectiveMSM") [ E ]. + + (* + pub fn new() -> Self { + ProjectiveMSM { + scalars: vec![], + bases: vec![], + } + } + *) + Definition new (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [] => + ltac:(M.monadic + (Value.StructRecord + "halo2_proofs::poly::msm::ProjectiveMSM" + [ + ("scalars", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |)); + ("bases", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (E : Ty.t), + M.IsAssociatedFunction (Self E) "new" (new E). + + (* + pub fn append_term(&mut self, scalar: E::Scalar, point: E::G1) { + self.scalars.push(scalar); + self.bases.push(point); + } + *) + Definition append_term (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [ self; scalar; point ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let scalar := M.alloc (| scalar |) in + let point := M.alloc (| point |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::ProjectiveMSM", + "scalars" + |); + M.read (| scalar |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::ProjectiveMSM", + "bases" + |); + M.read (| point |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_append_term : + forall (E : Ty.t), + M.IsAssociatedFunction (Self E) "append_term" (append_term E). + + (* + pub fn scale(&mut self, factor: E::Scalar) { + if !self.scalars.is_empty() { + parallelize(&mut self.scalars, |scalars, _| { + for other_scalar in scalars { + *other_scalar *= &factor; + } + }) + } + } + *) + Definition scale (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [ self; factor ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let factor := M.alloc (| factor |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "is_empty", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::ProjectiveMSM", + "scalars" + |) + ] + |)) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::parallelize", + [ + Ty.associated; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "slice") [ Ty.associated ] ]; + Ty.path "usize" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::ProjectiveMSM", + "scalars" + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let scalars := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "slice") + [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ M.read (| scalars |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let other_scalar := + M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ], + "mul_assign", + [] + |), + [ + M.read (| + other_scalar + |); + factor + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_scale : + forall (E : Ty.t), + M.IsAssociatedFunction (Self E) "scale" (scale E). + + (* + pub fn combine_with_base(&mut self, base: E::Scalar) { + use ff::Field; + let mut acc = E::Scalar::one(); + if !self.scalars.is_empty() { + for scalar in self.scalars.iter_mut().rev() { + *scalar *= &acc; + acc *= base; + } + } + } + *) + Definition combine_with_base (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [ self; base ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let base := M.alloc (| base |) in + M.read (| + let acc := + M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "one", [] |), + [] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "is_empty", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::ProjectiveMSM", + "scalars" + |) + ] + |)) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "rev", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::ProjectiveMSM", + "scalars" + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let scalar := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ Ty.apply (Ty.path "&") [ Ty.associated ] ], + "mul_assign", + [] + |), + [ M.read (| scalar |); acc ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ Ty.associated ], + "mul_assign", + [] + |), + [ acc; M.read (| base |) ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_combine_with_base : + forall (E : Ty.t), + M.IsAssociatedFunction (Self E) "combine_with_base" (combine_with_base E). + End Impl_halo2_proofs_poly_msm_ProjectiveMSM_E. + + (* StructRecord + { + name := "PreMSM"; + ty_params := [ "E" ]; + fields := + [ + ("projectives_msms", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::poly::msm::ProjectiveMSM") [ E ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_E_where_pairing_bn256_arithmetic_pairing_Engine_E_for_halo2_proofs_poly_msm_PreMSM_E. + Definition Self (E : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::msm::PreMSM") [ E ]. + + (* Debug *) + Definition fmt (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "PreMSM" |); + M.read (| Value.String "projectives_msms" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::PreMSM", + "projectives_msms" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (E : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self E) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt E)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_E_where_pairing_bn256_arithmetic_pairing_Engine_E_for_halo2_proofs_poly_msm_PreMSM_E. + + Module Impl_core_clone_Clone_where_core_clone_Clone_E_where_pairing_bn256_arithmetic_pairing_Engine_E_for_halo2_proofs_poly_msm_PreMSM_E. + Definition Self (E : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::msm::PreMSM") [ E ]. + + (* Clone *) + Definition clone (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::poly::msm::PreMSM" + [ + ("projectives_msms", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::poly::msm::ProjectiveMSM") [ E ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::PreMSM", + "projectives_msms" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (E : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self E) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone E)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_E_where_pairing_bn256_arithmetic_pairing_Engine_E_for_halo2_proofs_poly_msm_PreMSM_E. + + Module Impl_halo2_proofs_poly_msm_PreMSM_E. + Definition Self (E : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::msm::PreMSM") [ E ]. + + (* + pub fn new() -> Self { + PreMSM { + projectives_msms: vec![], + } + } + *) + Definition new (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [] => + ltac:(M.monadic + (Value.StructRecord + "halo2_proofs::poly::msm::PreMSM" + [ + ("projectives_msms", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::poly::msm::ProjectiveMSM") [ E ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (E : Ty.t), + M.IsAssociatedFunction (Self E) "new" (new E). + + (* + pub fn normalize(self) -> MSM { + use group::prime::PrimeCurveAffine; + + let bases: Vec = self + .projectives_msms + .iter() + .map(|msm| msm.bases.clone()) + .collect::>>() + .into_iter() + .flatten() + .collect(); + + let scalars: Vec = self + .projectives_msms + .iter() + .map(|msm| msm.scalars.clone()) + .collect::>>() + .into_iter() + .flatten() + .collect(); + + let mut affine_bases = vec![E::G1Affine::identity(); bases.len()]; + E::G1::batch_normalize(&bases[..], &mut affine_bases); + MSM { + scalars, + bases: affine_bases, + } + } + *) + Definition normalize (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let bases := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::flatten::Flatten") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "flatten", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::msm::ProjectiveMSM") + [ E ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::msm::ProjectiveMSM") + [ E ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::msm::ProjectiveMSM") + [ E ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::msm::ProjectiveMSM") + [ E ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::msm::ProjectiveMSM") + [ E ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::msm::ProjectiveMSM") + [ E ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::poly::msm::PreMSM", + "projectives_msms" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let msm := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| msm |), + "halo2_proofs::poly::msm::ProjectiveMSM", + "bases" + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + let scalars := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::flatten::Flatten") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "flatten", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::msm::ProjectiveMSM") + [ E ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::msm::ProjectiveMSM") + [ E ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::msm::ProjectiveMSM") + [ E ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::msm::ProjectiveMSM") + [ E ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::msm::ProjectiveMSM") + [ E ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::msm::ProjectiveMSM") + [ E ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::poly::msm::PreMSM", + "projectives_msms" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let msm := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| msm |), + "halo2_proofs::poly::msm::ProjectiveMSM", + "scalars" + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + let affine_bases := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ Ty.associated ] |), + [ + M.call_closure (| + M.get_trait_method (| + "group::prime::PrimeCurveAffine", + Ty.associated, + [], + "identity", + [] + |), + [] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ bases ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::Curve", + Ty.associated, + [], + "batch_normalize", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index", + [] + |), + [ bases; Value.StructTuple "core::ops::range::RangeFull" [] ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ affine_bases ] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::poly::msm::MSM" + [ ("scalars", M.read (| scalars |)); ("bases", M.read (| affine_bases |)) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_normalize : + forall (E : Ty.t), + M.IsAssociatedFunction (Self E) "normalize" (normalize E). + + (* + pub fn add_msm(&mut self, other: ProjectiveMSM) { + self.projectives_msms.push(other); + } + *) + Definition add_msm (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::poly::msm::ProjectiveMSM") [ E ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::PreMSM", + "projectives_msms" + |); + M.read (| other |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_add_msm : + forall (E : Ty.t), + M.IsAssociatedFunction (Self E) "add_msm" (add_msm E). + + (* + pub fn combine_with_base(&mut self, base: E::Scalar) { + use ff::Field; + let mut acc = E::Scalar::one(); + if !self.projectives_msms.is_empty() { + for msm in self.projectives_msms.iter_mut().rev() { + msm.scale(acc); + acc *= base; + } + } + } + *) + Definition combine_with_base (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [ self; base ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let base := M.alloc (| base |) in + M.read (| + let acc := + M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "one", [] |), + [] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::msm::ProjectiveMSM") + [ E ]; + Ty.path "alloc::alloc::Global" + ], + "is_empty", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::PreMSM", + "projectives_msms" + |) + ] + |)) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::msm::ProjectiveMSM") + [ E ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::msm::ProjectiveMSM") + [ E ] + ], + [], + "rev", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::msm::ProjectiveMSM") + [ E ] + ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::msm::ProjectiveMSM") + [ E ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::msm::PreMSM", + "projectives_msms" + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::rev::Rev") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::msm::ProjectiveMSM") + [ E ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let msm := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::msm::ProjectiveMSM") + [ E ], + "scale", + [] + |), + [ M.read (| msm |); M.read (| acc |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ Ty.associated ], + "mul_assign", + [] + |), + [ acc; M.read (| base |) ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_combine_with_base : + forall (E : Ty.t), + M.IsAssociatedFunction (Self E) "combine_with_base" (combine_with_base E). + End Impl_halo2_proofs_poly_msm_PreMSM_E. + End msm. +End poly. diff --git a/CoqOfRust/halo2_proofs/poly/multiopen.v b/CoqOfRust/halo2_proofs/poly/multiopen.v new file mode 100644 index 000000000..2adc7b2cb --- /dev/null +++ b/CoqOfRust/halo2_proofs/poly/multiopen.v @@ -0,0 +1,1482 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module poly. + Module multiopen. + (* StructRecord + { + name := "Decider"; + ty_params := [ "E" ]; + fields := [ ("_marker", Ty.apply (Ty.path "core::marker::PhantomData") [ E ]) ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_E_where_pairing_bn256_arithmetic_pairing_MultiMillerLoop_E_for_halo2_proofs_poly_multiopen_Decider_E. + Definition Self (E : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::Decider") [ E ]. + + (* Debug *) + Definition fmt (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Decider" |); + M.read (| Value.String "_marker" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::Decider", + "_marker" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (E : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self E) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt E)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_E_where_pairing_bn256_arithmetic_pairing_MultiMillerLoop_E_for_halo2_proofs_poly_multiopen_Decider_E. + + Module Impl_halo2_proofs_poly_multiopen_Decider_E. + Definition Self (E : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::Decider") [ E ]. + + (* + fn prepare(params: &ParamsVerifier) -> (E::G2Prepared, E::G2Prepared) { + let s_g2_prepared = E::G2Prepared::from(params.s_g2); + let n_g2_prepared = E::G2Prepared::from(-params.g2); + (s_g2_prepared, n_g2_prepared) + } + *) + Definition prepare (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [ params ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + M.read (| + let s_g2_prepared := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.associated, + [ Ty.associated ], + "from", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::ParamsVerifier", + "s_g2" + |) + |) + ] + |) + |) in + let n_g2_prepared := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.associated, + [ Ty.associated ], + "from", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Neg", + Ty.associated, + [], + "neg", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::ParamsVerifier", + "g2" + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [ M.read (| s_g2_prepared |); M.read (| n_g2_prepared |) ] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_prepare : + forall (E : Ty.t), + M.IsAssociatedFunction (Self E) "prepare" (prepare E). + + (* + fn pairing_check(terms: &[(&E::G1Affine, &E::G2Prepared); 2]) -> bool { + bool::from( + E::multi_miller_loop(&terms[..]) + .final_exponentiation() + .is_identity(), + ) + } + *) + Definition pairing_check (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [ terms ] => + ltac:(M.monadic + (let terms := M.alloc (| terms |) in + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "bool", + [ Ty.path "subtle::Choice" ], + "from", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "group::Group", Ty.associated, [], "is_identity", [] |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::pairing::MillerLoopResult", + Ty.associated, + [], + "final_exponentiation", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::pairing::MultiMillerLoop", + E, + [], + "multi_miller_loop", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.associated ]; + Ty.apply (Ty.path "&") [ Ty.associated ] + ] + ], + [ Ty.path "core::ops::range::RangeFull" ], + "index", + [] + |), + [ + M.read (| terms |); + Value.StructTuple "core::ops::range::RangeFull" [] + ] + |) + ] + |) + |) + ] + |) + |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_pairing_check : + forall (E : Ty.t), + M.IsAssociatedFunction (Self E) "pairing_check" (pairing_check E). + + (* + pub fn verify(params: &ParamsVerifier, msm: PairMSM) -> bool { + let (s_g2, n_g2) = Self::prepare(params); + let (left, right) = msm.eval(); + let (term_1, term_2) = ((&left, &s_g2), (&right, &n_g2)); + Self::pairing_check(&[term_1, term_2]) + } + *) + Definition verify (E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self E in + match τ, α with + | [], [ params; msm ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let msm := M.alloc (| msm |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::Decider") [ E ], + "prepare", + [] + |), + [ M.read (| params |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let s_g2 := M.copy (| γ0_0 |) in + let n_g2 := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::msm::PairMSM") + [ Ty.associated ], + "eval", + [] + |), + [ msm ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| + Value.Tuple + [ Value.Tuple [ left; s_g2 ]; Value.Tuple [ right; n_g2 ] ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let term_1 := M.copy (| γ0_0 |) in + let term_2 := M.copy (| γ0_1 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::Decider") + [ E ], + "pairing_check", + [] + |), + [ + M.alloc (| + Value.Array + [ M.read (| term_1 |); M.read (| term_2 |) ] + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_verify : + forall (E : Ty.t), + M.IsAssociatedFunction (Self E) "verify" (verify E). + End Impl_halo2_proofs_poly_multiopen_Decider_E. + + (* StructRecord + { + name := "ProverQuery"; + ty_params := [ "C" ]; + fields := + [ + ("point", Ty.associated); + ("rotation", Ty.path "halo2_proofs::poly::Rotation"); + ("poly", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_poly_multiopen_ProverQuery_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "ProverQuery" |); + M.read (| Value.String "point" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::ProverQuery", + "point" + |)); + M.read (| Value.String "rotation" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::ProverQuery", + "rotation" + |)); + M.read (| Value.String "poly" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::ProverQuery", + "poly" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_poly_multiopen_ProverQuery_C. + + Module Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_for_halo2_proofs_poly_multiopen_ProverQuery_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") [ C ]. + + (* Clone *) + Definition clone (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::poly::multiopen::ProverQuery" + [ + ("point", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.associated, [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::ProverQuery", + "point" + |) + ] + |)); + ("rotation", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::poly::Rotation", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::ProverQuery", + "rotation" + |) + ] + |)); + ("poly", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::ProverQuery", + "poly" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone C)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_for_halo2_proofs_poly_multiopen_ProverQuery_C. + + Module Impl_core_marker_Copy_where_core_marker_Copy_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_marker_Copy_associated_type_where_core_marker_Copy_associated_type_for_halo2_proofs_poly_multiopen_ProverQuery_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") [ C ]. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_marker_Copy_associated_type_where_core_marker_Copy_associated_type_for_halo2_proofs_poly_multiopen_ProverQuery_C. + + (* StructRecord + { + name := "VerifierQuery"; + ty_params := [ "C" ]; + fields := + [ + ("point", Ty.associated); + ("rotation", Ty.path "halo2_proofs::poly::Rotation"); + ("commitment", + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::CommitmentReference") [ C ]); + ("eval", Ty.associated) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_poly_multiopen_VerifierQuery_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field4_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "VerifierQuery" |); + M.read (| Value.String "point" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::VerifierQuery", + "point" + |)); + M.read (| Value.String "rotation" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::VerifierQuery", + "rotation" + |)); + M.read (| Value.String "commitment" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::VerifierQuery", + "commitment" + |)); + M.read (| Value.String "eval" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::VerifierQuery", + "eval" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_where_core_fmt_Debug_associated_type_for_halo2_proofs_poly_multiopen_VerifierQuery_C. + + Module Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_for_halo2_proofs_poly_multiopen_VerifierQuery_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") [ C ]. + + (* Clone *) + Definition clone (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::poly::multiopen::VerifierQuery" + [ + ("point", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.associated, [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::VerifierQuery", + "point" + |) + ] + |)); + ("rotation", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::poly::Rotation", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::VerifierQuery", + "rotation" + |) + ] + |)); + ("commitment", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::CommitmentReference") [ C ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::VerifierQuery", + "commitment" + |) + ] + |)); + ("eval", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.associated, [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::VerifierQuery", + "eval" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone C)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_clone_Clone_associated_type_where_core_clone_Clone_associated_type_for_halo2_proofs_poly_multiopen_VerifierQuery_C. + + Module Impl_core_marker_Copy_where_core_marker_Copy_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_marker_Copy_associated_type_where_core_marker_Copy_associated_type_for_halo2_proofs_poly_multiopen_VerifierQuery_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") [ C ]. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_marker_Copy_associated_type_where_core_marker_Copy_associated_type_for_halo2_proofs_poly_multiopen_VerifierQuery_C. + + Module Impl_halo2_proofs_poly_multiopen_VerifierQuery_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") [ C ]. + + (* + pub fn new_commitment( + commitment: &'r C, + point: C::Scalar, + rotation: Rotation, + eval: C::Scalar, + ) -> Self { + VerifierQuery { + point, + rotation, + eval, + commitment: CommitmentReference::Commitment(commitment), + } + } + *) + Definition new_commitment (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ commitment; point; rotation; eval ] => + ltac:(M.monadic + (let commitment := M.alloc (| commitment |) in + let point := M.alloc (| point |) in + let rotation := M.alloc (| rotation |) in + let eval := M.alloc (| eval |) in + Value.StructRecord + "halo2_proofs::poly::multiopen::VerifierQuery" + [ + ("point", M.read (| point |)); + ("rotation", M.read (| rotation |)); + ("eval", M.read (| eval |)); + ("commitment", + Value.StructTuple + "halo2_proofs::poly::multiopen::CommitmentReference::Commitment" + [ M.read (| commitment |) ]) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new_commitment : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "new_commitment" (new_commitment C). + + (* + pub fn new_msm(msm: &'r MSM, point: C::Scalar, rotation: Rotation, eval: C::Scalar) -> Self { + VerifierQuery { + point, + rotation, + eval, + commitment: CommitmentReference::MSM(msm), + } + } + *) + Definition new_msm (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ msm; point; rotation; eval ] => + ltac:(M.monadic + (let msm := M.alloc (| msm |) in + let point := M.alloc (| point |) in + let rotation := M.alloc (| rotation |) in + let eval := M.alloc (| eval |) in + Value.StructRecord + "halo2_proofs::poly::multiopen::VerifierQuery" + [ + ("point", M.read (| point |)); + ("rotation", M.read (| rotation |)); + ("eval", M.read (| eval |)); + ("commitment", + Value.StructTuple + "halo2_proofs::poly::multiopen::CommitmentReference::MSM" + [ M.read (| msm |) ]) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new_msm : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "new_msm" (new_msm C). + End Impl_halo2_proofs_poly_multiopen_VerifierQuery_C. + + (* + Enum CommitmentReference + { + ty_params := [ "C" ]; + variants := + [ + { + name := "Commitment"; + item := StructTuple [ Ty.apply (Ty.path "&") [ C ] ]; + discriminant := None; + }; + { + name := "MSM"; + item := + StructTuple + [ Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ] ] + ]; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_marker_Copy_where_core_marker_Copy_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_poly_multiopen_CommitmentReference_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::CommitmentReference") [ C ]. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_poly_multiopen_CommitmentReference_C. + + Module Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_poly_multiopen_CommitmentReference_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::CommitmentReference") [ C ]. + + (* Clone *) + Definition clone (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::poly::multiopen::CommitmentReference::Commitment", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::poly::multiopen::CommitmentReference::Commitment" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "&") [ C ], + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::poly::multiopen::CommitmentReference::MSM", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::poly::multiopen::CommitmentReference::MSM" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ] ], + [], + "clone", + [] + |), + [ M.read (| __self_0 |) ] + |) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone C)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_poly_multiopen_CommitmentReference_C. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_poly_multiopen_CommitmentReference_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::CommitmentReference") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::poly::multiopen::CommitmentReference::Commitment", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Commitment" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::poly::multiopen::CommitmentReference::MSM", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "MSM" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_poly_multiopen_CommitmentReference_C. + + Module Impl_core_cmp_PartialEq_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_poly_multiopen_CommitmentReference_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::CommitmentReference") [ C ]. + + (* + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (&CommitmentReference::Commitment(a), &CommitmentReference::Commitment(b)) => { + std::ptr::eq(a, b) + } + (&CommitmentReference::MSM(a), &CommitmentReference::MSM(b)) => std::ptr::eq(a, b), + _ => false, + } + } + *) + Definition eq (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| other |) ] |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::poly::multiopen::CommitmentReference::Commitment", + 0 + |) in + let a := M.copy (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::poly::multiopen::CommitmentReference::Commitment", + 0 + |) in + let b := M.copy (| γ2_0 |) in + M.alloc (| + M.call_closure (| + M.get_function (| "core::ptr::eq", [ C ] |), + [ M.read (| a |); M.read (| b |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "halo2_proofs::poly::multiopen::CommitmentReference::MSM", + 0 + |) in + let a := M.copy (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "halo2_proofs::poly::multiopen::CommitmentReference::MSM", + 0 + |) in + let b := M.copy (| γ2_0 |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::ptr::eq", + [ Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ C ] ] + |), + [ M.read (| a |); M.read (| b |) ] + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Bool false |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::cmp::PartialEq" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method (eq C)) ]. + End Impl_core_cmp_PartialEq_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_poly_multiopen_CommitmentReference_C. + + (* Trait *) + (* Empty module 'Query' *) + + (* StructRecord + { + name := "PolynomialPointer"; + ty_params := [ "C" ]; + fields := + [ + ("poly", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ]) + ]; + } *) + + Module Impl_core_marker_Copy_where_core_marker_Copy_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_marker_Copy_associated_type_for_halo2_proofs_poly_multiopen_PolynomialPointer_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::PolynomialPointer") [ C ]. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_marker_Copy_associated_type_for_halo2_proofs_poly_multiopen_PolynomialPointer_C. + + Module Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_clone_Clone_associated_type_for_halo2_proofs_poly_multiopen_PolynomialPointer_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::PolynomialPointer") [ C ]. + + (* Clone *) + Definition clone (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::poly::multiopen::PolynomialPointer" + [ + ("poly", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::PolynomialPointer", + "poly" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone C)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_clone_Clone_associated_type_for_halo2_proofs_poly_multiopen_PolynomialPointer_C. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_for_halo2_proofs_poly_multiopen_PolynomialPointer_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::PolynomialPointer") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "PolynomialPointer" |); + M.read (| Value.String "poly" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::PolynomialPointer", + "poly" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_associated_type_for_halo2_proofs_poly_multiopen_PolynomialPointer_C. + + Module Impl_core_cmp_PartialEq_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_poly_multiopen_PolynomialPointer_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::PolynomialPointer") [ C ]. + + (* + fn eq(&self, other: &Self) -> bool { + std::ptr::eq(self.poly, other.poly) + } + *) + Definition eq (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.call_closure (| + M.get_function (| + "core::ptr::eq", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::PolynomialPointer", + "poly" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::multiopen::PolynomialPointer", + "poly" + |) + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::cmp::PartialEq" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method (eq C)) ]. + End Impl_core_cmp_PartialEq_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_poly_multiopen_PolynomialPointer_C. + + Module Impl_halo2_proofs_poly_multiopen_Query_where_pairing_bn256_arithmetic_curves_CurveAffine_C_associated_type_for_halo2_proofs_poly_multiopen_ProverQuery_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") [ C ]. + + (* type Commitment = PolynomialPointer<'a, C>; *) + Definition _Commitment (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::PolynomialPointer") [ C ]. + + (* + fn get_point(&self) -> C::Scalar { + self.point + } + *) + Definition get_point (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::ProverQuery", + "point" + |) + |))) + | _, _ => M.impossible + end. + + (* + fn get_rotation(&self) -> Rotation { + self.rotation + } + *) + Definition get_rotation (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::ProverQuery", + "rotation" + |) + |))) + | _, _ => M.impossible + end. + + (* + fn get_eval(&self) -> C::Scalar { + eval_polynomial(self.poly, self.get_point()) + } + *) + Definition get_eval (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_function (| "halo2_proofs::arithmetic::eval_polynomial", [ Ty.associated ] |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ], + [], + "deref", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::ProverQuery", + "poly" + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::poly::multiopen::Query", + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") [ C ], + [ Ty.associated ], + "get_point", + [] + |), + [ M.read (| self |) ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn get_commitment(&self) -> Self::Commitment { + PolynomialPointer { poly: self.poly } + } + *) + Definition get_commitment (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::poly::multiopen::PolynomialPointer" + [ + ("poly", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::ProverQuery", + "poly" + |) + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "halo2_proofs::poly::multiopen::Query" + (Self C) + (* Trait polymorphic types *) [ (* F *) Ty.associated ] + (* Instance *) + [ + ("Commitment", InstanceField.Ty (_Commitment C)); + ("get_point", InstanceField.Method (get_point C)); + ("get_rotation", InstanceField.Method (get_rotation C)); + ("get_eval", InstanceField.Method (get_eval C)); + ("get_commitment", InstanceField.Method (get_commitment C)) + ]. + End Impl_halo2_proofs_poly_multiopen_Query_where_pairing_bn256_arithmetic_curves_CurveAffine_C_associated_type_for_halo2_proofs_poly_multiopen_ProverQuery_C. + + Module Impl_halo2_proofs_poly_multiopen_Query_where_pairing_bn256_arithmetic_curves_CurveAffine_C_associated_type_for_halo2_proofs_poly_multiopen_VerifierQuery_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") [ C ]. + + (* type Commitment = CommitmentReference<'a, C>; *) + Definition _Commitment (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::CommitmentReference") [ C ]. + + (* + fn get_point(&self) -> C::Scalar { + self.point + } + *) + Definition get_point (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::VerifierQuery", + "point" + |) + |))) + | _, _ => M.impossible + end. + + (* + fn get_rotation(&self) -> Rotation { + self.rotation + } + *) + Definition get_rotation (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::VerifierQuery", + "rotation" + |) + |))) + | _, _ => M.impossible + end. + + (* + fn get_eval(&self) -> C::Scalar { + self.eval + } + *) + Definition get_eval (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::VerifierQuery", + "eval" + |) + |))) + | _, _ => M.impossible + end. + + (* + fn get_commitment(&self) -> Self::Commitment { + self.commitment + } + *) + Definition get_commitment (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::VerifierQuery", + "commitment" + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "halo2_proofs::poly::multiopen::Query" + (Self C) + (* Trait polymorphic types *) [ (* F *) Ty.associated ] + (* Instance *) + [ + ("Commitment", InstanceField.Ty (_Commitment C)); + ("get_point", InstanceField.Method (get_point C)); + ("get_rotation", InstanceField.Method (get_rotation C)); + ("get_eval", InstanceField.Method (get_eval C)); + ("get_commitment", InstanceField.Method (get_commitment C)) + ]. + End Impl_halo2_proofs_poly_multiopen_Query_where_pairing_bn256_arithmetic_curves_CurveAffine_C_associated_type_for_halo2_proofs_poly_multiopen_VerifierQuery_C. + End multiopen. +End poly. diff --git a/CoqOfRust/halo2_proofs/poly/multiopen/gwc.v b/CoqOfRust/halo2_proofs/poly/multiopen/gwc.v new file mode 100644 index 000000000..387f3f55b --- /dev/null +++ b/CoqOfRust/halo2_proofs/poly/multiopen/gwc.v @@ -0,0 +1,568 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module poly. + Module multiopen. + Module gwc. + (* StructTuple + { + name := "U"; + ty_params := []; + fields := []; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_poly_multiopen_gwc_U. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::multiopen::gwc::U". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| M.read (| self |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_poly_multiopen_gwc_U. + + Module Impl_core_marker_Copy_for_halo2_proofs_poly_multiopen_gwc_U. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::multiopen::gwc::U". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_poly_multiopen_gwc_U. + + Module Impl_core_fmt_Debug_for_halo2_proofs_poly_multiopen_gwc_U. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::multiopen::gwc::U". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ M.read (| f |); M.read (| Value.String "U" |) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_poly_multiopen_gwc_U. + + Axiom ChallengeU : + forall (F : Ty.t), + (Ty.apply (Ty.path "halo2_proofs::poly::multiopen::gwc::ChallengeU") [ F ]) = + (Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ F; Ty.path "halo2_proofs::poly::multiopen::gwc::U" ]). + + (* StructTuple + { + name := "V"; + ty_params := []; + fields := []; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_poly_multiopen_gwc_V. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::multiopen::gwc::V". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| M.read (| self |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_poly_multiopen_gwc_V. + + Module Impl_core_marker_Copy_for_halo2_proofs_poly_multiopen_gwc_V. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::multiopen::gwc::V". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_poly_multiopen_gwc_V. + + Module Impl_core_fmt_Debug_for_halo2_proofs_poly_multiopen_gwc_V. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::multiopen::gwc::V". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ M.read (| f |); M.read (| Value.String "V" |) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_poly_multiopen_gwc_V. + + Axiom ChallengeV : + forall (F : Ty.t), + (Ty.apply (Ty.path "halo2_proofs::poly::multiopen::gwc::ChallengeV") [ F ]) = + (Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ F; Ty.path "halo2_proofs::poly::multiopen::gwc::V" ]). + + (* StructRecord + { + name := "CommitmentData"; + ty_params := [ "F"; "Q" ]; + fields := + [ + ("queries", + Ty.apply (Ty.path "alloc::vec::Vec") [ Q; Ty.path "alloc::alloc::Global" ]); + ("point", F); + ("_marker", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + (* + fn construct_intermediate_sets>(queries: I) -> Vec> + where + I: IntoIterator, + { + let mut point_query_map: BTreeMap> = BTreeMap::new(); + for query in queries { + if let Some(queries) = point_query_map.get_mut(&query.get_rotation()) { + queries.push(query); + } else { + point_query_map.insert(query.get_rotation(), vec![query]); + } + } + + point_query_map + .into_iter() + .map(|(_, queries)| { + let point = queries[0].get_point(); + CommitmentData { + queries, + point, + _marker: PhantomData, + } + }) + .collect() + } + *) + Definition construct_intermediate_sets (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F; _ as I; Q ], [ queries ] => + ltac:(M.monadic + (let queries := M.alloc (| queries |) in + M.read (| + let point_query_map := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Q; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + I, + [], + "into_iter", + [] + |), + [ M.read (| queries |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.associated, + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let query := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Q; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + "get_mut", + [ Ty.path "halo2_proofs::poly::Rotation" ] + |), + [ + point_query_map; + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::poly::multiopen::Query", + Q, + [ F ], + "get_rotation", + [] + |), + [ query ] + |) + |) + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let queries := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Q; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ M.read (| queries |); M.read (| query |) ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Q; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + point_query_map; + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::poly::multiopen::Query", + Q, + [ F ], + "get_rotation", + [] + |), + [ query ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Q ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Q ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ M.read (| query |) ] + |) + ] + |) + |)) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::IntoIter") + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Q; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Q; Ty.path "alloc::alloc::Global" ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ F; Q ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ F; Q ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::IntoIter") + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Q; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ F; Q ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Q; Ty.path "alloc::alloc::Global" ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ F; Q ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Q; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| point_query_map |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let queries := M.copy (| γ0_1 |) in + M.read (| + let point := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::poly::multiopen::Query", + Q, + [ F ], + "get_point", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Q; Ty.path "alloc::alloc::Global" ], + [ Ty.path "usize" ], + "index", + [] + |), + [ queries; Value.Integer 0 ] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::poly::multiopen::gwc::CommitmentData" + [ + ("queries", M.read (| queries |)); + ("point", M.read (| point |)); + ("_marker", + Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + End gwc. + End multiopen. +End poly. diff --git a/CoqOfRust/halo2_proofs/poly/multiopen/gwc/prover.v b/CoqOfRust/halo2_proofs/poly/multiopen/gwc/prover.v new file mode 100644 index 000000000..fbd18d901 --- /dev/null +++ b/CoqOfRust/halo2_proofs/poly/multiopen/gwc/prover.v @@ -0,0 +1,1587 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module poly. + Module multiopen. + Module gwc. + Module prover. + (* + pub fn create_proof<'a, I, C: CurveAffine, E: EncodedChallenge, T: TranscriptWrite>( + params: &Params, + transcript: &mut T, + queries: I, + ) -> io::Result<()> + where + I: IntoIterator>, + { + let v: ChallengeV<_> = transcript.squeeze_challenge_scalar(); + let commitment_data = construct_intermediate_sets(queries); + + let zero = || Polynomial:: { + values: vec![C::Scalar::zero(); params.n as usize], + _marker: PhantomData, + }; + + let mut commitment_data = commitment_data.into_iter().enumerate().collect::>(); + commitment_data.sort_by(|a, b| a.1.queries.len().cmp(&b.1.queries.len())); + + // Sort by len to compute large batch first + let mut ws = commitment_data + .par_iter() + .rev() + .map(|(idx, commitment_at_a_point)| { + let z = commitment_at_a_point.point; + + #[cfg(not(feature = "cuda"))] + let poly_batch = { + let mut poly_batch = zero(); + for query in commitment_at_a_point.queries.iter() { + assert_eq!(query.get_point(), z); + + let poly = query.get_commitment().poly; + poly_batch = poly_batch * *v + poly; + } + poly_batch + }; + + #[cfg(feature = "cuda")] + let poly_batch = { + if commitment_at_a_point.queries.len() <= 4 { + let mut poly_batch = zero(); + for query in commitment_at_a_point.queries.iter() { + assert_eq!(query.get_point(), z); + + let poly = query.get_commitment().poly; + poly_batch = poly_batch * *v + poly; + } + poly_batch + } else { + use crate::arithmetic::acquire_gpu; + use crate::arithmetic::release_gpu; + use crate::plonk::{GPU_COND_VAR, GPU_LOCK}; + use ec_gpu_gen::rust_gpu_tools::program_closures; + use ec_gpu_gen::{ + fft::FftKernel, multiexp::SingleMultiexpKernel, rust_gpu_tools::Device, + threadpool::Worker, + }; + use group::Curve; + use pairing::bn256::Fr; + + let mut poly_batch = zero(); + + let gpu_idx = acquire_gpu(); + let closures = + program_closures!(|program, + input: &mut [C::ScalarExt]| + -> ec_gpu_gen::EcResult<()> { + let size = params.n as usize; + let local_work_size = 128; + let global_work_size = size / local_work_size; + let vl = vec![*v]; + let v_buffer = program.create_buffer_from_slice(&vl[..])?; + let mut it = commitment_at_a_point.queries.iter(); + let mut tmp_buffer = unsafe { program.create_buffer(size)? }; + let query = it.next().unwrap(); + let res_buffer = program.create_buffer_from_slice( + &query.get_commitment().poly.values[..], + )?; + for query in it { + let kernel_name = format!("{}_eval_mul_c", "Bn256_Fr"); + let kernel = program.create_kernel( + &kernel_name, + global_work_size as usize, + local_work_size as usize, + )?; + kernel + .arg(&res_buffer) + .arg(&res_buffer) + .arg(&0) + .arg(&v_buffer) + .arg(&(size as u32)) + .run()?; + + program.write_from_buffer( + &mut tmp_buffer, + &query.get_commitment().poly.values[..], + )?; + + let kernel_name = format!("{}_eval_sum", "Bn256_Fr"); + let kernel = program.create_kernel( + &kernel_name, + global_work_size as usize, + local_work_size as usize, + )?; + kernel + .arg(&res_buffer) + .arg(&res_buffer) + .arg(&tmp_buffer) + .arg(&0) + .arg(&0) + .arg(&(size as u32)) + .run()?; + } + program.read_into_buffer(&res_buffer, input)?; + Ok(()) + }); + + let devices = Device::all(); + let device = devices[gpu_idx % devices.len()]; + let program = ec_gpu_gen::program!(device).unwrap(); + program + .run(closures, unsafe { + std::mem::transmute::<_, &mut [C::ScalarExt]>( + &mut poly_batch.values[..], + ) + }) + .unwrap(); + + release_gpu(gpu_idx); + poly_batch + } + }; + + let eval_batch = + eval_polynomial_st(&poly_batch, commitment_at_a_point.queries[0].get_point()); + + let poly_batch = &poly_batch - eval_batch; + let witness_poly = Polynomial { + values: kate_division(&poly_batch.values, z), + _marker: PhantomData, + }; + + (idx, params.commit(&witness_poly).to_affine()) + }) + .collect::>(); + + ws.sort_by(|a, b| a.0.cmp(&b.0)); + + for w in ws { + transcript.write_point(w.1)?; + } + + Ok(()) + } + *) + Definition create_proof (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ _ as I; C; E; T ], [ params; transcript; queries ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let transcript := M.alloc (| transcript |) in + let queries := M.alloc (| queries |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let v := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ C; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::poly::multiopen::gwc::V" ] + |), + [ M.read (| transcript |) ] + |) + |) in + let commitment_data := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::poly::multiopen::gwc::construct_intermediate_sets", + [ + Ty.associated; + I; + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") [ C ] + ] + |), + [ M.read (| queries |) ] + |) + |) in + let zero := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "zero", + [] + |), + [] + |); + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)) + ] + |)); + ("_marker", + Value.StructTuple "core::marker::PhantomData" []) + ])) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let commitment_data := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ + Ty.associated; + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ + Ty.associated; + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ + Ty.associated; + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ + Ty.associated; + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| commitment_data |) ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ + Ty.associated; + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ] + ], + "sort_by", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ] + ] + ] + ] + (Ty.path "core::cmp::Ordering") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ + Ty.associated; + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ commitment_data ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let b := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path "usize", + [], + "cmp", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_tuple_field (| + M.read (| a |), + 1 + |), + "halo2_proofs::poly::multiopen::gwc::CommitmentData", + "queries" + |) + ] + |) + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_tuple_field (| + M.read (| b |), + 1 + |), + "halo2_proofs::poly::multiopen::gwc::CommitmentData", + "queries" + |) + ] + |) + |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let ws := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::map::Map") + [ + Ty.apply + (Ty.path "rayon::iter::rev::Rev") + [ + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ] + ] + ] + ] + (Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "usize" ]; C ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "usize" ]; C ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::rev::Rev") + [ + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ] + ] + ], + [], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ] + ] + ] + ] + (Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "usize" ]; C ]); + Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "usize" ]; C ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IndexedParallelIterator", + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ] + ], + [], + "rev", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelRefIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "par_iter", + [] + |), + [ commitment_data ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let idx := M.alloc (| γ1_0 |) in + let commitment_at_a_point := M.alloc (| γ1_1 |) in + M.read (| + let z := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| commitment_at_a_point |), + "halo2_proofs::poly::multiopen::gwc::CommitmentData", + "point" + |) + |) in + let poly_batch := + M.copy (| + let poly_batch := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]), + [ Ty.tuple [] ], + "call", + [] + |), + [ zero; Value.Tuple [] ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + commitment_at_a_point + |), + "halo2_proofs::poly::multiopen::gwc::CommitmentData", + "queries" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let query := + M.copy (| + γ0_0 + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::poly::multiopen::Query", + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ + C + ], + [ + Ty.associated + ], + "get_point", + [] + |), + [ + M.read (| + query + |) + ] + |) + |); + z + ] + |), + [ + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + left_val := + M.copy (| + γ0_0 + |) in + let + right_val := + M.copy (| + γ0_1 + |) in + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ + Ty.associated + ], + "eq", + [] + |), + [ + M.read (| + left_val + |); + M.read (| + right_val + |) + ] + |)) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let + kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ + Ty.associated; + Ty.associated + ] + |), + [ + M.read (| + kind + |); + M.read (| + left_val + |); + M.read (| + right_val + |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple + [] + |))) + ] + |))) + ] + |) in + let poly := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::poly::multiopen::Query", + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ], + [ + Ty.associated + ], + "get_commitment", + [] + |), + [ + M.read (| + query + |) + ] + |) + |), + "halo2_proofs::poly::multiopen::PolynomialPointer", + "poly" + |) + |) in + let _ := + M.write (| + poly_batch, + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + poly_batch + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::poly::multiopen::gwc::V" + ], + [], + "deref", + [] + |), + [ v + ] + |) + |) + ] + |); + M.read (| + poly + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + poly_batch + |) in + let eval_batch := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::eval_polynomial_st", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [], + "deref", + [] + |), + [ poly_batch ] + |); + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::poly::multiopen::Query", + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ], + [ Ty.associated ], + "get_point", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::ProverQuery") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + commitment_at_a_point + |), + "halo2_proofs::poly::multiopen::gwc::CommitmentData", + "queries" + |); + Value.Integer 0 + ] + |) + ] + |) + ] + |) + |) in + let poly_batch := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ], + [ Ty.associated ], + "sub", + [] + |), + [ poly_batch; M.read (| eval_batch |) ] + |) + |) in + let witness_poly := + M.alloc (| + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::kate_division", + [ + Ty.associated; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.SubPointer.get_struct_record_field (| + poly_batch, + "halo2_proofs::poly::Polynomial", + "values" + |); + M.read (| z |) + ] + |)); + ("_marker", + Value.StructTuple + "core::marker::PhantomData" + []) + ] + |) in + M.alloc (| + Value.Tuple + [ + M.read (| idx |); + M.call_closure (| + M.get_trait_method (| + "group::Curve", + Ty.associated, + [], + "to_affine", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::Params") + [ C ], + "commit", + [] + |), + [ M.read (| params |); witness_poly + ] + |) + |) + ] + |) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "usize" ]; C ] ], + "sort_by", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "usize" ]; C ] + ]; + Ty.apply + (Ty.path "&") + [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "usize" ]; C ] + ] + ] + ] + (Ty.path "core::cmp::Ordering") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "usize" ]; C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ ws ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let a := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let b := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path "usize", + [], + "cmp", + [] + |), + [ + M.read (| + M.SubPointer.get_tuple_field (| + M.read (| a |), + 0 + |) + |); + M.read (| + M.SubPointer.get_tuple_field (| + M.read (| b |), + 0 + |) + |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "usize" ]; C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| ws |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ Ty.apply (Ty.path "&") [ Ty.path "usize" ]; C + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let w := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ C; E ], + "write_point", + [] + |), + [ + M.read (| transcript |); + M.read (| + M.SubPointer.get_tuple_field (| + w, + 1 + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + End prover. + End gwc. + End multiopen. +End poly. diff --git a/CoqOfRust/halo2_proofs/poly/multiopen/gwc/verifier.v b/CoqOfRust/halo2_proofs/poly/multiopen/gwc/verifier.v new file mode 100644 index 000000000..b7cbf8f04 --- /dev/null +++ b/CoqOfRust/halo2_proofs/poly/multiopen/gwc/verifier.v @@ -0,0 +1,1332 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module poly. + Module multiopen. + Module gwc. + Module verifier. + (* + pub fn verify_proof< + 'r, + 'params: 'r, + I, + C: MultiMillerLoop, + E: EncodedChallenge, + T: TranscriptRead, + >( + params: &'params ParamsVerifier, + transcript: &mut T, + queries: I, + ) -> Result, Error> + where + I: IntoIterator> + Clone, + { + let v: ChallengeV<_> = transcript.squeeze_challenge_scalar(); + let u: ChallengeU<_> = transcript.squeeze_challenge_scalar(); + + let commitment_data = construct_intermediate_sets(queries); + + let mut commitment_multi = params.empty_msm(); + let mut eval_multi = C::Scalar::zero(); + + let mut witness = params.empty_msm(); + let mut witness_with_aux = params.empty_msm(); + + for commitment_at_a_point in commitment_data.iter() { + assert!(!commitment_at_a_point.queries.is_empty()); + let z = commitment_at_a_point.point; + + let wi = transcript.read_point().map_err(|_| Error::SamplingError)?; + + witness_with_aux.scale( *u); + witness_with_aux.append_term(z, wi); + witness.scale( *u); + witness.append_term(C::Scalar::one(), wi); + commitment_multi.scale( *u); + eval_multi = eval_multi * *u; + + let mut commitment_batch = params.empty_msm(); + let mut eval_batch = C::Scalar::zero(); + + for query in commitment_at_a_point.queries.iter() { + assert_eq!(query.get_point(), z); + + let commitment = query.get_commitment(); + let eval = query.get_eval(); + + commitment_batch.scale( *v); + match commitment { + CommitmentReference::Commitment(c) => { + commitment_batch.append_term(C::Scalar::one(), *c); + } + CommitmentReference::MSM(msm) => { + commitment_batch.add_msm(msm); + } + } + + eval_batch = eval_batch * *v + eval; + } + + commitment_multi.add_msm(&commitment_batch); + eval_multi += eval_batch; + } + + let mut left = params.empty_msm(); + left.add_msm(&witness); + + let mut right = params.empty_msm(); + right.add_msm(&witness_with_aux); + right.add_msm(&commitment_multi); + right.append_term(eval_multi, -params.g1); + + Ok(PairMSM::with(left, right)) + } + *) + Definition verify_proof (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ _ as I; C; E; T ], [ params; transcript; queries ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let transcript := M.alloc (| transcript |) in + let queries := M.alloc (| queries |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let v := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ Ty.associated; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::poly::multiopen::gwc::V" ] + |), + [ M.read (| transcript |) ] + |) + |) in + let u := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ Ty.associated; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::poly::multiopen::gwc::U" ] + |), + [ M.read (| transcript |) ] + |) + |) in + let commitment_data := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::poly::multiopen::gwc::construct_intermediate_sets", + [ + Ty.associated; + I; + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ] + |), + [ M.read (| queries |) ] + |) + |) in + let commitment_multi := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::commitment::ParamsVerifier") + [ C ], + "empty_msm", + [] + |), + [ M.read (| params |) ] + |) + |) in + let eval_multi := + M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "zero", [] |), + [] + |) + |) in + let witness := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::commitment::ParamsVerifier") + [ C ], + "empty_msm", + [] + |), + [ M.read (| params |) ] + |) + |) in + let witness_with_aux := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::commitment::ParamsVerifier") + [ C ], + "empty_msm", + [] + |), + [ M.read (| params |) ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ + Ty.associated; + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ commitment_data ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::gwc::CommitmentData") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let commitment_at_a_point := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]; + Ty.path + "alloc::alloc::Global" + ], + "is_empty", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + commitment_at_a_point + |), + "halo2_proofs::poly::multiopen::gwc::CommitmentData", + "queries" + |) + ] + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic", + [] + |), + [ + M.read (| + Value.String + "assertion failed: !commitment_at_a_point.queries.is_empty()" + |) + ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |) in + let z := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| commitment_at_a_point |), + "halo2_proofs::poly::multiopen::gwc::CommitmentData", + "point" + |) + |) in + let wi := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.associated; + Ty.path "std::io::error::Error" + ], + "map_err", + [ + Ty.path "halo2_proofs::poly::Error"; + Ty.function + [ + Ty.tuple + [ + Ty.path + "std::io::error::Error" + ] + ] + (Ty.path + "halo2_proofs::poly::Error") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptRead", + T, + [ Ty.associated; E ], + "read_point", + [] + |), + [ M.read (| transcript |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::poly::Error::SamplingError" + [])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::msm::PairMSM") + [ Ty.associated ]; + Ty.path + "halo2_proofs::poly::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::poly::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::msm::MSM") + [ Ty.associated ], + "scale", + [] + |), + [ + witness_with_aux; + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::multiopen::gwc::U" + ], + [], + "deref", + [] + |), + [ u ] + |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::msm::MSM") + [ Ty.associated ], + "append_term", + [] + |), + [ + witness_with_aux; + M.read (| z |); + M.read (| wi |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::msm::MSM") + [ Ty.associated ], + "scale", + [] + |), + [ + witness; + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::multiopen::gwc::U" + ], + [], + "deref", + [] + |), + [ u ] + |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::msm::MSM") + [ Ty.associated ], + "append_term", + [] + |), + [ + witness; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |); + M.read (| wi |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::msm::MSM") + [ Ty.associated ], + "scale", + [] + |), + [ + commitment_multi; + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::multiopen::gwc::U" + ], + [], + "deref", + [] + |), + [ u ] + |) + |) + ] + |) + |) in + let _ := + M.write (| + eval_multi, + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.associated ], + "mul", + [] + |), + [ + M.read (| eval_multi |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::multiopen::gwc::U" + ], + [], + "deref", + [] + |), + [ u ] + |) + |) + ] + |) + |) in + let commitment_batch := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::ParamsVerifier") + [ C ], + "empty_msm", + [] + |), + [ M.read (| params |) ] + |) + |) in + let eval_batch := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "zero", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + commitment_at_a_point + |), + "halo2_proofs::poly::multiopen::gwc::CommitmentData", + "queries" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let query := + M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::poly::multiopen::Query", + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ + Ty.associated + ], + [ + Ty.associated + ], + "get_point", + [] + |), + [ + M.read (| + query + |) + ] + |) + |); + z + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let left_val := + M.copy (| + γ0_0 + |) in + let right_val := + M.copy (| + γ0_1 + |) in + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ + Ty.associated + ], + "eq", + [] + |), + [ + M.read (| + left_val + |); + M.read (| + right_val + |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let + kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ + Ty.associated; + Ty.associated + ] + |), + [ + M.read (| + kind + |); + M.read (| + left_val + |); + M.read (| + right_val + |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple + [] + |))) + ] + |))) + ] + |) in + let commitment := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::poly::multiopen::Query", + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ], + [ Ty.associated ], + "get_commitment", + [] + |), + [ M.read (| query |) ] + |) + |) in + let eval := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::poly::multiopen::Query", + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ], + [ Ty.associated ], + "get_eval", + [] + |), + [ M.read (| query |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::msm::MSM") + [ Ty.associated ], + "scale", + [] + |), + [ + commitment_batch; + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::multiopen::gwc::V" + ], + [], + "deref", + [] + |), + [ v ] + |) + |) + ] + |) + |) in + let _ := + M.match_operator (| + commitment, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::poly::multiopen::CommitmentReference::Commitment", + 0 + |) in + let c := + M.copy (| + γ0_0 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::msm::MSM") + [ + Ty.associated + ], + "append_term", + [] + |), + [ + commitment_batch; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |); + M.read (| + M.read (| + c + |) + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::poly::multiopen::CommitmentReference::MSM", + 0 + |) in + let msm := + M.copy (| + γ0_0 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::msm::MSM") + [ + Ty.associated + ], + "add_msm", + [] + |), + [ + commitment_batch; + M.read (| + msm + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + let _ := + M.write (| + eval_batch, + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ Ty.associated ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + eval_batch + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::multiopen::gwc::V" + ], + [], + "deref", + [] + |), + [ v ] + |) + |) + ] + |); + M.read (| eval |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::msm::MSM") + [ Ty.associated ], + "add_msm", + [] + |), + [ commitment_multi; commitment_batch ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::AddAssign", + Ty.associated, + [ Ty.associated ], + "add_assign", + [] + |), + [ eval_multi; M.read (| eval_batch |) ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let left := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::commitment::ParamsVerifier") + [ C ], + "empty_msm", + [] + |), + [ M.read (| params |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ Ty.associated ], + "add_msm", + [] + |), + [ left; witness ] + |) + |) in + let right := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::commitment::ParamsVerifier") + [ C ], + "empty_msm", + [] + |), + [ M.read (| params |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ Ty.associated ], + "add_msm", + [] + |), + [ right; witness_with_aux ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ Ty.associated ], + "add_msm", + [] + |), + [ right; commitment_multi ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::msm::MSM") [ Ty.associated ], + "append_term", + [] + |), + [ + right; + M.read (| eval_multi |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Neg", + Ty.associated, + [], + "neg", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::ParamsVerifier", + "g1" + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::msm::PairMSM") + [ Ty.associated ], + "with", + [] + |), + [ M.read (| left |); M.read (| right |) ] + |) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + End verifier. + End gwc. + End multiopen. +End poly. diff --git a/CoqOfRust/halo2_proofs/poly/multiopen/shplonk.v b/CoqOfRust/halo2_proofs/poly/multiopen/shplonk.v new file mode 100644 index 000000000..b7ebe8712 --- /dev/null +++ b/CoqOfRust/halo2_proofs/poly/multiopen/shplonk.v @@ -0,0 +1,2961 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module poly. + Module multiopen. + Module shplonk. + (* StructTuple + { + name := "U"; + ty_params := []; + fields := []; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_poly_multiopen_shplonk_U. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::multiopen::shplonk::U". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| M.read (| self |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_poly_multiopen_shplonk_U. + + Module Impl_core_marker_Copy_for_halo2_proofs_poly_multiopen_shplonk_U. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::multiopen::shplonk::U". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_poly_multiopen_shplonk_U. + + Module Impl_core_fmt_Debug_for_halo2_proofs_poly_multiopen_shplonk_U. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::multiopen::shplonk::U". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ M.read (| f |); M.read (| Value.String "U" |) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_poly_multiopen_shplonk_U. + + Axiom ChallengeU : + forall (F : Ty.t), + (Ty.apply (Ty.path "halo2_proofs::poly::multiopen::shplonk::ChallengeU") [ F ]) = + (Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ F; Ty.path "halo2_proofs::poly::multiopen::shplonk::U" ]). + + (* StructTuple + { + name := "V"; + ty_params := []; + fields := []; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_poly_multiopen_shplonk_V. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::multiopen::shplonk::V". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| M.read (| self |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_poly_multiopen_shplonk_V. + + Module Impl_core_marker_Copy_for_halo2_proofs_poly_multiopen_shplonk_V. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::multiopen::shplonk::V". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_poly_multiopen_shplonk_V. + + Module Impl_core_fmt_Debug_for_halo2_proofs_poly_multiopen_shplonk_V. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::multiopen::shplonk::V". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ M.read (| f |); M.read (| Value.String "V" |) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_poly_multiopen_shplonk_V. + + Axiom ChallengeV : + forall (F : Ty.t), + (Ty.apply (Ty.path "halo2_proofs::poly::multiopen::shplonk::ChallengeV") [ F ]) = + (Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ F; Ty.path "halo2_proofs::poly::multiopen::shplonk::V" ]). + + (* StructTuple + { + name := "Y"; + ty_params := []; + fields := []; + } *) + + Module Impl_core_clone_Clone_for_halo2_proofs_poly_multiopen_shplonk_Y. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::multiopen::shplonk::Y". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| M.read (| self |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_halo2_proofs_poly_multiopen_shplonk_Y. + + Module Impl_core_marker_Copy_for_halo2_proofs_poly_multiopen_shplonk_Y. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::multiopen::shplonk::Y". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_halo2_proofs_poly_multiopen_shplonk_Y. + + Module Impl_core_fmt_Debug_for_halo2_proofs_poly_multiopen_shplonk_Y. + Definition Self : Ty.t := Ty.path "halo2_proofs::poly::multiopen::shplonk::Y". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ M.read (| f |); M.read (| Value.String "Y" |) ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_halo2_proofs_poly_multiopen_shplonk_Y. + + Axiom ChallengeY : + forall (F : Ty.t), + (Ty.apply (Ty.path "halo2_proofs::poly::multiopen::shplonk::ChallengeY") [ F ]) = + (Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ F; Ty.path "halo2_proofs::poly::multiopen::shplonk::Y" ]). + + (* StructTuple + { + name := "Commitment"; + ty_params := [ "F"; "T" ]; + fields := + [ + Ty.tuple + [ T; Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ] ] + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_core_fmt_Debug_T_where_core_cmp_PartialEq_T_where_core_clone_Clone_T_for_halo2_proofs_poly_multiopen_shplonk_Commitment_F_T. + Definition Self (F T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::shplonk::Commitment") [ F; T ]. + + (* Debug *) + Definition fmt (F T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F T in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Commitment" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::shplonk::Commitment", + 0 + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F T : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F T) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F T)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_core_fmt_Debug_T_where_core_cmp_PartialEq_T_where_core_clone_Clone_T_for_halo2_proofs_poly_multiopen_shplonk_Commitment_F_T. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_core_clone_Clone_T_where_core_cmp_PartialEq_T_where_core_clone_Clone_T_for_halo2_proofs_poly_multiopen_shplonk_Commitment_F_T. + Definition Self (F T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::shplonk::Commitment") [ F; T ]. + + (* Clone *) + Definition clone (F T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F T in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructTuple + "halo2_proofs::poly::multiopen::shplonk::Commitment" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.tuple + [ + T; + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ] + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::shplonk::Commitment", + 0 + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F T : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F T) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F T)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_core_clone_Clone_T_where_core_cmp_PartialEq_T_where_core_clone_Clone_T_for_halo2_proofs_poly_multiopen_shplonk_Commitment_F_T. + + Module Impl_core_marker_StructuralPartialEq_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_core_cmp_PartialEq_T_where_core_clone_Clone_T_for_halo2_proofs_poly_multiopen_shplonk_Commitment_F_T. + Definition Self (F T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::shplonk::Commitment") [ F; T ]. + + Axiom Implements : + forall (F T : Ty.t), + M.IsTraitInstance + "core::marker::StructuralPartialEq" + (Self F T) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_core_cmp_PartialEq_T_where_core_clone_Clone_T_for_halo2_proofs_poly_multiopen_shplonk_Commitment_F_T. + + Module Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_core_cmp_PartialEq_T_where_core_cmp_PartialEq_T_where_core_clone_Clone_T_for_halo2_proofs_poly_multiopen_shplonk_Commitment_F_T. + Definition Self (F T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::shplonk::Commitment") [ F; T ]. + + (* PartialEq *) + Definition eq (F T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F T in + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.tuple + [ T; Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ] + ], + [ + Ty.tuple + [ + T; + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ] + ] + ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::shplonk::Commitment", + 0 + |); + M.SubPointer.get_struct_tuple_field (| + M.read (| other |), + "halo2_proofs::poly::multiopen::shplonk::Commitment", + 0 + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F T : Ty.t), + M.IsTraitInstance + "core::cmp::PartialEq" + (Self F T) + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method (eq F T)) ]. + End Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_core_cmp_PartialEq_T_where_core_cmp_PartialEq_T_where_core_clone_Clone_T_for_halo2_proofs_poly_multiopen_shplonk_Commitment_F_T. + + Module Impl_halo2_proofs_poly_multiopen_shplonk_Commitment_F_T. + Definition Self (F T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::shplonk::Commitment") [ F; T ]. + + (* + fn get(&self) -> T { + self.0 .0.clone() + } + *) + Definition get (F T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F T in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", T, [], "clone", [] |), + [ + M.SubPointer.get_tuple_field (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::shplonk::Commitment", + 0 + |), + 0 + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get : + forall (F T : Ty.t), + M.IsAssociatedFunction (Self F T) "get" (get F T). + + (* + fn evals(&self) -> Vec { + self.0 .1.clone() + } + *) + Definition evals (F T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F T in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_tuple_field (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::shplonk::Commitment", + 0 + |), + 1 + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_evals : + forall (F T : Ty.t), + M.IsAssociatedFunction (Self F T) "evals" (evals F T). + End Impl_halo2_proofs_poly_multiopen_shplonk_Commitment_F_T. + + (* StructRecord + { + name := "RotationSet"; + ty_params := [ "F"; "T" ]; + fields := + [ + ("commitments", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ F; T ]; + Ty.path "alloc::alloc::Global" + ]); + ("points", Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_core_fmt_Debug_T_where_core_cmp_PartialEq_T_where_core_clone_Clone_T_for_halo2_proofs_poly_multiopen_shplonk_RotationSet_F_T. + Definition Self (F T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::shplonk::RotationSet") [ F; T ]. + + (* Debug *) + Definition fmt (F T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F T in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "RotationSet" |); + M.read (| Value.String "commitments" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::shplonk::RotationSet", + "commitments" + |)); + M.read (| Value.String "points" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::shplonk::RotationSet", + "points" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F T : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F T) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F T)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_core_fmt_Debug_T_where_core_cmp_PartialEq_T_where_core_clone_Clone_T_for_halo2_proofs_poly_multiopen_shplonk_RotationSet_F_T. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_core_clone_Clone_T_where_core_cmp_PartialEq_T_where_core_clone_Clone_T_for_halo2_proofs_poly_multiopen_shplonk_RotationSet_F_T. + Definition Self (F T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::shplonk::RotationSet") [ F; T ]. + + (* Clone *) + Definition clone (F T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F T in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::poly::multiopen::shplonk::RotationSet" + [ + ("commitments", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ F; T ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::shplonk::RotationSet", + "commitments" + |) + ] + |)); + ("points", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::shplonk::RotationSet", + "points" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F T : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F T) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F T)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_core_clone_Clone_T_where_core_cmp_PartialEq_T_where_core_clone_Clone_T_for_halo2_proofs_poly_multiopen_shplonk_RotationSet_F_T. + + Module Impl_core_marker_StructuralPartialEq_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_core_cmp_PartialEq_T_where_core_clone_Clone_T_for_halo2_proofs_poly_multiopen_shplonk_RotationSet_F_T. + Definition Self (F T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::shplonk::RotationSet") [ F; T ]. + + Axiom Implements : + forall (F T : Ty.t), + M.IsTraitInstance + "core::marker::StructuralPartialEq" + (Self F T) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_core_cmp_PartialEq_T_where_core_clone_Clone_T_for_halo2_proofs_poly_multiopen_shplonk_RotationSet_F_T. + + Module Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_core_cmp_PartialEq_T_where_core_cmp_PartialEq_T_where_core_clone_Clone_T_for_halo2_proofs_poly_multiopen_shplonk_RotationSet_F_T. + Definition Self (F T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::shplonk::RotationSet") [ F; T ]. + + (* PartialEq *) + Definition eq (F T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F T in + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ F; T ]; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ F; T ]; + Ty.path "alloc::alloc::Global" + ] + ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::shplonk::RotationSet", + "commitments" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::multiopen::shplonk::RotationSet", + "commitments" + |) + ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + [ Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ] + ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::shplonk::RotationSet", + "points" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::multiopen::shplonk::RotationSet", + "points" + |) + ] + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F T : Ty.t), + M.IsTraitInstance + "core::cmp::PartialEq" + (Self F T) + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method (eq F T)) ]. + End Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_core_cmp_PartialEq_T_where_core_cmp_PartialEq_T_where_core_clone_Clone_T_for_halo2_proofs_poly_multiopen_shplonk_RotationSet_F_T. + + (* StructRecord + { + name := "IntermediateSets"; + ty_params := [ "F"; "Q" ]; + fields := + [ + ("rotation_sets", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::shplonk::RotationSet") + [ F; Ty.associated ]; + Ty.path "alloc::alloc::Global" + ]); + ("super_point_set", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_core_fmt_Debug_Q_where_halo2_proofs_poly_multiopen_Query_Q_F_where_core_fmt_Debug_associated_type_for_halo2_proofs_poly_multiopen_shplonk_IntermediateSets_F_Q. + Definition Self (F Q : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::shplonk::IntermediateSets") [ F; Q ]. + + (* Debug *) + Definition fmt (F Q : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F Q in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "IntermediateSets" |); + M.read (| Value.String "rotation_sets" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::shplonk::IntermediateSets", + "rotation_sets" + |)); + M.read (| Value.String "super_point_set" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::shplonk::IntermediateSets", + "super_point_set" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F Q : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F Q) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F Q)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_core_fmt_Debug_Q_where_halo2_proofs_poly_multiopen_Query_Q_F_where_core_fmt_Debug_associated_type_for_halo2_proofs_poly_multiopen_shplonk_IntermediateSets_F_Q. + + Module Impl_core_marker_StructuralPartialEq_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_halo2_proofs_poly_multiopen_Query_Q_F_for_halo2_proofs_poly_multiopen_shplonk_IntermediateSets_F_Q. + Definition Self (F Q : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::shplonk::IntermediateSets") [ F; Q ]. + + Axiom Implements : + forall (F Q : Ty.t), + M.IsTraitInstance + "core::marker::StructuralPartialEq" + (Self F Q) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_halo2_proofs_poly_multiopen_Query_Q_F_for_halo2_proofs_poly_multiopen_shplonk_IntermediateSets_F_Q. + + Module Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_core_cmp_PartialEq_Q_where_halo2_proofs_poly_multiopen_Query_Q_F_where_core_cmp_PartialEq_associated_type_for_halo2_proofs_poly_multiopen_shplonk_IntermediateSets_F_Q. + Definition Self (F Q : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::shplonk::IntermediateSets") [ F; Q ]. + + (* PartialEq *) + Definition eq (F Q : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F Q in + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::shplonk::RotationSet") + [ F; Ty.associated ]; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::shplonk::RotationSet") + [ F; Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::shplonk::IntermediateSets", + "rotation_sets" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::multiopen::shplonk::IntermediateSets", + "rotation_sets" + |) + ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + [ Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ] + ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::shplonk::IntermediateSets", + "super_point_set" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "halo2_proofs::poly::multiopen::shplonk::IntermediateSets", + "super_point_set" + |) + ] + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F Q : Ty.t), + M.IsTraitInstance + "core::cmp::PartialEq" + (Self F Q) + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method (eq F Q)) ]. + End Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_where_core_cmp_PartialEq_Q_where_halo2_proofs_poly_multiopen_Query_Q_F_where_core_cmp_PartialEq_associated_type_for_halo2_proofs_poly_multiopen_shplonk_IntermediateSets_F_Q. + + (* + fn construct_intermediate_sets>(queries: I) -> IntermediateSets + where + I: IntoIterator + Clone, + { + let queries = queries.into_iter().collect::>(); + + // Find evaluation of a commitment at a rotation + let get_eval = |commitment: Q::Commitment, rotation: Rotation| -> F { + queries + .iter() + .find(|query| query.get_commitment() == commitment && query.get_rotation() == rotation) + .unwrap() + .get_eval() + }; + + // Order points according to their rotation + let mut rotation_point_map = BTreeMap::new(); + for query in queries.clone() { + let point = rotation_point_map + .entry(query.get_rotation()) + .or_insert_with(|| query.get_point()); + + // Assert rotation point matching consistency + assert_eq!( *point, query.get_point()); + } + // All points appear in queries + let super_point_set: Vec = rotation_point_map.values().cloned().collect(); + + // Collect rotation sets for each commitment + // Example elements in the vector: + // (C_0, {r_5}), + // (C_1, {r_1, r_2, r_3}), + // (C_2, {r_2, r_3, r_4}), + // (C_3, {r_2, r_3, r_4}), + // ... + let mut commitment_rotation_set_map: Vec<(Q::Commitment, BTreeSet)> = vec![]; + for query in queries.clone() { + let rotation = query.get_rotation(); + if let Some(pos) = commitment_rotation_set_map + .iter() + .position(|(commitment, _)| *commitment == query.get_commitment()) + { + let (_, rotation_set) = &mut commitment_rotation_set_map[pos]; + rotation_set.insert(rotation); + } else { + let rotation_set = BTreeSet::from([rotation]); + commitment_rotation_set_map.push((query.get_commitment(), rotation_set)); + }; + } + + // Flatten rotation sets and collect commitments that opens against each commitment set + // Example elements in the vector: + // {r_5}: [C_0], + // {r_1, r_2, r_3} : [C_1] + // {r_2, r_3, r_4} : [C_2, C_3], + // ... + let mut rotation_set_commitment_map = BTreeMap::, Vec>::new(); + for (commitment, rotation_set) in commitment_rotation_set_map.iter() { + let commitments = rotation_set_commitment_map + .entry(rotation_set.clone()) + .or_insert_with(Vec::new); + if !commitments.contains(commitment) { + commitments.push(commitment.clone()); + } + } + + let rotation_sets = rotation_set_commitment_map + .into_iter() + .map(|(rotation_set, commitments)| { + let rotations: Vec = rotation_set.iter().cloned().collect(); + + let commitments: Vec> = commitments + .iter() + .map(|commitment| { + let evals: Vec = rotations + .iter() + .map(|rotation| get_eval(commitment.clone(), *rotation)) + .collect(); + Commitment((commitment.clone(), evals)) + }) + .collect(); + + RotationSet { + commitments, + points: rotations + .iter() + .map(|rotation| *rotation_point_map.get(rotation).unwrap()) + .collect(), + } + }) + .collect::>>(); + + IntermediateSets { + rotation_sets, + super_point_set, + } + } + *) + Definition construct_intermediate_sets (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F; _ as I; Q ], [ queries ] => + ltac:(M.monadic + (let queries := M.alloc (| queries |) in + M.read (| + let queries := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.associated, + [], + "collect", + [ Ty.apply (Ty.path "alloc::vec::Vec") [ Q; Ty.path "alloc::alloc::Global" ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + I, + [], + "into_iter", + [] + |), + [ M.read (| queries |) ] + |) + ] + |) + |) in + let get_eval := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let commitment := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let rotation := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::poly::multiopen::Query", + Q, + [ F ], + "get_eval", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Q ] ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Q ], + [], + "find", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "&") [ Q ] ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Q ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Q; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ queries ] + |) + ] + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let query := + M.copy (| γ |) in + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ Ty.associated ], + "eq", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::poly::multiopen::Query", + Q, + [ F ], + "get_commitment", + [] + |), + [ + M.read (| + M.read (| + query + |) + |) + ] + |) + |); + commitment + ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "halo2_proofs::poly::Rotation", + [ + Ty.path + "halo2_proofs::poly::Rotation" + ], + "eq", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::poly::multiopen::Query", + Q, + [ F ], + "get_rotation", + [] + |), + [ + M.read (| + M.read (| + query + |) + |) + ] + |) + |); + rotation + ] + |))) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let rotation_point_map := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "halo2_proofs::poly::Rotation"; F; Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Q; Ty.path "alloc::alloc::Global" ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Q; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ queries ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ Q; Ty.path "alloc::alloc::Global" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let query := M.copy (| γ0_0 |) in + let point := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::entry::Entry") + [ + Ty.path "halo2_proofs::poly::Rotation"; + F; + Ty.path "alloc::alloc::Global" + ], + "or_insert_with", + [ Ty.function [ Ty.tuple [] ] F ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::poly::Rotation"; + F; + Ty.path "alloc::alloc::Global" + ], + "entry", + [] + |), + [ + rotation_point_map; + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::poly::multiopen::Query", + Q, + [ F ], + "get_rotation", + [] + |), + [ query ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "halo2_proofs::poly::multiopen::Query", + Q, + [ F ], + "get_point", + [] + |), + [ query ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.read (| point |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::poly::multiopen::Query", + Q, + [ F ], + "get_point", + [] + |), + [ query ] + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + F, + [ F ], + "eq", + [] + |), + [ + M.read (| left_val |); + M.read (| right_val |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ F; F ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let super_point_set := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::cloned::Cloned") + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::Values") + [ Ty.path "halo2_proofs::poly::Rotation"; F ] + ], + [], + "collect", + [ Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::Values") + [ Ty.path "halo2_proofs::poly::Rotation"; F ], + [], + "cloned", + [ F ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "halo2_proofs::poly::Rotation"; + F; + Ty.path "alloc::alloc::Global" + ], + "values", + [] + |), + [ rotation_point_map ] + |) + ] + |) + ] + |) + |) in + let commitment_rotation_set_map := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.associated; + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Q; Ty.path "alloc::alloc::Global" ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Q; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ queries ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ Q; Ty.path "alloc::alloc::Global" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let query := M.copy (| γ0_0 |) in + let rotation := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::poly::multiopen::Query", + Q, + [ F ], + "get_rotation", + [] + |), + [ query ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.associated; + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "halo2_proofs::poly::Rotation"; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "position", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.associated; + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "halo2_proofs::poly::Rotation"; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.associated; + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "halo2_proofs::poly::Rotation"; + Ty.path + "alloc::alloc::Global" + ] + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.associated; + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "halo2_proofs::poly::Rotation"; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ commitment_rotation_set_map ] + |) + ] + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let commitment := + M.alloc (| γ1_0 |) in + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ Ty.associated ], + "eq", + [] + |), + [ + M.read (| + commitment + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::poly::multiopen::Query", + Q, + [ F ], + "get_commitment", + [] + |), + [ query ] + |) + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let pos := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::IndexMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.associated; + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "halo2_proofs::poly::Rotation"; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index_mut", + [] + |), + [ + commitment_rotation_set_map; + M.read (| pos |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let rotation_set := M.alloc (| γ1_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "halo2_proofs::poly::Rotation"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + M.read (| rotation_set |); + M.read (| rotation |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let rotation_set := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "halo2_proofs::poly::Rotation"; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.apply + (Ty.path "array") + [ + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + "from", + [] + |), + [ Value.Array [ M.read (| rotation |) ] ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.associated; + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "halo2_proofs::poly::Rotation"; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + commitment_rotation_set_map; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::poly::multiopen::Query", + Q, + [ F ], + "get_commitment", + [] + |), + [ query ] + |); + M.read (| rotation_set |) + ] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let rotation_set_commitment_map := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ Ty.path "halo2_proofs::poly::Rotation"; Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.associated; + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.associated; + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.associated; + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ commitment_rotation_set_map ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.associated; + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ2_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let commitment := M.alloc (| γ2_0 |) in + let rotation_set := M.alloc (| γ2_1 |) in + let commitments := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::entry::Entry") + [ + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "or_insert_with", + [ + Ty.function + [] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "entry", + [] + |), + [ + rotation_set_commitment_map; + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ M.read (| rotation_set |) ] + |) + ] + |); + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" + ], + "new", + [] + |) + ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "contains", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| commitments |) ] + |); + M.read (| commitment |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.read (| commitments |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.associated, + [], + "clone", + [] + |), + [ M.read (| commitment |) ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let rotation_sets := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::IntoIter") + [ + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::shplonk::RotationSet") + [ F; Ty.associated ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::shplonk::RotationSet") + [ F; Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::IntoIter") + [ + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::shplonk::RotationSet") + [ F; Ty.associated ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::shplonk::RotationSet") + [ F; Ty.associated ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply + (Ty.path "alloc::collections::btree::set::BTreeSet") + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| rotation_set_commitment_map |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let rotation_set := M.copy (| γ0_0 |) in + let commitments := M.copy (| γ0_1 |) in + M.read (| + let rotations := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::cloned::Cloned") + [ + Ty.apply + (Ty.path + "alloc::collections::btree::set::Iter") + [ Ty.path "halo2_proofs::poly::Rotation" ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::poly::Rotation"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::collections::btree::set::Iter") + [ Ty.path "halo2_proofs::poly::Rotation" + ], + [], + "cloned", + [ Ty.path "halo2_proofs::poly::Rotation" ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::set::BTreeSet") + [ + Ty.path + "halo2_proofs::poly::Rotation"; + Ty.path "alloc::alloc::Global" + ], + "iter", + [] + |), + [ rotation_set ] + |) + ] + |) + ] + |) + |) in + let commitments := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.associated ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ F; Ty.associated ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ F; Ty.associated ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.associated ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ F; Ty.associated ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ F; Ty.associated ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ commitments ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let commitment := + M.copy (| γ |) in + M.read (| + let evals := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + F + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::poly::Rotation" + ], + [], + "map", + [ + F; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + F + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.path + "halo2_proofs::poly::Rotation" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::poly::Rotation"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + rotations + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + rotation := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + F, + [ + Ty.tuple + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Rotation" + ] + ], + "call", + [] + |), + [ + get_eval; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.associated, + [], + "clone", + [] + |), + [ + M.read (| + commitment + |) + ] + |); + M.read (| + M.read (| + rotation + |) + |) + ] + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "halo2_proofs::poly::multiopen::shplonk::Commitment" + [ + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.associated, + [], + "clone", + [] + |), + [ + M.read (| + commitment + |) + ] + |); + M.read (| + evals + |) + ] + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::poly::multiopen::shplonk::RotationSet" + [ + ("commitments", M.read (| commitments |)); + ("points", + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::poly::Rotation" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + F + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "halo2_proofs::poly::Rotation" + ], + [], + "map", + [ + F; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "halo2_proofs::poly::Rotation" + ] + ] + ] + F + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "halo2_proofs::poly::Rotation" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::poly::Rotation"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ rotations ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let rotation := + M.copy (| γ |) in + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "&") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "halo2_proofs::poly::Rotation"; + F; + Ty.path + "alloc::alloc::Global" + ], + "get", + [ + Ty.path + "halo2_proofs::poly::Rotation" + ] + |), + [ + rotation_point_map; + M.read (| + rotation + |) + ] + |) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |)) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::poly::multiopen::shplonk::IntermediateSets" + [ + ("rotation_sets", M.read (| rotation_sets |)); + ("super_point_set", M.read (| super_point_set |)) + ] + |) + |))) + | _, _ => M.impossible + end. + End shplonk. + End multiopen. +End poly. diff --git a/CoqOfRust/halo2_proofs/poly/multiopen/shplonk/prover.v b/CoqOfRust/halo2_proofs/poly/multiopen/shplonk/prover.v new file mode 100644 index 000000000..73d50b189 --- /dev/null +++ b/CoqOfRust/halo2_proofs/poly/multiopen/shplonk/prover.v @@ -0,0 +1,3838 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module poly. + Module multiopen. + Module shplonk. + Module prover. + (* + fn div_by_vanishing(poly: Polynomial, roots: &[F]) -> Vec { + let poly = roots + .iter() + .fold(poly.values, |poly, point| kate_division(&poly, *point)); + + poly + } + *) + Definition div_by_vanishing (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ poly; roots ] => + ltac:(M.monadic + (let poly := M.alloc (| poly |) in + let roots := M.alloc (| roots |) in + M.read (| + let poly := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ F ], + [], + "fold", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.apply (Ty.path "&") [ F ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ F ], + "iter", + [] + |), + [ M.read (| roots |) ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + poly, + "halo2_proofs::poly::Polynomial", + "values" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let poly := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let point := M.copy (| γ |) in + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::kate_division", + [ + F; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ] + ] + ] + |), + [ poly; M.read (| M.read (| point |) |) ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + poly + |))) + | _, _ => M.impossible + end. + + (* StructRecord + { + name := "CommitmentExtension"; + ty_params := [ "C" ]; + fields := + [ + ("commitment", + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ + Ty.associated; + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::PolynomialPointer") [ C ] + ]); + ("low_degree_equivalent", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]) + ]; + } *) + + Module Impl_halo2_proofs_poly_multiopen_shplonk_Commitment_associated_type_halo2_proofs_poly_multiopen_PolynomialPointer_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ + Ty.associated; + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::PolynomialPointer") [ C ] + ]. + + (* + fn extend(&self, n: u64, points: Vec) -> CommitmentExtension<'a, C> { + let mut poly = lagrange_interpolate(&points[..], &self.evals()[..]); + poly.resize(n as usize, C::Scalar::zero()); + + let low_degree_equivalent = Polynomial { + values: poly, + _marker: PhantomData, + }; + + CommitmentExtension { + commitment: self.clone(), + low_degree_equivalent, + } + } + *) + Definition extend (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; n; points ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let n := M.alloc (| n |) in + let points := M.alloc (| points |) in + M.read (| + let poly := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::lagrange_interpolate", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index", + [] + |), + [ points; Value.StructTuple "core::ops::range::RangeFull" [] ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::PolynomialPointer") + [ C ] + ], + "evals", + [] + |), + [ M.read (| self |) ] + |) + |); + Value.StructTuple "core::ops::range::RangeFull" [] + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "resize", + [] + |), + [ + poly; + M.rust_cast (M.read (| n |)); + M.call_closure (| + M.get_trait_method (| "ff::Field", Ty.associated, [], "zero", [] |), + [] + |) + ] + |) + |) in + let low_degree_equivalent := + M.alloc (| + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", M.read (| poly |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ] + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension" + [ + ("commitment", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ + Ty.associated; + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::PolynomialPointer") + [ C ] + ], + [], + "clone", + [] + |), + [ M.read (| self |) ] + |)); + ("low_degree_equivalent", M.read (| low_degree_equivalent |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_extend : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "extend" (extend C). + End Impl_halo2_proofs_poly_multiopen_shplonk_Commitment_associated_type_halo2_proofs_poly_multiopen_PolynomialPointer_C. + + Module Impl_halo2_proofs_poly_multiopen_shplonk_prover_CommitmentExtension_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension") + [ C ]. + + (* + fn linearisation_contribution(&self, u: C::Scalar) -> Polynomial { + let p_x = self.commitment.get().poly; + let r_eval = eval_polynomial(&self.low_degree_equivalent.values[..], u); + p_x - r_eval + } + *) + Definition linearisation_contribution (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; u ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let u := M.alloc (| u |) in + M.read (| + let p_x := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ + Ty.associated; + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::PolynomialPointer") + [ C ] + ], + "get", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension", + "commitment" + |) + ] + |) + |), + "halo2_proofs::poly::multiopen::PolynomialPointer", + "poly" + |) + |) in + let r_eval := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::eval_polynomial", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension", + "low_degree_equivalent" + |), + "halo2_proofs::poly::Polynomial", + "values" + |); + Value.StructTuple "core::ops::range::RangeFull" [] + ] + |); + M.read (| u |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ], + [ Ty.associated ], + "sub", + [] + |), + [ M.read (| p_x |); M.read (| r_eval |) ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_linearisation_contribution : + forall (C : Ty.t), + M.IsAssociatedFunction + (Self C) + "linearisation_contribution" + (linearisation_contribution C). + + (* + fn quotient_contribution(&self) -> Polynomial { + let p_x = self.commitment.get().poly.clone(); + p_x - &self.low_degree_equivalent + } + *) + Definition quotient_contribution (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let p_x := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ], + [], + "clone", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::PolynomialPointer") + [ C ] + ], + "get", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension", + "commitment" + |) + ] + |) + |), + "halo2_proofs::poly::multiopen::PolynomialPointer", + "poly" + |) + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ], + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ] + ], + "sub", + [] + |), + [ + M.read (| p_x |); + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension", + "low_degree_equivalent" + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_quotient_contribution : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "quotient_contribution" (quotient_contribution C). + End Impl_halo2_proofs_poly_multiopen_shplonk_prover_CommitmentExtension_C. + + (* StructRecord + { + name := "RotationSetExtension"; + ty_params := [ "C" ]; + fields := + [ + ("commitments", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension") + [ C ]; + Ty.path "alloc::alloc::Global" + ]); + ("points", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]) + ]; + } *) + + Module Impl_halo2_proofs_poly_multiopen_shplonk_RotationSet_associated_type_halo2_proofs_poly_multiopen_PolynomialPointer_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::shplonk::RotationSet") + [ + Ty.associated; + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::PolynomialPointer") [ C ] + ]. + + (* + fn extend(&self, commitments: Vec>) -> RotationSetExtension<'a, C> { + RotationSetExtension { + commitments, + points: self.points.clone(), + } + } + *) + Definition extend (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; commitments ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let commitments := M.alloc (| commitments |) in + Value.StructRecord + "halo2_proofs::poly::multiopen::shplonk::prover::RotationSetExtension" + [ + ("commitments", M.read (| commitments |)); + ("points", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::poly::multiopen::shplonk::RotationSet", + "points" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_extend : + forall (C : Ty.t), + M.IsAssociatedFunction (Self C) "extend" (extend C). + End Impl_halo2_proofs_poly_multiopen_shplonk_RotationSet_associated_type_halo2_proofs_poly_multiopen_PolynomialPointer_C. + + (* + pub fn create_proof<'a, I, C: CurveAffine, E: EncodedChallenge, T: TranscriptWrite>( + params: &Params, + transcript: &mut T, + queries: I, + ) -> io::Result<()> + where + I: IntoIterator> + Clone, + { + let zero = || Polynomial:: { + values: vec![C::Scalar::zero(); params.n as usize], + _marker: PhantomData, + }; + + // TODO: explore if it is safe to use same challenge + // for different sets that are already combined with anoter challenge + let y: ChallengeY<_> = transcript.squeeze_challenge_scalar(); + + let quotient_contribution = + |rotation_set: &RotationSetExtension| -> Polynomial { + // [P_i_0(X) - R_i_0(X), P_i_1(X) - R_i_1(X), ... ] + let numerators: Vec> = rotation_set + .commitments + .iter() + .map(|commitment| commitment.quotient_contribution()) + .collect(); + + // define numerator polynomial as + // N_i_j(X) = (P_i_j(X) - R_i_j(X)) + // and combine polynomials with same evaluation point set + // N_i(X) = linear_combinination(y, N_i_j(X)) + // where y is random scalar to combine numerator polynomials + let n_x: Polynomial = + numerators.iter().fold(zero(), |acc, q_x| (acc * *y) + q_x); + + let points = &rotation_set.points[..]; + + // quotient contribution of this evaluation set is + // Q_i(X) = N_i(X) / Z_i(X) where + // Z_i(X) = (x - r_i_0) * (x - r_i_1) * ... + let mut poly = div_by_vanishing(n_x, points); + poly.resize(params.n as usize, C::Scalar::zero()); + + Polynomial { + values: poly, + _marker: PhantomData, + } + }; + + let intermediate_sets = construct_intermediate_sets(queries); + let (rotation_sets, super_point_set) = ( + intermediate_sets.rotation_sets, + intermediate_sets.super_point_set, + ); + + let rotation_sets: Vec> = rotation_sets + .iter() + .map(|rotation_set| { + let commitments: Vec> = rotation_set + .commitments + .iter() + .map(|commitment_data| { + commitment_data.extend(params.n, rotation_set.points.clone()) + }) + .collect(); + rotation_set.extend(commitments) + }) + .collect(); + + let v: ChallengeV<_> = transcript.squeeze_challenge_scalar(); + + let quotient_polynomials: Vec> = + rotation_sets.iter().map(quotient_contribution).collect(); + + let h_x: Polynomial = quotient_polynomials + .iter() + .fold(zero(), |acc, u_x| (acc * *v) + u_x); + + let h = params.commit(&h_x).to_affine(); + transcript.write_point(h)?; + let u: ChallengeU<_> = transcript.squeeze_challenge_scalar(); + + let zt_eval = evaluate_vanishing_polynomial(&super_point_set[..], *u); + + let linearisation_contribution = + |rotation_set: RotationSetExtension| -> (Polynomial, C::Scalar) { + let diffs: Vec = super_point_set + .iter() + .filter(|point| !rotation_set.points.contains(point)) + .copied() + .collect(); + + // calculate difference vanishing polynomial evaluation + + let z_i = evaluate_vanishing_polynomial(&diffs[..], *u); + + // inner linearisation contibutions are + // [P_i_0(X) - r_i_0, P_i_1(X) - r_i_1, ... ] where + // r_i_j = R_i_j(u) is the evaluation of low degree equivalent polynomial + // where u is random evaluation point + let inner_contributions: Vec> = rotation_set + .commitments + .iter() + .map(|commitment| commitment.linearisation_contribution( *u)) + .collect(); + + // define inner contributor polynomial as + // L_i_j(X) = (P_i_j(X) - r_i_j) + // and combine polynomials with same evaluation point set + // L_i(X) = linear_combinination(y, L_i_j(X)) + // where y is random scalar to combine inner contibutors + let l_x: Polynomial = inner_contributions + .iter() + .fold(zero(), |acc, l_x| (acc * *y) + l_x); + + // finally scale l_x by difference vanishing polynomial evaluation z_i + (l_x * z_i, z_i) + }; + + #[allow(clippy::type_complexity)] + let (linearisation_contibutions, z_diffs): ( + Vec>, + Vec, + ) = rotation_sets + .into_iter() + .map(linearisation_contribution) + .unzip(); + + let l_x: Polynomial = linearisation_contibutions + .iter() + .fold(zero(), |acc, u_x| (acc * *v) + u_x); + + let l_x = l_x - &(h_x * zt_eval); + + // sanity check + { + let must_be_zero = eval_polynomial(&l_x.values[..], *u); + assert_eq!(must_be_zero, C::Scalar::zero()); + } + + let mut h_x = div_by_vanishing(l_x, &[*u]); + + // normalize coefficients by the coefficient of the first polynomial + let z_0_diff_inv = z_diffs[0].invert().unwrap(); + for h_i in h_x.iter_mut() { + h_i.mul_assign(z_0_diff_inv) + } + + let h_x = Polynomial { + values: h_x, + _marker: PhantomData, + }; + + let h = params.commit(&h_x).to_affine(); + transcript.write_point(h)?; + + Ok(()) + } + *) + Definition create_proof (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ _ as I; C; E; T ], [ params; transcript; queries ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let transcript := M.alloc (| transcript |) in + let queries := M.alloc (| queries |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let zero := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", + M.call_closure (| + M.get_function (| + "alloc::vec::from_elem", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "zero", + [] + |), + [] + |); + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)) + ] + |)); + ("_marker", + Value.StructTuple "core::marker::PhantomData" []) + ])) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let y := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ C; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::poly::multiopen::shplonk::Y" ] + |), + [ M.read (| transcript |) ] + |) + |) in + let quotient_contribution := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let rotation_set := M.copy (| γ |) in + M.read (| + let numerators := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension") + [ C ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension") + [ C ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension") + [ C ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension") + [ C ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| rotation_set |), + "halo2_proofs::poly::multiopen::shplonk::prover::RotationSetExtension", + "commitments" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let commitment := + M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension") + [ C ], + "quotient_contribution", + [] + |), + [ M.read (| commitment |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let n_x := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ], + [], + "fold", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ numerators ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ]), + [ Ty.tuple [] ], + "call", + [] + |), + [ zero; Value.Tuple [] ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let q_x := + M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [ Ty.associated ], + "mul", + [] + |), + [ + M.read (| acc |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::poly::multiopen::shplonk::Y" + ], + [], + "deref", + [] + |), + [ y ] + |) + |) + ] + |); + M.read (| q_x |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let points := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" + ], + [ Ty.path "core::ops::range::RangeFull" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| rotation_set |), + "halo2_proofs::poly::multiopen::shplonk::prover::RotationSetExtension", + "points" + |); + Value.StructTuple "core::ops::range::RangeFull" [] + ] + |) + |) in + let poly := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::poly::multiopen::shplonk::prover::div_by_vanishing", + [ Ty.associated ] + |), + [ M.read (| n_x |); M.read (| points |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" + ], + "resize", + [] + |), + [ + poly; + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |)); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "zero", + [] + |), + [] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", M.read (| poly |)); + ("_marker", + Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let intermediate_sets := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::poly::multiopen::shplonk::construct_intermediate_sets", + [ + Ty.associated; + I; + Ty.apply (Ty.path "halo2_proofs::poly::multiopen::ProverQuery") [ C ] + ] + |), + [ M.read (| queries |) ] + |) + |) in + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.read (| + M.SubPointer.get_struct_record_field (| + intermediate_sets, + "halo2_proofs::poly::multiopen::shplonk::IntermediateSets", + "rotation_sets" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + intermediate_sets, + "halo2_proofs::poly::multiopen::shplonk::IntermediateSets", + "super_point_set" + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let rotation_sets := M.copy (| γ0_0 |) in + let super_point_set := M.copy (| γ0_1 |) in + let rotation_sets := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::RotationSet") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::PolynomialPointer") + [ C ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::RotationSet") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::PolynomialPointer") + [ C ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::RotationSetExtension") + [ C ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::RotationSetExtension") + [ C ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::RotationSet") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::PolynomialPointer") + [ C ] + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::RotationSetExtension") + [ C ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::RotationSet") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::PolynomialPointer") + [ C ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::RotationSetExtension") + [ C ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::RotationSet") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::PolynomialPointer") + [ C ] + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::RotationSet") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::PolynomialPointer") + [ C ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ rotation_sets ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let rotation_set := M.copy (| γ |) in + M.read (| + let commitments := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::PolynomialPointer") + [ C ] + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::PolynomialPointer") + [ C ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension") + [ C ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension") + [ C ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::PolynomialPointer") + [ C ] + ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension") + [ C ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::PolynomialPointer") + [ C ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension") + [ C ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::PolynomialPointer") + [ C ] + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::PolynomialPointer") + [ C ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + rotation_set + |), + "halo2_proofs::poly::multiopen::shplonk::RotationSet", + "commitments" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let + commitment_data := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::PolynomialPointer") + [ C + ] + ], + "extend", + [] + |), + [ + M.read (| + commitment_data + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + params + |), + "halo2_proofs::poly::commitment::Params", + "n" + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + rotation_set + |), + "halo2_proofs::poly::multiopen::shplonk::RotationSet", + "points" + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::RotationSet") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::PolynomialPointer") + [ C ] + ], + "extend", + [] + |), + [ + M.read (| rotation_set |); + M.read (| commitments |) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let v := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ C; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::poly::multiopen::shplonk::V" ] + |), + [ M.read (| transcript |) ] + |) + |) in + let quotient_polynomials := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::RotationSetExtension") + [ C ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::RotationSetExtension") + [ C ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::RotationSetExtension") + [ C ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::RotationSetExtension") + [ C ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::RotationSetExtension") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::RotationSetExtension") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ rotation_sets ] + |) + ] + |); + M.read (| quotient_contribution |) + ] + |) + ] + |) + |) in + let h_x := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ], + [], + "fold", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ quotient_polynomials ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]), + [ Ty.tuple [] ], + "call", + [] + |), + [ zero; Value.Tuple [] ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let u_x := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [ Ty.associated ], + "mul", + [] + |), + [ + M.read (| acc |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::poly::multiopen::shplonk::V" + ], + [], + "deref", + [] + |), + [ v ] + |) + |) + ] + |); + M.read (| u_x |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let h := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::Curve", + Ty.associated, + [], + "to_affine", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::commitment::Params") + [ C ], + "commit", + [] + |), + [ M.read (| params |); h_x ] + |) + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ C; E ], + "write_point", + [] + |), + [ M.read (| transcript |); M.read (| h |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let u := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ C; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::poly::multiopen::shplonk::U" ] + |), + [ M.read (| transcript |) ] + |) + |) in + let zt_eval := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::evaluate_vanishing_polynomial", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index", + [] + |), + [ + super_point_set; + Value.StructTuple "core::ops::range::RangeFull" [] + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "halo2_proofs::transcript::ChallengeScalar") + [ C; Ty.path "halo2_proofs::poly::multiopen::shplonk::U" + ], + [], + "deref", + [] + |), + [ u ] + |) + |) + ] + |) + |) in + let linearisation_contribution := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let rotation_set := M.copy (| γ |) in + M.read (| + let diffs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::copied::Copied") + [ + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.associated ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ] + ] + ] + (Ty.path "bool") + ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.associated ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ] + ] + ] + (Ty.path "bool") + ], + [], + "copied", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.associated ], + [], + "filter", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ Ty.associated ] + ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.associated ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ super_point_set ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let point := + M.copy (| + γ + |) in + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ], + "contains", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rotation_set, + "halo2_proofs::poly::multiopen::shplonk::prover::RotationSetExtension", + "points" + |) + ] + |); + M.read (| + M.read (| + point + |) + |) + ] + |)))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |) in + let z_i := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::evaluate_vanishing_polynomial", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.path + "core::ops::range::RangeFull" + ], + "index", + [] + |), + [ + diffs; + Value.StructTuple + "core::ops::range::RangeFull" + [] + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::poly::multiopen::shplonk::U" + ], + [], + "deref", + [] + |), + [ u ] + |) + |) + ] + |) + |) in + let inner_contributions := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension") + [ C ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension") + [ C ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension") + [ C ] + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension") + [ C ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension") + [ C ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension") + [ C ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rotation_set, + "halo2_proofs::poly::multiopen::shplonk::prover::RotationSetExtension", + "commitments" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let commitment := + M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::CommitmentExtension") + [ C ], + "linearisation_contribution", + [] + |), + [ + M.read (| + commitment + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::poly::multiopen::shplonk::U" + ], + [], + "deref", + [] + |), + [ u ] + |) + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let l_x := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ], + [], + "fold", + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ inner_contributions ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ]), + [ Ty.tuple [] ], + "call", + [] + |), + [ zero; Value.Tuple [] ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := + M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let l_x := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + acc + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::poly::multiopen::shplonk::Y" + ], + [], + "deref", + [] + |), + [ y ] + |) + |) + ] + |); + M.read (| + l_x + |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ], + [ Ty.associated ], + "mul", + [] + |), + [ M.read (| l_x |); M.read (| z_i |) ] + |); + M.read (| z_i |) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::RotationSetExtension") + [ C ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::RotationSetExtension") + [ C ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" + ]; + Ty.associated + ]) + ], + [], + "unzip", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]; + Ty.associated; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::RotationSetExtension") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" + ]; + Ty.associated + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::RotationSetExtension") + [ C ] + ] + ] + (Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ]; + Ty.associated + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::prover::RotationSetExtension") + [ C ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| rotation_sets |) ] + |); + M.read (| linearisation_contribution |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let linearisation_contibutions := M.copy (| γ0_0 |) in + let z_diffs := M.copy (| γ0_1 |) in + let l_x := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ], + [], + "fold", + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ linearisation_contibutions ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ]), + [ Ty.tuple [] ], + "call", + [] + |), + [ zero; Value.Tuple [] ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let u_x := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ] + ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::Coeff" + ], + [ Ty.associated ], + "mul", + [] + |), + [ + M.read (| acc |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::poly::multiopen::shplonk::V" + ], + [], + "deref", + [] + |), + [ v ] + |) + |) + ] + |); + M.read (| u_x |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let l_x := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ Ty.associated; Ty.path "halo2_proofs::poly::Coeff" + ], + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ] + ] + ], + "sub", + [] + |), + [ + M.read (| l_x |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::poly::Polynomial") + [ + Ty.associated; + Ty.path "halo2_proofs::poly::Coeff" + ], + [ Ty.associated ], + "mul", + [] + |), + [ M.read (| h_x |); M.read (| zt_eval |) ] + |) + |) + ] + |) + |) in + let _ := + let must_be_zero := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::eval_polynomial", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" + ], + [ Ty.path "core::ops::range::RangeFull" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + l_x, + "halo2_proofs::poly::Polynomial", + "values" + |); + Value.StructTuple "core::ops::range::RangeFull" [] + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::poly::multiopen::shplonk::U" + ], + [], + "deref", + [] + |), + [ u ] + |) + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + must_be_zero; + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "zero", + [] + |), + [] + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.associated, + [ Ty.associated ], + "eq", + [] + |), + [ + M.read (| left_val |); + M.read (| right_val |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.associated; Ty.associated ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |) in + let h_x := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::poly::multiopen::shplonk::prover::div_by_vanishing", + [ Ty.associated ] + |), + [ + M.read (| l_x |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + C; + Ty.path + "halo2_proofs::poly::multiopen::shplonk::U" + ], + [], + "deref", + [] + |), + [ u ] + |) + |) + ] + |)) + ] + |) + |) in + let z_0_diff_inv := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "subtle::CtOption") [ Ty.associated ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "invert", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ z_diffs; Value.Integer 0 ] + |) + ] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.associated ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ h_x ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::IterMut") + [ Ty.associated ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let h_i := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ Ty.associated ], + "mul_assign", + [] + |), + [ + M.read (| h_i |); + M.read (| z_0_diff_inv |) + ] + |) + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let h_x := + M.alloc (| + Value.StructRecord + "halo2_proofs::poly::Polynomial" + [ + ("values", M.read (| h_x |)); + ("_marker", + Value.StructTuple "core::marker::PhantomData" []) + ] + |) in + let h := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::Curve", + Ty.associated, + [], + "to_affine", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::Params") + [ C ], + "commit", + [] + |), + [ M.read (| params |); h_x ] + |) + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptWrite", + T, + [ C; E ], + "write_point", + [] + |), + [ M.read (| transcript |); M.read (| h |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ] + |))) + ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + End prover. + End shplonk. + End multiopen. +End poly. diff --git a/CoqOfRust/halo2_proofs/poly/multiopen/shplonk/verifier.v b/CoqOfRust/halo2_proofs/poly/multiopen/shplonk/verifier.v new file mode 100644 index 000000000..b9c3ff8b2 --- /dev/null +++ b/CoqOfRust/halo2_proofs/poly/multiopen/shplonk/verifier.v @@ -0,0 +1,2074 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module poly. + Module multiopen. + Module shplonk. + Module verifier. + (* + pub fn verify_proof< + 'r, + 'params: 'r, + I, + C: MultiMillerLoop, + E: EncodedChallenge, + T: TranscriptRead, + >( + params: &'params ParamsVerifier, + transcript: &mut T, + queries: I, + ) -> Result, Error> + where + I: IntoIterator> + Clone, + { + let intermediate_sets = construct_intermediate_sets(queries); + let (rotation_sets, super_point_set) = ( + intermediate_sets.rotation_sets, + intermediate_sets.super_point_set, + ); + + let y: ChallengeY<_> = transcript.squeeze_challenge_scalar(); + let v: ChallengeV<_> = transcript.squeeze_challenge_scalar(); + + let h1 = transcript.read_point().map_err(|_| Error::SamplingError)?; + let u: ChallengeU<_> = transcript.squeeze_challenge_scalar(); + let h2 = transcript.read_point().map_err(|_| Error::SamplingError)?; + + let (mut z_0_diff_inverse, mut z_0) = (C::Scalar::zero(), C::Scalar::zero()); + let (mut outer_msm, mut r_outer_acc) = (PreMSM::::new(), C::Scalar::zero()); + for (i, rotation_set) in rotation_sets.iter().enumerate() { + let diffs: Vec = super_point_set + .iter() + .filter(|point| !rotation_set.points.contains(point)) + .copied() + .collect(); + let mut z_diff_i = evaluate_vanishing_polynomial(&diffs[..], *u); + + // normalize coefficients by the coefficient of the first commitment + if i == 0 { + z_0 = evaluate_vanishing_polynomial(&rotation_set.points[..], *u); + z_0_diff_inverse = z_diff_i.invert().unwrap(); + z_diff_i = C::Scalar::one(); + } else { + z_diff_i.mul_assign(z_0_diff_inverse); + } + + let (mut inner_msm, mut r_inner_acc) = (ProjectiveMSM::new(), C::Scalar::zero()); + for commitment_data in rotation_set.commitments.iter() { + // calculate low degree equivalent + let r_x = lagrange_interpolate(&rotation_set.points[..], &commitment_data.evals()[..]); + let r_eval = eval_polynomial(&r_x[..], *u); + r_inner_acc = ( *y * r_inner_acc) + r_eval; + + let inner_contrib = match commitment_data.get() { + CommitmentReference::Commitment(c) => c.to_curve(), + // TODO: we should support one more nested degree to append + // folded commitments to the inner_msm + CommitmentReference::MSM(msm) => msm.eval().to_curve(), + }; + inner_msm.append_term(C::Scalar::one(), inner_contrib); + } + r_outer_acc = ( *v * r_outer_acc) + (r_inner_acc * z_diff_i); + + inner_msm.combine_with_base( *y); + inner_msm.scale(z_diff_i); + outer_msm.add_msm(inner_msm); + } + outer_msm.combine_with_base( *v); + let mut outer_msm = outer_msm.normalize(); + outer_msm.append_term(-r_outer_acc, params.g1); + outer_msm.append_term(-z_0, h1); + outer_msm.append_term( *u, h2); + + let mut left = params.empty_msm(); + left.append_term(C::Scalar::one(), h2); + + let mut right = params.empty_msm(); + right.add_msm(&outer_msm); + + Ok(PairMSM::with(left, right)) + } + *) + Definition verify_proof (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ _ as I; C; E; T ], [ params; transcript; queries ] => + ltac:(M.monadic + (let params := M.alloc (| params |) in + let transcript := M.alloc (| transcript |) in + let queries := M.alloc (| queries |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let intermediate_sets := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::poly::multiopen::shplonk::construct_intermediate_sets", + [ + Ty.associated; + I; + Ty.apply + (Ty.path "halo2_proofs::poly::multiopen::VerifierQuery") + [ Ty.associated ] + ] + |), + [ M.read (| queries |) ] + |) + |) in + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.read (| + M.SubPointer.get_struct_record_field (| + intermediate_sets, + "halo2_proofs::poly::multiopen::shplonk::IntermediateSets", + "rotation_sets" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + intermediate_sets, + "halo2_proofs::poly::multiopen::shplonk::IntermediateSets", + "super_point_set" + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let rotation_sets := M.copy (| γ0_0 |) in + let super_point_set := M.copy (| γ0_1 |) in + let y := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ Ty.associated; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::poly::multiopen::shplonk::Y" ] + |), + [ M.read (| transcript |) ] + |) + |) in + let v := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ Ty.associated; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::poly::multiopen::shplonk::V" ] + |), + [ M.read (| transcript |) ] + |) + |) in + let h1 := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "halo2_proofs::poly::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ], + "map_err", + [ + Ty.path "halo2_proofs::poly::Error"; + Ty.function + [ Ty.tuple [ Ty.path "std::io::error::Error" ] ] + (Ty.path "halo2_proofs::poly::Error") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptRead", + T, + [ Ty.associated; E ], + "read_point", + [] + |), + [ M.read (| transcript |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::poly::Error::SamplingError" + [])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::msm::PairMSM") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::poly::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let u := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + T, + [ Ty.associated; E ], + "squeeze_challenge_scalar", + [ Ty.path "halo2_proofs::poly::multiopen::shplonk::U" ] + |), + [ M.read (| transcript |) ] + |) + |) in + let h2 := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "halo2_proofs::poly::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ], + "map_err", + [ + Ty.path "halo2_proofs::poly::Error"; + Ty.function + [ Ty.tuple [ Ty.path "std::io::error::Error" ] ] + (Ty.path "halo2_proofs::poly::Error") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptRead", + T, + [ Ty.associated; E ], + "read_point", + [] + |), + [ M.read (| transcript |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::poly::Error::SamplingError" + [])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::msm::PairMSM") + [ Ty.associated ]; + Ty.path "halo2_proofs::poly::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::poly::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "zero", + [] + |), + [] + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "zero", + [] + |), + [] + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let z_0_diff_inverse := M.copy (| γ0_0 |) in + let z_0 := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::msm::PreMSM") + [ C ], + "new", + [] + |), + [] + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "zero", + [] + |), + [] + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let outer_msm := M.copy (| γ0_0 |) in + let r_outer_acc := M.copy (| γ0_1 |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::RotationSet") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::CommitmentReference") + [ Ty.associated ] + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::RotationSet") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::CommitmentReference") + [ Ty.associated ] + ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::RotationSet") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::CommitmentReference") + [ Ty.associated ] + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::RotationSet") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::CommitmentReference") + [ Ty.associated ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ rotation_sets ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::RotationSet") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::CommitmentReference") + [ Ty.associated + ] + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let i := M.copy (| γ1_0 |) in + let rotation_set := + M.copy (| γ1_1 |) in + let diffs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::copied::Copied") + [ + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.associated + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ] + ] + ] + (Ty.path + "bool") + ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.associated + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ] + ] + ] + (Ty.path + "bool") + ], + [], + "copied", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.associated + ], + [], + "filter", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.associated + ] + ] + ] + ] + (Ty.path + "bool") + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + super_point_set + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + point := + M.copy (| + γ + |) in + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.associated + ], + "contains", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + rotation_set + |), + "halo2_proofs::poly::multiopen::shplonk::RotationSet", + "points" + |) + ] + |); + M.read (| + M.read (| + point + |) + |) + ] + |)))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |) in + let z_diff_i := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::evaluate_vanishing_polynomial", + [ Ty.associated ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "core::ops::range::RangeFull" + ], + "index", + [] + |), + [ + diffs; + Value.StructTuple + "core::ops::range::RangeFull" + [] + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::multiopen::shplonk::U" + ], + [], + "deref", + [] + |), + [ u ] + |) + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| + i + |)) + (Value.Integer + 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.write (| + z_0, + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::evaluate_vanishing_polynomial", + [ + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "core::ops::range::RangeFull" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + rotation_set + |), + "halo2_proofs::poly::multiopen::shplonk::RotationSet", + "points" + |); + Value.StructTuple + "core::ops::range::RangeFull" + [] + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::multiopen::shplonk::U" + ], + [], + "deref", + [] + |), + [ u ] + |) + |) + ] + |) + |) in + let _ := + M.write (| + z_0_diff_inverse, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "subtle::CtOption") + [ + Ty.associated + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "invert", + [] + |), + [ z_diff_i + ] + |) + ] + |) + |) in + let _ := + M.write (| + z_diff_i, + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |) + |) in + M.alloc (| + Value.Tuple [] + |))); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::MulAssign", + Ty.associated, + [ + Ty.associated + ], + "mul_assign", + [] + |), + [ + z_diff_i; + M.read (| + z_0_diff_inverse + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::msm::ProjectiveMSM") + [ C ], + "new", + [] + |), + [] + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "zero", + [] + |), + [] + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let inner_msm := + M.copy (| γ0_0 |) in + let r_inner_acc := + M.copy (| γ0_1 |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::CommitmentReference") + [ + Ty.associated + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::CommitmentReference") + [ + Ty.associated + ] + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::CommitmentReference") + [ + Ty.associated + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + rotation_set + |), + "halo2_proofs::poly::multiopen::shplonk::RotationSet", + "commitments" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::CommitmentReference") + [ + Ty.associated + ] + ] + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + commitment_data := + M.copy (| + γ0_0 + |) in + let + r_x := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::lagrange_interpolate", + [ + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "core::ops::range::RangeFull" + ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + rotation_set + |), + "halo2_proofs::poly::multiopen::shplonk::RotationSet", + "points" + |); + Value.StructTuple + "core::ops::range::RangeFull" + [] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "core::ops::range::RangeFull" + ], + "index", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::CommitmentReference") + [ + Ty.associated + ] + ], + "evals", + [] + |), + [ + M.read (| + commitment_data + |) + ] + |) + |); + Value.StructTuple + "core::ops::range::RangeFull" + [] + ] + |) + ] + |) + |) in + let + r_eval := + M.alloc (| + M.call_closure (| + M.get_function (| + "halo2_proofs::arithmetic::eval_polynomial", + [ + Ty.associated + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.associated; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "core::ops::range::RangeFull" + ], + "index", + [] + |), + [ + r_x; + Value.StructTuple + "core::ops::range::RangeFull" + [] + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::multiopen::shplonk::U" + ], + [], + "deref", + [] + |), + [ + u + ] + |) + |) + ] + |) + |) in + let + _ := + M.write (| + r_inner_acc, + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::multiopen::shplonk::Y" + ], + [], + "deref", + [] + |), + [ + y + ] + |) + |); + M.read (| + r_inner_acc + |) + ] + |); + M.read (| + r_eval + |) + ] + |) + |) in + let + inner_contrib := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::shplonk::Commitment") + [ + Ty.associated; + Ty.apply + (Ty.path + "halo2_proofs::poly::multiopen::CommitmentReference") + [ + Ty.associated + ] + ], + "get", + [] + |), + [ + M.read (| + commitment_data + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::poly::multiopen::CommitmentReference::Commitment", + 0 + |) in + let + c := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::prime::PrimeCurveAffine", + Ty.associated, + [], + "to_curve", + [] + |), + [ + M.read (| + c + |) + ] + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "halo2_proofs::poly::multiopen::CommitmentReference::MSM", + 0 + |) in + let + msm := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "group::prime::PrimeCurveAffine", + Ty.associated, + [], + "to_curve", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::msm::MSM") + [ + Ty.associated + ], + "eval", + [] + |), + [ + M.read (| + msm + |) + ] + |) + |) + ] + |) + |))) + ] + |) + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::msm::ProjectiveMSM") + [ + C + ], + "append_term", + [] + |), + [ + inner_msm; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |); + M.read (| + inner_contrib + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + let _ := + M.write (| + r_outer_acc, + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.associated, + [ + Ty.associated + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::multiopen::shplonk::V" + ], + [], + "deref", + [] + |), + [ v ] + |) + |); + M.read (| + r_outer_acc + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.associated, + [ + Ty.associated + ], + "mul", + [] + |), + [ + M.read (| + r_inner_acc + |); + M.read (| + z_diff_i + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::msm::ProjectiveMSM") + [ C ], + "combine_with_base", + [] + |), + [ + inner_msm; + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::multiopen::shplonk::Y" + ], + [], + "deref", + [] + |), + [ y ] + |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::msm::ProjectiveMSM") + [ C ], + "scale", + [] + |), + [ + inner_msm; + M.read (| + z_diff_i + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::msm::PreMSM") + [ C ], + "add_msm", + [] + |), + [ + outer_msm; + M.read (| + inner_msm + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::msm::PreMSM") + [ C ], + "combine_with_base", + [] + |), + [ + outer_msm; + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::multiopen::shplonk::V" + ], + [], + "deref", + [] + |), + [ v ] + |) + |) + ] + |) + |) in + let outer_msm := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::msm::PreMSM") + [ C ], + "normalize", + [] + |), + [ M.read (| outer_msm |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::msm::MSM") + [ Ty.associated ], + "append_term", + [] + |), + [ + outer_msm; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Neg", + Ty.associated, + [], + "neg", + [] + |), + [ M.read (| r_outer_acc |) ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| params |), + "halo2_proofs::poly::commitment::ParamsVerifier", + "g1" + |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::msm::MSM") + [ Ty.associated ], + "append_term", + [] + |), + [ + outer_msm; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Neg", + Ty.associated, + [], + "neg", + [] + |), + [ M.read (| z_0 |) ] + |); + M.read (| h1 |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::msm::MSM") + [ Ty.associated ], + "append_term", + [] + |), + [ + outer_msm; + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "halo2_proofs::transcript::ChallengeScalar") + [ + Ty.associated; + Ty.path + "halo2_proofs::poly::multiopen::shplonk::U" + ], + [], + "deref", + [] + |), + [ u ] + |) + |); + M.read (| h2 |) + ] + |) + |) in + let left := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::ParamsVerifier") + [ C ], + "empty_msm", + [] + |), + [ M.read (| params |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::msm::MSM") + [ Ty.associated ], + "append_term", + [] + |), + [ + left; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + Ty.associated, + [], + "one", + [] + |), + [] + |); + M.read (| h2 |) + ] + |) + |) in + let right := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::poly::commitment::ParamsVerifier") + [ C ], + "empty_msm", + [] + |), + [ M.read (| params |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::msm::MSM") + [ Ty.associated ], + "add_msm", + [] + |), + [ right; outer_msm ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::msm::PairMSM") + [ Ty.associated ], + "with", + [] + |), + [ M.read (| left |); M.read (| right |) ] + |) + ] + |))) + ] + |))) + ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + End verifier. + End shplonk. + End multiopen. +End poly. diff --git a/CoqOfRust/halo2_proofs/transcript.v b/CoqOfRust/halo2_proofs/transcript.v new file mode 100644 index 000000000..53ca9b022 --- /dev/null +++ b/CoqOfRust/halo2_proofs/transcript.v @@ -0,0 +1,3492 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module transcript. + Definition value_BLAKE2B_PREFIX_CHALLENGE : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 0 |))). + + Definition value_BLAKE2B_PREFIX_POINT : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 1 |))). + + Definition value_BLAKE2B_PREFIX_SCALAR : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 2 |))). + + (* Trait *) + Module Transcript. + Definition squeeze_challenge_scalar (C E Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ T ], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::transcript::ChallengeScalar" + [ + ("inner", + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::EncodedChallenge", + E, + [ C ], + "get_scalar", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + Self, + [ C; E ], + "squeeze_challenge", + [] + |), + [ M.read (| self |) ] + |) + |) + ] + |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ])) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_squeeze_challenge_scalar : + forall (C E : Ty.t), + M.IsProvidedMethod + "halo2_proofs::transcript::Transcript" + "squeeze_challenge_scalar" + (squeeze_challenge_scalar C E). + End Transcript. + + (* Trait *) + (* Empty module 'TranscriptRead' *) + + (* Trait *) + (* Empty module 'TranscriptWrite' *) + + (* StructRecord + { + name := "Blake2bRead"; + ty_params := [ "R"; "C"; "E" ]; + fields := + [ + ("state", Ty.path "blake2b_simd::State"); + ("reader", R); + ("_marker", Ty.apply (Ty.path "core::marker::PhantomData") [ Ty.tuple [ C; E ] ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_R_where_std_io_Read_R_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_E_where_halo2_proofs_transcript_EncodedChallenge_E_C_for_halo2_proofs_transcript_Blake2bRead_R_C_E. + Definition Self (R C E : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::transcript::Blake2bRead") [ R; C; E ]. + + (* Debug *) + Definition fmt (R C E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self R C E in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Blake2bRead" |); + M.read (| Value.String "state" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bRead", + "state" + |)); + M.read (| Value.String "reader" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bRead", + "reader" + |)); + M.read (| Value.String "_marker" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bRead", + "_marker" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (R C E : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self R C E) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt R C E)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_R_where_std_io_Read_R_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_E_where_halo2_proofs_transcript_EncodedChallenge_E_C_for_halo2_proofs_transcript_Blake2bRead_R_C_E. + + Module Impl_core_clone_Clone_where_core_clone_Clone_R_where_std_io_Read_R_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_clone_Clone_E_where_halo2_proofs_transcript_EncodedChallenge_E_C_for_halo2_proofs_transcript_Blake2bRead_R_C_E. + Definition Self (R C E : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::transcript::Blake2bRead") [ R; C; E ]. + + (* Clone *) + Definition clone (R C E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self R C E in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::transcript::Blake2bRead" + [ + ("state", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "blake2b_simd::State", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bRead", + "state" + |) + ] + |)); + ("reader", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", R, [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bRead", + "reader" + |) + ] + |)); + ("_marker", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ Ty.tuple [ C; E ] ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bRead", + "_marker" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (R C E : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self R C E) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone R C E)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_R_where_std_io_Read_R_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_clone_Clone_E_where_halo2_proofs_transcript_EncodedChallenge_E_C_for_halo2_proofs_transcript_Blake2bRead_R_C_E. + + Module Impl_halo2_proofs_transcript_Blake2bRead_R_C_E. + Definition Self (R C E : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::transcript::Blake2bRead") [ R; C; E ]. + + (* + pub fn init(reader: R) -> Self { + Blake2bRead { + state: Blake2bParams::new() + .hash_length(64) + .personal(b"Halo2-Transcript") + .to_state(), + reader, + _marker: PhantomData, + } + } + *) + Definition init (R C E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self R C E in + match τ, α with + | [], [ reader ] => + ltac:(M.monadic + (let reader := M.alloc (| reader |) in + Value.StructRecord + "halo2_proofs::transcript::Blake2bRead" + [ + ("state", + M.call_closure (| + M.get_associated_function (| Ty.path "blake2b_simd::Params", "to_state", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "blake2b_simd::Params", + "personal", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "blake2b_simd::Params", + "hash_length", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "blake2b_simd::Params", + "new", + [] + |), + [] + |) + |); + Value.Integer 64 + ] + |); + (* Unsize *) M.pointer_coercion (M.read (| UnsupportedLiteral |)) + ] + |) + ] + |)); + ("reader", M.read (| reader |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_init : + forall (R C E : Ty.t), + M.IsAssociatedFunction (Self R C E) "init" (init R C E). + End Impl_halo2_proofs_transcript_Blake2bRead_R_C_E. + + Module Impl_halo2_proofs_transcript_TranscriptRead_where_std_io_Read_R_where_pairing_bn256_arithmetic_curves_CurveAffine_C_C_halo2_proofs_transcript_Challenge255_C_for_halo2_proofs_transcript_Blake2bRead_R_C_halo2_proofs_transcript_Challenge255_C. + Definition Self (R C : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::transcript::Blake2bRead") + [ R; C; Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ] ]. + + (* + fn read_point(&mut self) -> io::Result { + let mut compressed = C::Repr::default(); + self.reader.read_exact(compressed.as_mut())?; + let point: C = Option::from(C::from_bytes(&compressed)).ok_or_else(|| { + io::Error::new(io::ErrorKind::Other, "invalid point encoding in proof") + })?; + self.common_point(point)?; + + Ok(point) + } + *) + Definition read_point (R C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self R C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let compressed := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.associated, + [], + "default", + [] + |), + [] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Read", R, [], "read_exact", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bRead", + "reader" + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsMut", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_mut", + [] + |), + [ compressed ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let point := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ C ], + "ok_or_else", + [ + Ty.path "std::io::error::Error"; + Ty.function [ Ty.tuple [] ] (Ty.path "std::io::error::Error") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.apply (Ty.path "core::option::Option") [ C ], + [ Ty.apply (Ty.path "subtle::CtOption") [ C ] ], + "from", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "group::GroupEncoding", + C, + [], + "from_bytes", + [] + |), + [ compressed ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.path "std::io::error::Error", + "new", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + Value.StructTuple + "std::io::error::ErrorKind::Other" + []; + M.read (| + Value.String "invalid point encoding in proof" + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + Ty.apply + (Ty.path "halo2_proofs::transcript::Blake2bRead") + [ + R; + C; + Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ] + ], + [ C; Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ] + ], + "common_point", + [] + |), + [ M.read (| self |); M.read (| point |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| point |) ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn read_scalar(&mut self) -> io::Result { + let mut data = ::Repr::default(); + self.reader.read_exact(data.as_mut())?; + let scalar: C::Scalar = Option::from(C::Scalar::from_repr(data)).ok_or_else(|| { + io::Error::new( + io::ErrorKind::Other, + "invalid field element encoding in proof", + ) + })?; + self.common_scalar(scalar)?; + + Ok(scalar) + } + *) + Definition read_scalar (R C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self R C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let data := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.associated, + [], + "default", + [] + |), + [] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "std::io::Read", R, [], "read_exact", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bRead", + "reader" + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsMut", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_mut", + [] + |), + [ data ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let scalar := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.associated ], + "ok_or_else", + [ + Ty.path "std::io::error::Error"; + Ty.function [ Ty.tuple [] ] (Ty.path "std::io::error::Error") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.apply (Ty.path "core::option::Option") [ Ty.associated ], + [ Ty.apply (Ty.path "subtle::CtOption") [ Ty.associated ] ], + "from", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::PrimeField", + Ty.associated, + [], + "from_repr", + [] + |), + [ M.read (| data |) ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.path "std::io::error::Error", + "new", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + Value.StructTuple + "std::io::error::ErrorKind::Other" + []; + M.read (| + Value.String + "invalid field element encoding in proof" + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + Ty.apply + (Ty.path "halo2_proofs::transcript::Blake2bRead") + [ + R; + C; + Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ] + ], + [ C; Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ] + ], + "common_scalar", + [] + |), + [ M.read (| self |); M.read (| scalar |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| scalar |) ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (R C : Ty.t), + M.IsTraitInstance + "halo2_proofs::transcript::TranscriptRead" + (Self R C) + (* Trait polymorphic types *) + [ (* C *) C; (* E *) Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ] ] + (* Instance *) + [ + ("read_point", InstanceField.Method (read_point R C)); + ("read_scalar", InstanceField.Method (read_scalar R C)) + ]. + End Impl_halo2_proofs_transcript_TranscriptRead_where_std_io_Read_R_where_pairing_bn256_arithmetic_curves_CurveAffine_C_C_halo2_proofs_transcript_Challenge255_C_for_halo2_proofs_transcript_Blake2bRead_R_C_halo2_proofs_transcript_Challenge255_C. + + Module Impl_halo2_proofs_transcript_Transcript_where_std_io_Read_R_where_pairing_bn256_arithmetic_curves_CurveAffine_C_C_halo2_proofs_transcript_Challenge255_C_for_halo2_proofs_transcript_Blake2bRead_R_C_halo2_proofs_transcript_Challenge255_C. + Definition Self (R C : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::transcript::Blake2bRead") + [ R; C; Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ] ]. + + (* + fn squeeze_challenge(&mut self) -> Challenge255 { + self.state.update(&[BLAKE2B_PREFIX_CHALLENGE]); + let hasher = self.state.clone(); + let result: [u8; 64] = hasher.finalize().as_bytes().try_into().unwrap(); + Challenge255::::new(&result) + } + *) + Definition squeeze_challenge (R C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self R C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "blake2b_simd::State", "update", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bRead", + "state" + |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + M.get_constant (| + "halo2_proofs::transcript::BLAKE2B_PREFIX_CHALLENGE" + |) + |) + ] + |)) + ] + |) + |) in + let hasher := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "blake2b_simd::State", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bRead", + "state" + |) + ] + |) + |) in + let result := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "array") [ Ty.path "u8" ]; + Ty.path "core::array::TryFromSliceError" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::TryInto", + Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + [ Ty.apply (Ty.path "array") [ Ty.path "u8" ] ], + "try_into", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "blake2b_simd::Hash", + "as_bytes", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "blake2b_simd::State", + "finalize", + [] + |), + [ hasher ] + |) + |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::EncodedChallenge", + Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ], + [ C ], + "new", + [] + |), + [ result ] + |) + |) + |))) + | _, _ => M.impossible + end. + + (* + fn common_point(&mut self, point: C) -> io::Result<()> { + self.state.update(&[BLAKE2B_PREFIX_POINT]); + let coords: Coordinates = Option::from(point.coordinates()).ok_or_else(|| { + io::Error::new( + io::ErrorKind::Other, + "cannot write points at infinity to the transcript", + ) + })?; + coords.x().write(&mut self.state)?; + coords.y().write(&mut self.state)?; + + Ok(()) + } + *) + Definition common_point (R C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self R C in + match τ, α with + | [], [ self; point ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let point := M.alloc (| point |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "blake2b_simd::State", "update", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bRead", + "state" + |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + M.get_constant (| + "halo2_proofs::transcript::BLAKE2B_PREFIX_POINT" + |) + |) + ] + |)) + ] + |) + |) in + let coords := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "pairing_bn256::arithmetic::curves::Coordinates") + [ C ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "pairing_bn256::arithmetic::curves::Coordinates") + [ C ] + ], + "ok_or_else", + [ + Ty.path "std::io::error::Error"; + Ty.function [ Ty.tuple [] ] (Ty.path "std::io::error::Error") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "pairing_bn256::arithmetic::curves::Coordinates") + [ C ] + ], + [ + Ty.apply + (Ty.path "subtle::CtOption") + [ + Ty.apply + (Ty.path + "pairing_bn256::arithmetic::curves::Coordinates") + [ C ] + ] + ], + "from", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::curves::CurveAffine", + C, + [], + "coordinates", + [] + |), + [ point ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.path "std::io::error::Error", + "new", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + Value.StructTuple + "std::io::error::ErrorKind::Other" + []; + M.read (| + Value.String + "cannot write points at infinity to the transcript" + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::fields::BaseExt", + Ty.associated, + [], + "write", + [ Ty.path "blake2b_simd::State" ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "pairing_bn256::arithmetic::curves::Coordinates") + [ C ], + "x", + [] + |), + [ coords ] + |); + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bRead", + "state" + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::fields::BaseExt", + Ty.associated, + [], + "write", + [ Ty.path "blake2b_simd::State" ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "pairing_bn256::arithmetic::curves::Coordinates") + [ C ], + "y", + [] + |), + [ coords ] + |); + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bRead", + "state" + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn common_scalar(&mut self, scalar: C::Scalar) -> io::Result<()> { + self.state.update(&[BLAKE2B_PREFIX_SCALAR]); + self.state.update(scalar.to_repr().as_ref()); + + Ok(()) + } + *) + Definition common_scalar (R C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self R C in + match τ, α with + | [], [ self; scalar ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let scalar := M.alloc (| scalar |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "blake2b_simd::State", "update", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bRead", + "state" + |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + M.get_constant (| "halo2_proofs::transcript::BLAKE2B_PREFIX_SCALAR" |) + |) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "blake2b_simd::State", "update", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bRead", + "state" + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::PrimeField", + Ty.associated, + [], + "to_repr", + [] + |), + [ scalar ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (R C : Ty.t), + M.IsTraitInstance + "halo2_proofs::transcript::Transcript" + (Self R C) + (* Trait polymorphic types *) + [ (* C *) C; (* E *) Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ] ] + (* Instance *) + [ + ("squeeze_challenge", InstanceField.Method (squeeze_challenge R C)); + ("common_point", InstanceField.Method (common_point R C)); + ("common_scalar", InstanceField.Method (common_scalar R C)) + ]. + End Impl_halo2_proofs_transcript_Transcript_where_std_io_Read_R_where_pairing_bn256_arithmetic_curves_CurveAffine_C_C_halo2_proofs_transcript_Challenge255_C_for_halo2_proofs_transcript_Blake2bRead_R_C_halo2_proofs_transcript_Challenge255_C. + + (* StructRecord + { + name := "Blake2bWrite"; + ty_params := [ "W"; "C"; "E" ]; + fields := + [ + ("state", Ty.path "blake2b_simd::State"); + ("writer", W); + ("_marker", Ty.apply (Ty.path "core::marker::PhantomData") [ Ty.tuple [ C; E ] ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_W_where_std_io_Write_W_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_E_where_halo2_proofs_transcript_EncodedChallenge_E_C_for_halo2_proofs_transcript_Blake2bWrite_W_C_E. + Definition Self (W C E : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::transcript::Blake2bWrite") [ W; C; E ]. + + (* Debug *) + Definition fmt (W C E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self W C E in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Blake2bWrite" |); + M.read (| Value.String "state" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bWrite", + "state" + |)); + M.read (| Value.String "writer" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bWrite", + "writer" + |)); + M.read (| Value.String "_marker" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bWrite", + "_marker" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (W C E : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self W C E) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt W C E)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_W_where_std_io_Write_W_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_E_where_halo2_proofs_transcript_EncodedChallenge_E_C_for_halo2_proofs_transcript_Blake2bWrite_W_C_E. + + Module Impl_core_clone_Clone_where_core_clone_Clone_W_where_std_io_Write_W_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_clone_Clone_E_where_halo2_proofs_transcript_EncodedChallenge_E_C_for_halo2_proofs_transcript_Blake2bWrite_W_C_E. + Definition Self (W C E : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::transcript::Blake2bWrite") [ W; C; E ]. + + (* Clone *) + Definition clone (W C E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self W C E in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::transcript::Blake2bWrite" + [ + ("state", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "blake2b_simd::State", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bWrite", + "state" + |) + ] + |)); + ("writer", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", W, [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bWrite", + "writer" + |) + ] + |)); + ("_marker", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ Ty.tuple [ C; E ] ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bWrite", + "_marker" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (W C E : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self W C E) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone W C E)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_W_where_std_io_Write_W_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_clone_Clone_E_where_halo2_proofs_transcript_EncodedChallenge_E_C_for_halo2_proofs_transcript_Blake2bWrite_W_C_E. + + Module Impl_halo2_proofs_transcript_Blake2bWrite_W_C_E. + Definition Self (W C E : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::transcript::Blake2bWrite") [ W; C; E ]. + + (* + pub fn init(writer: W) -> Self { + Blake2bWrite { + state: Blake2bParams::new() + .hash_length(64) + .personal(b"Halo2-Transcript") + .to_state(), + writer, + _marker: PhantomData, + } + } + *) + Definition init (W C E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self W C E in + match τ, α with + | [], [ writer ] => + ltac:(M.monadic + (let writer := M.alloc (| writer |) in + Value.StructRecord + "halo2_proofs::transcript::Blake2bWrite" + [ + ("state", + M.call_closure (| + M.get_associated_function (| Ty.path "blake2b_simd::Params", "to_state", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "blake2b_simd::Params", + "personal", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "blake2b_simd::Params", + "hash_length", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "blake2b_simd::Params", + "new", + [] + |), + [] + |) + |); + Value.Integer 64 + ] + |); + (* Unsize *) M.pointer_coercion (M.read (| UnsupportedLiteral |)) + ] + |) + ] + |)); + ("writer", M.read (| writer |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_init : + forall (W C E : Ty.t), + M.IsAssociatedFunction (Self W C E) "init" (init W C E). + + (* + pub fn finalize(self) -> W { + // TODO: handle outstanding scalars? see issue #138 + self.writer + } + *) + Definition finalize (W C E : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self W C E in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "halo2_proofs::transcript::Blake2bWrite", + "writer" + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_finalize : + forall (W C E : Ty.t), + M.IsAssociatedFunction (Self W C E) "finalize" (finalize W C E). + End Impl_halo2_proofs_transcript_Blake2bWrite_W_C_E. + + Module Impl_halo2_proofs_transcript_TranscriptWrite_where_std_io_Write_W_where_pairing_bn256_arithmetic_curves_CurveAffine_C_C_halo2_proofs_transcript_Challenge255_C_for_halo2_proofs_transcript_Blake2bWrite_W_C_halo2_proofs_transcript_Challenge255_C. + Definition Self (W C : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::transcript::Blake2bWrite") + [ W; C; Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ] ]. + + (* + fn write_point(&mut self, point: C) -> io::Result<()> { + self.common_point(point)?; + let compressed = point.to_bytes(); + self.writer.write_all(compressed.as_ref()) + } + *) + Definition write_point (W C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self W C in + match τ, α with + | [], [ self; point ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let point := M.alloc (| point |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + Ty.apply + (Ty.path "halo2_proofs::transcript::Blake2bWrite") + [ + W; + C; + Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ] + ], + [ C; Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ] + ], + "common_point", + [] + |), + [ M.read (| self |); M.read (| point |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let compressed := + M.alloc (| + M.call_closure (| + M.get_trait_method (| "group::GroupEncoding", C, [], "to_bytes", [] |), + [ point ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write_all", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bWrite", + "writer" + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_ref", + [] + |), + [ compressed ] + |) + ] + |) + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn write_scalar(&mut self, scalar: C::Scalar) -> io::Result<()> { + self.common_scalar(scalar)?; + let data = scalar.to_repr(); + self.writer.write_all(data.as_ref()) + } + *) + Definition write_scalar (W C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self W C in + match τ, α with + | [], [ self; scalar ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let scalar := M.alloc (| scalar |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::Transcript", + Ty.apply + (Ty.path "halo2_proofs::transcript::Blake2bWrite") + [ + W; + C; + Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ] + ], + [ C; Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ] + ], + "common_scalar", + [] + |), + [ M.read (| self |); M.read (| scalar |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let data := + M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::PrimeField", Ty.associated, [], "to_repr", [] |), + [ scalar ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "std::io::Write", W, [], "write_all", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bWrite", + "writer" + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_ref", + [] + |), + [ data ] + |) + ] + |) + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (W C : Ty.t), + M.IsTraitInstance + "halo2_proofs::transcript::TranscriptWrite" + (Self W C) + (* Trait polymorphic types *) + [ (* C *) C; (* E *) Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ] ] + (* Instance *) + [ + ("write_point", InstanceField.Method (write_point W C)); + ("write_scalar", InstanceField.Method (write_scalar W C)) + ]. + End Impl_halo2_proofs_transcript_TranscriptWrite_where_std_io_Write_W_where_pairing_bn256_arithmetic_curves_CurveAffine_C_C_halo2_proofs_transcript_Challenge255_C_for_halo2_proofs_transcript_Blake2bWrite_W_C_halo2_proofs_transcript_Challenge255_C. + + Module Impl_halo2_proofs_transcript_Transcript_where_std_io_Write_W_where_pairing_bn256_arithmetic_curves_CurveAffine_C_C_halo2_proofs_transcript_Challenge255_C_for_halo2_proofs_transcript_Blake2bWrite_W_C_halo2_proofs_transcript_Challenge255_C. + Definition Self (W C : Ty.t) : Ty.t := + Ty.apply + (Ty.path "halo2_proofs::transcript::Blake2bWrite") + [ W; C; Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ] ]. + + (* + fn squeeze_challenge(&mut self) -> Challenge255 { + self.state.update(&[BLAKE2B_PREFIX_CHALLENGE]); + let hasher = self.state.clone(); + let result: [u8; 64] = hasher.finalize().as_bytes().try_into().unwrap(); + Challenge255::::new(&result) + } + *) + Definition squeeze_challenge (W C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self W C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "blake2b_simd::State", "update", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bWrite", + "state" + |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + M.get_constant (| + "halo2_proofs::transcript::BLAKE2B_PREFIX_CHALLENGE" + |) + |) + ] + |)) + ] + |) + |) in + let hasher := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "blake2b_simd::State", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bWrite", + "state" + |) + ] + |) + |) in + let result := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "array") [ Ty.path "u8" ]; + Ty.path "core::array::TryFromSliceError" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::TryInto", + Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + [ Ty.apply (Ty.path "array") [ Ty.path "u8" ] ], + "try_into", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "blake2b_simd::Hash", + "as_bytes", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "blake2b_simd::State", + "finalize", + [] + |), + [ hasher ] + |) + |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::EncodedChallenge", + Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ], + [ C ], + "new", + [] + |), + [ result ] + |) + |) + |))) + | _, _ => M.impossible + end. + + (* + fn common_point(&mut self, point: C) -> io::Result<()> { + self.state.update(&[BLAKE2B_PREFIX_POINT]); + let coords: Coordinates = Option::from(point.coordinates()).ok_or_else(|| { + io::Error::new( + io::ErrorKind::Other, + "cannot write points at infinity to the transcript", + ) + })?; + coords.x().write(&mut self.state)?; + coords.y().write(&mut self.state)?; + + Ok(()) + } + *) + Definition common_point (W C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self W C in + match τ, α with + | [], [ self; point ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let point := M.alloc (| point |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "blake2b_simd::State", "update", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bWrite", + "state" + |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + M.get_constant (| + "halo2_proofs::transcript::BLAKE2B_PREFIX_POINT" + |) + |) + ] + |)) + ] + |) + |) in + let coords := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "pairing_bn256::arithmetic::curves::Coordinates") + [ C ]; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "pairing_bn256::arithmetic::curves::Coordinates") + [ C ] + ], + "ok_or_else", + [ + Ty.path "std::io::error::Error"; + Ty.function [ Ty.tuple [] ] (Ty.path "std::io::error::Error") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "pairing_bn256::arithmetic::curves::Coordinates") + [ C ] + ], + [ + Ty.apply + (Ty.path "subtle::CtOption") + [ + Ty.apply + (Ty.path + "pairing_bn256::arithmetic::curves::Coordinates") + [ C ] + ] + ], + "from", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::curves::CurveAffine", + C, + [], + "coordinates", + [] + |), + [ point ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.path "std::io::error::Error", + "new", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + Value.StructTuple + "std::io::error::ErrorKind::Other" + []; + M.read (| + Value.String + "cannot write points at infinity to the transcript" + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::fields::BaseExt", + Ty.associated, + [], + "write", + [ Ty.path "blake2b_simd::State" ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "pairing_bn256::arithmetic::curves::Coordinates") + [ C ], + "x", + [] + |), + [ coords ] + |); + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bWrite", + "state" + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::fields::BaseExt", + Ty.associated, + [], + "write", + [ Ty.path "blake2b_simd::State" ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "pairing_bn256::arithmetic::curves::Coordinates") + [ C ], + "y", + [] + |), + [ coords ] + |); + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bWrite", + "state" + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn common_scalar(&mut self, scalar: C::Scalar) -> io::Result<()> { + self.state.update(&[BLAKE2B_PREFIX_SCALAR]); + self.state.update(scalar.to_repr().as_ref()); + + Ok(()) + } + *) + Definition common_scalar (W C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self W C in + match τ, α with + | [], [ self; scalar ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let scalar := M.alloc (| scalar |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "blake2b_simd::State", "update", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bWrite", + "state" + |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + M.get_constant (| "halo2_proofs::transcript::BLAKE2B_PREFIX_SCALAR" |) + |) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "blake2b_simd::State", "update", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::Blake2bWrite", + "state" + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::PrimeField", + Ty.associated, + [], + "to_repr", + [] + |), + [ scalar ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (W C : Ty.t), + M.IsTraitInstance + "halo2_proofs::transcript::Transcript" + (Self W C) + (* Trait polymorphic types *) + [ (* C *) C; (* E *) Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ] ] + (* Instance *) + [ + ("squeeze_challenge", InstanceField.Method (squeeze_challenge W C)); + ("common_point", InstanceField.Method (common_point W C)); + ("common_scalar", InstanceField.Method (common_scalar W C)) + ]. + End Impl_halo2_proofs_transcript_Transcript_where_std_io_Write_W_where_pairing_bn256_arithmetic_curves_CurveAffine_C_C_halo2_proofs_transcript_Challenge255_C_for_halo2_proofs_transcript_Blake2bWrite_W_C_halo2_proofs_transcript_Challenge255_C. + + (* StructRecord + { + name := "ChallengeScalar"; + ty_params := [ "C"; "T" ]; + fields := + [ + ("inner", Ty.associated); + ("_marker", Ty.apply (Ty.path "core::marker::PhantomData") [ T ]) + ]; + } *) + + Module Impl_core_marker_Copy_where_core_marker_Copy_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_marker_Copy_T_where_core_marker_Copy_associated_type_for_halo2_proofs_transcript_ChallengeScalar_C_T. + Definition Self (C T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::transcript::ChallengeScalar") [ C; T ]. + + Axiom Implements : + forall (C T : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self C T) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_marker_Copy_T_where_core_marker_Copy_associated_type_for_halo2_proofs_transcript_ChallengeScalar_C_T. + + Module Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_clone_Clone_T_where_core_clone_Clone_associated_type_for_halo2_proofs_transcript_ChallengeScalar_C_T. + Definition Self (C T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::transcript::ChallengeScalar") [ C; T ]. + + (* Clone *) + Definition clone (C T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C T in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::transcript::ChallengeScalar" + [ + ("inner", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.associated, [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::ChallengeScalar", + "inner" + |) + ] + |)); + ("_marker", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ T ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::ChallengeScalar", + "_marker" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C T : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self C T) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone C T)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_clone_Clone_T_where_core_clone_Clone_associated_type_for_halo2_proofs_transcript_ChallengeScalar_C_T. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_T_where_core_fmt_Debug_associated_type_for_halo2_proofs_transcript_ChallengeScalar_C_T. + Definition Self (C T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::transcript::ChallengeScalar") [ C; T ]. + + (* Debug *) + Definition fmt (C T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C T in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "ChallengeScalar" |); + M.read (| Value.String "inner" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::ChallengeScalar", + "inner" + |)); + M.read (| Value.String "_marker" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::ChallengeScalar", + "_marker" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C T : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C T) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C T)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_where_core_fmt_Debug_T_where_core_fmt_Debug_associated_type_for_halo2_proofs_transcript_ChallengeScalar_C_T. + + Module Impl_core_ops_deref_Deref_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_transcript_ChallengeScalar_C_T. + Definition Self (C T : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::transcript::ChallengeScalar") [ C; T ]. + + (* type Target = C::Scalar; *) + Definition _Target (C T : Ty.t) : Ty.t := Ty.associated. + + (* + fn deref(&self) -> &Self::Target { + &self.inner + } + *) + Definition deref (C T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C T in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "halo2_proofs::transcript::ChallengeScalar", + "inner" + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C T : Ty.t), + M.IsTraitInstance + "core::ops::deref::Deref" + (Self C T) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("Target", InstanceField.Ty (_Target C T)); ("deref", InstanceField.Method (deref C T)) ]. + End Impl_core_ops_deref_Deref_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_transcript_ChallengeScalar_C_T. + + (* Trait *) + Module EncodedChallenge. + Definition as_challenge_scalar (C Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ T ], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "halo2_proofs::transcript::ChallengeScalar" + [ + ("inner", + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::EncodedChallenge", + Self, + [ C ], + "get_scalar", + [] + |), + [ M.read (| self |) ] + |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ])) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_as_challenge_scalar : + forall (C : Ty.t), + M.IsProvidedMethod + "halo2_proofs::transcript::EncodedChallenge" + "as_challenge_scalar" + (as_challenge_scalar C). + End EncodedChallenge. + + (* StructTuple + { + name := "Challenge255"; + ty_params := [ "C" ]; + fields := + [ + Ty.apply (Ty.path "array") [ Ty.path "u8" ]; + Ty.apply (Ty.path "core::marker::PhantomData") [ C ] + ]; + } *) + + Module Impl_core_marker_Copy_where_core_marker_Copy_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_transcript_Challenge255_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ]. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_transcript_Challenge255_C. + + Module Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_transcript_Challenge255_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ]. + + (* Clone *) + Definition clone (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructTuple + "halo2_proofs::transcript::Challenge255" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "array") [ Ty.path "u8" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::transcript::Challenge255", + 0 + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ C ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::transcript::Challenge255", + 1 + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone C)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_transcript_Challenge255_C. + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_transcript_Challenge255_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ]. + + (* Debug *) + Definition fmt (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Challenge255" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::transcript::Challenge255", + 0 + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::transcript::Challenge255", + 1 + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt C)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_C_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_transcript_Challenge255_C. + + Module Impl_core_ops_deref_Deref_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_transcript_Challenge255_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ]. + + (* type Target = [u8; 32]; *) + Definition _Target (C : Ty.t) : Ty.t := Ty.apply (Ty.path "array") [ Ty.path "u8" ]. + + (* + fn deref(&self) -> &Self::Target { + &self.0 + } + *) + Definition deref (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::transcript::Challenge255", + 0 + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "core::ops::deref::Deref" + (Self C) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("Target", InstanceField.Ty (_Target C)); ("deref", InstanceField.Method (deref C)) ]. + End Impl_core_ops_deref_Deref_where_pairing_bn256_arithmetic_curves_CurveAffine_C_for_halo2_proofs_transcript_Challenge255_C. + + Module Impl_halo2_proofs_transcript_EncodedChallenge_where_pairing_bn256_arithmetic_curves_CurveAffine_C_C_for_halo2_proofs_transcript_Challenge255_C. + Definition Self (C : Ty.t) : Ty.t := + Ty.apply (Ty.path "halo2_proofs::transcript::Challenge255") [ C ]. + + (* type Input = [u8; 64]; *) + Definition _Input (C : Ty.t) : Ty.t := Ty.apply (Ty.path "array") [ Ty.path "u8" ]. + + (* + fn new(challenge_input: &[u8; 64]) -> Self { + Challenge255( + C::Scalar::from_bytes_wide(challenge_input) + .to_repr() + .as_ref() + .try_into() + .expect("Scalar fits into 256 bits"), + PhantomData, + ) + } + *) + Definition new (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ challenge_input ] => + ltac:(M.monadic + (let challenge_input := M.alloc (| challenge_input |) in + Value.StructTuple + "halo2_proofs::transcript::Challenge255" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "array") [ Ty.path "u8" ]; + Ty.path "core::array::TryFromSliceError" + ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::TryInto", + Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + [ Ty.apply (Ty.path "array") [ Ty.path "u8" ] ], + "try_into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_ref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::PrimeField", + Ty.associated, + [], + "to_repr", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::fields::BaseExt", + Ty.associated, + [], + "from_bytes_wide", + [] + |), + [ M.read (| challenge_input |) ] + |) + |) + ] + |) + |) + ] + |) + ] + |); + M.read (| Value.String "Scalar fits into 256 bits" |) + ] + |); + Value.StructTuple "core::marker::PhantomData" [] + ])) + | _, _ => M.impossible + end. + + (* + fn get_scalar(&self) -> C::Scalar { + let mut repr = ::Repr::default(); + repr.as_mut().copy_from_slice(&self.0); + C::Scalar::from_repr(repr).unwrap() + } + *) + Definition get_scalar (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let repr := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.associated, + [], + "default", + [] + |), + [] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u8" ], + "copy_from_slice", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::AsMut", + Ty.associated, + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ], + "as_mut", + [] + |), + [ repr ] + |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "halo2_proofs::transcript::Challenge255", + 0 + |)) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "subtle::CtOption") [ Ty.associated ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "ff::PrimeField", Ty.associated, [], "from_repr", [] |), + [ M.read (| repr |) ] + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "halo2_proofs::transcript::EncodedChallenge" + (Self C) + (* Trait polymorphic types *) [ (* C *) C ] + (* Instance *) + [ + ("Input", InstanceField.Ty (_Input C)); + ("new", InstanceField.Method (new C)); + ("get_scalar", InstanceField.Method (get_scalar C)) + ]. + End Impl_halo2_proofs_transcript_EncodedChallenge_where_pairing_bn256_arithmetic_curves_CurveAffine_C_C_for_halo2_proofs_transcript_Challenge255_C. + + (* + pub fn read_n_points, T: TranscriptRead>( + transcript: &mut T, + n: usize, + ) -> io::Result> { + (0..n).map(|_| transcript.read_point()).collect() + } + *) + Definition read_n_points (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; E; T ], [ transcript; n ] => + ltac:(M.monadic + (let transcript := M.alloc (| transcript |) in + let n := M.alloc (| n |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply (Ty.path "core::result::Result") [ C; Ty.path "std::io::error::Error" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "map", + [ + Ty.apply (Ty.path "core::result::Result") [ C; Ty.path "std::io::error::Error" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ C; Ty.path "std::io::error::Error" ]) + ] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| n |)) ]; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptRead", + T, + [ C; E ], + "read_point", + [] + |), + [ M.read (| transcript |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + pub fn read_n_scalars, T: TranscriptRead>( + transcript: &mut T, + n: usize, + ) -> io::Result> { + (0..n).map(|_| transcript.read_scalar()).collect() + } + *) + Definition read_n_scalars (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C; E; T ], [ transcript; n ] => + ltac:(M.monadic + (let transcript := M.alloc (| transcript |) in + let n := M.alloc (| n |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ]; + Ty.path "std::io::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "map", + [ + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ]; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.path "std::io::error::Error" ]) + ] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| n |)) ]; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "halo2_proofs::transcript::TranscriptRead", + T, + [ C; E ], + "read_scalar", + [] + |), + [ M.read (| transcript |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + | _, _ => M.impossible + end. +End transcript. diff --git a/CoqOfRust/simulations/M.v b/CoqOfRust/simulations/M.v index ec9a4a5b2..4c0d0a826 100644 --- a/CoqOfRust/simulations/M.v +++ b/CoqOfRust/simulations/M.v @@ -196,6 +196,14 @@ End SubPointer. (** ** Monads that are useful for the definition of simulations. *) +Module Lens. + Record t {Big_A A : Set} : Set := { + read : Big_A -> A; + write : Big_A -> A -> Big_A + }. + Arguments t : clear implicits. +End Lens. + Module Error. Definition t (Error A : Set) : Set := A + Error. @@ -235,6 +243,14 @@ Module StateError. Definition lift_from_error {State Error A : Set} (value : Error.t Error A) : t State Error A := fun state => (value, state). + + Definition lift_lens {Big_State State Error A : Set} + (lens : Lens.t Big_State State) + (value : t State Error A) : + t Big_State Error A := + fun big_state => + let (value, state) := value (lens.(Lens.read) big_state) in + (value, lens.(Lens.write) big_state state). End StateError. Module Notations. diff --git a/CoqOfRust/zkWasm/checksum/mod.v b/CoqOfRust/zkWasm/checksum/mod.v new file mode 100644 index 000000000..2dc44094f --- /dev/null +++ b/CoqOfRust/zkWasm/checksum/mod.v @@ -0,0 +1,302 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module checksum. + (* Trait *) + (* Empty module 'ImageCheckSum' *) + + Module Impl_delphinus_zkwasm_checksum_ImageCheckSum_where_pairing_bn256_arithmetic_curves_CurveAffine_C_C_alloc_vec_Vec_C_alloc_alloc_Global_for_specs_CompilationTable. + Definition Self (C : Ty.t) : Ty.t := Ty.path "specs::CompilationTable". + + (* + fn checksum(&self, k: u32, params: &Params) -> Vec { + let cells = encode_compilation_table_values( + k, + &self.itable, + &self.br_table, + &self.elem_table, + &self.static_jtable, + &self.initialization_state, + &self.imtable, + ) + .plain(); + + let c = best_multiexp_gpu_cond(&cells[..], ¶ms.get_g_lagrange()[0..cells.len()]); + vec![c.into()] + } + *) + Definition checksum (C : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self C in + match τ, α with + | [], [ self; k; params ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let k := M.alloc (| k |) in + let params := M.alloc (| params |) in + M.read (| + let cells := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ Ty.associated ], + "plain", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::image_table::encode_compilation_table_values", + [ Ty.associated ] + |), + [ + M.read (| k |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::itable::InstructionTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::CompilationTable", + "itable" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ Ty.path "specs::brtable::BrTable"; Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::CompilationTable", + "br_table" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::brtable::ElemTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::CompilationTable", + "elem_table" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::jtable::StaticFrameEntry" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::CompilationTable", + "static_jtable" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ Ty.path "u32"; Ty.path "num_bigint::biguint::BigUint" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::CompilationTable", + "initialization_state" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::imtable::InitMemoryTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::CompilationTable", + "imtable" + |) + ] + |) + ] + |) + |) + ] + |) + |) in + let c := + M.alloc (| + M.call_closure (| + M.get_function (| "halo2_proofs::arithmetic::best_multiexp_gpu_cond", [ C ] |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index", + [] + |), + [ cells; Value.StructTuple "core::ops::range::RangeFull" [] ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ], + [ Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ] ], + "index", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::poly::commitment::Params") [ C ], + "get_g_lagrange", + [] + |), + [ M.read (| params |) ] + |); + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ cells ] + |)) + ] + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ C ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ Ty.apply (Ty.path "array") [ C ]; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.associated, + [ C ], + "into", + [] + |), + [ M.read (| c |) ] + |) + ] + |) + ] + |) + |)) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (C : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::checksum::ImageCheckSum" + (Self C) + (* Trait polymorphic types *) + [ + (* C *) C; + (* Output *) Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ] + ] + (* Instance *) [ ("checksum", InstanceField.Method (checksum C)) ]. + End Impl_delphinus_zkwasm_checksum_ImageCheckSum_where_pairing_bn256_arithmetic_curves_CurveAffine_C_C_alloc_vec_Vec_C_alloc_alloc_Global_for_specs_CompilationTable. +End checksum. diff --git a/CoqOfRust/zkWasm/circuits/bit_table/assign.v b/CoqOfRust/zkWasm/circuits/bit_table/assign.v new file mode 100644 index 000000000..4aee69abf --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/bit_table/assign.v @@ -0,0 +1,5487 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module bit_table. + Module assign. + (* StructRecord + { + name := "BitTableAssign"; + ty_params := []; + fields := + [ + ("op", Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableOp"); + ("left", Ty.path "u64"); + ("right", Ty.path "u64"); + ("result", Ty.path "u64") + ]; + } *) + + Module Impl_delphinus_zkwasm_circuits_bit_table_BitTableTrait_for_delphinus_zkwasm_circuits_utils_table_entry_EventTableWithMemoryInfo. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::utils::table_entry::EventTableWithMemoryInfo". + + (* + fn filter_bit_table_entries(&self) -> Vec { + self.0 + .iter() + .filter_map(|entry| match &entry.eentry.step_info { + StepInfo::I32BinBitOp { + class, + left, + right, + value, + } => Some(BitTableAssign { + op: BitTableOp::BinaryBit( *class), + left: *left as u32 as u64, + right: *right as u32 as u64, + result: *value as u32 as u64, + }), + + StepInfo::I64BinBitOp { + class, + left, + right, + value, + } => Some(BitTableAssign { + op: BitTableOp::BinaryBit( *class), + left: *left as u64, + right: *right as u64, + result: *value as u64, + }), + + StepInfo::UnaryOp { + class: UnaryOp::Popcnt, + operand, + result, + .. + } => Some(BitTableAssign { + op: BitTableOp::Popcnt, + left: *operand, + right: 0, + result: *result, + }), + + _ => None, + }) + .collect::>() + } + *) + Definition filter_bit_table_entries (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "delphinus_zkwasm::circuits::bit_table::assign::BitTableAssign" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "delphinus_zkwasm::circuits::bit_table::assign::BitTableAssign"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo" + ], + [], + "filter_map", + [ + Ty.path "delphinus_zkwasm::circuits::bit_table::assign::BitTableAssign"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo" + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::circuits::bit_table::assign::BitTableAssign" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableWithMemoryInfo", + 0 + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let entry := M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinBitOp", + "class" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinBitOp", + "left" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinBitOp", + "right" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinBitOp", + "value" + |) in + let class := M.alloc (| γ1_0 |) in + let left := M.alloc (| γ1_1 |) in + let right := M.alloc (| γ1_2 |) in + let value := M.alloc (| γ1_3 |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::circuits::bit_table::assign::BitTableAssign" + [ + ("op", + Value.StructTuple + "delphinus_zkwasm::circuits::bit_table::BitTableOp::BinaryBit" + [ M.read (| M.read (| class |) |) ]); + ("left", + M.rust_cast + (M.rust_cast + (M.read (| M.read (| left |) |)))); + ("right", + M.rust_cast + (M.rust_cast + (M.read (| M.read (| right |) |)))); + ("result", + M.rust_cast + (M.rust_cast + (M.read (| M.read (| value |) |)))) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinBitOp", + "class" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinBitOp", + "left" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinBitOp", + "right" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinBitOp", + "value" + |) in + let class := M.alloc (| γ1_0 |) in + let left := M.alloc (| γ1_1 |) in + let right := M.alloc (| γ1_2 |) in + let value := M.alloc (| γ1_3 |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::circuits::bit_table::assign::BitTableAssign" + [ + ("op", + Value.StructTuple + "delphinus_zkwasm::circuits::bit_table::BitTableOp::BinaryBit" + [ M.read (| M.read (| class |) |) ]); + ("left", + M.rust_cast + (M.read (| M.read (| left |) |))); + ("right", + M.rust_cast + (M.read (| M.read (| right |) |))); + ("result", + M.rust_cast + (M.read (| M.read (| value |) |))) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::UnaryOp", + "class" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::UnaryOp", + "operand" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::UnaryOp", + "result" + |) in + let operand := M.alloc (| γ1_1 |) in + let result := M.alloc (| γ1_2 |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::circuits::bit_table::assign::BitTableAssign" + [ + ("op", + Value.StructTuple + "delphinus_zkwasm::circuits::bit_table::BitTableOp::Popcnt" + []); + ("left", + M.read (| M.read (| operand |) |)); + ("right", Value.Integer 0); + ("result", + M.read (| M.read (| result |) |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple "core::option::Option::None" [] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "delphinus_zkwasm::circuits::bit_table::BitTableTrait" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("filter_bit_table_entries", InstanceField.Method filter_bit_table_entries) ]. + End Impl_delphinus_zkwasm_circuits_bit_table_BitTableTrait_for_delphinus_zkwasm_circuits_utils_table_entry_EventTableWithMemoryInfo. + + Module Impl_delphinus_zkwasm_circuits_bit_table_BitTableChip_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableChip") [ F ]. + + (* + fn init(&self, ctx: &mut Context<'_, F>) -> Result<(), Error> { + for _ in 0..self.max_available_rows / STEP_SIZE { + ctx.region.assign_fixed( + || "bit table: block sel", + self.config.block_sel, + ctx.offset + BLOCK_SEL_OFFSET, + || Ok(F::one()), + )?; + + for i in U8_OFFSET { + ctx.region.assign_fixed( + || "bit table: lookup sel", + self.config.lookup_sel, + ctx.offset + i, + || Ok(F::one()), + )?; + } + + for i in U32_OFFSET { + ctx.region.assign_fixed( + || "bit table: u32 sel", + self.config.u32_sel, + ctx.offset + i, + || Ok(F::one()), + )?; + } + + ctx.step(STEP_SIZE); + } + + Ok(()) + } + *) + Definition init (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + BinOp.Panic.div (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableChip", + "max_available_rows" + |) + |), + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::bit_table::STEP_SIZE" + |) + |) + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_fixed", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "bit table: block sel" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableChip", + "config" + |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "block_sel" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |), + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::bit_table::BLOCK_SEL_OFFSET" + |) + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "array") + [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::bit_table::U8_OFFSET" + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::array::iter::IntoIter") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := + M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_fixed", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + ctx + |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "bit table: lookup sel" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::bit_table::BitTableChip", + "config" + |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "lookup_sel" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + ctx + |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |), + M.read (| + i + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "array") + [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::bit_table::U32_OFFSET" + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::array::iter::IntoIter") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := + M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_fixed", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + ctx + |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "bit table: u32 sel" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::bit_table::BitTableChip", + "config" + |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "u32_sel" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + ctx + |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |), + M.read (| + i + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "step", + [] + |), + [ + M.read (| ctx |); + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::bit_table::STEP_SIZE" + |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_init : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "init" (init F). + + (* + fn assign_op(&self, ctx: &mut Context<'_, F>, op: BitTableOp) -> Result<(), Error> { + let op_index = F::from(op.index() as u64); + + for i in 0..STEP_SIZE { + ctx.region.assign_advice( + || "bit table op", + self.config.op, + ctx.offset + i, + || Ok(op_index), + )?; + } + + if op == BitTableOp::Popcnt { + for i in U32_OFFSET { + ctx.region.assign_advice( + || "bit table op", + self.config.helper, + ctx.offset + i, + || Ok(F::one()), + )?; + } + } + + Ok(()) + } + *) + Definition assign_op (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; op ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let op := M.alloc (| op |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let op_index := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableOp", + "index", + [] + |), + [ op ] + |)) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::bit_table::STEP_SIZE" + |) + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "bit table op" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableChip", + "config" + |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "op" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |), + M.read (| i |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.read (| + op_index + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableOp", + [ + Ty.path + "delphinus_zkwasm::circuits::bit_table::BitTableOp" + ], + "eq", + [] + |), + [ + op; + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::bit_table::BitTableOp::Popcnt" + [] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "array") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::bit_table::U32_OFFSET" + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "bit table op" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableChip", + "config" + |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "helper" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |), + M.read (| i |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_op : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign_op" (assign_op F). + + (* + fn assign_u64_popcnt( + &self, + ctx: &mut Context<'_, F>, + col: Column, + value: u64, + ) -> Result<(), Error> { + let low_u32 = value as u32; + let high_u32 = (value >> 32) as u32; + + let low_u8s_popcnt = low_u32.to_le_bytes().map(|byte| byte.count_ones()); + let high_u8s_popcnt = high_u32.to_le_bytes().map(|byte| byte.count_ones()); + let low_u32_popcnt = low_u32.count_ones(); + let high_u32_popcnt = high_u32.count_ones(); + + ctx.region.assign_advice( + || "bit table: assign u64", + col, + ctx.offset, + || Ok(F::from(value.count_ones() as u64)), + )?; + + macro_rules! assign_u32 { + ($v: expr, $bytes: expr, $offset: expr) => {{ + ctx.region.assign_advice( + || "bit table: assign u32", + col, + ctx.offset + $offset, + || Ok(F::from($v as u64)), + )?; + + for (index, byte_count_ones) in $bytes.into_iter().enumerate() { + ctx.region.assign_advice( + || "bit table: assign u8", + col, + ctx.offset + 1 + index + $offset, + || Ok(F::from(byte_count_ones as u64)), + )?; + } + }}; + } + + assign_u32!(low_u32_popcnt, low_u8s_popcnt, U32_OFFSET[0]); + assign_u32!(high_u32_popcnt, high_u8s_popcnt, U32_OFFSET[1]); + + Ok(()) + } + *) + Definition assign_u64_popcnt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; col; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let col := M.alloc (| col |) in + let value := M.alloc (| value |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let low_u32 := M.alloc (| M.rust_cast (M.read (| value |)) |) in + let high_u32 := + M.alloc (| + M.rust_cast (BinOp.Panic.shr (| M.read (| value |), Value.Integer 32 |)) + |) in + let low_u8s_popcnt := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.path "u8" ], + "map", + [ + Ty.function [ Ty.tuple [ Ty.path "u8" ] ] (Ty.path "u32"); + Ty.path "u32" + ] + |), + [ + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "to_le_bytes", [] |), + [ M.read (| low_u32 |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let byte := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "u8", + "count_ones", + [] + |), + [ M.read (| byte |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let high_u8s_popcnt := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.path "u8" ], + "map", + [ + Ty.function [ Ty.tuple [ Ty.path "u8" ] ] (Ty.path "u32"); + Ty.path "u32" + ] + |), + [ + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "to_le_bytes", [] |), + [ M.read (| high_u32 |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let byte := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "u8", + "count_ones", + [] + |), + [ M.read (| byte |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let low_u32_popcnt := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "count_ones", [] |), + [ M.read (| low_u32 |) ] + |) + |) in + let high_u32_popcnt := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "count_ones", [] |), + [ M.read (| high_u32 |) ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "halo2_proofs::plonk::error::Error" ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String "bit table: assign u64" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| col |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path "u64", + "count_ones", + [] + |), + [ M.read (| value |) ] + |)) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "halo2_proofs::plonk::error::Error" ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String "bit table: assign u32" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| col |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |), + M.read (| + M.SubPointer.get_array_field (| + M.get_constant (| + "delphinus_zkwasm::circuits::bit_table::U32_OFFSET" + |), + M.alloc (| Value.Integer 0 |) + |) + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| low_u32_popcnt |)) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ Ty.path "u32" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ Ty.path "u32" ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "array") [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ M.read (| low_u8s_popcnt |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ Ty.path "u32" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let index := M.copy (| γ1_0 |) in + let byte_count_ones := M.copy (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "bit table: assign u8" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| col |); + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |), + Value.Integer 1 + |), + M.read (| index |) + |), + M.read (| + M.SubPointer.get_array_field (| + M.get_constant (| + "delphinus_zkwasm::circuits::bit_table::U32_OFFSET" + |), + M.alloc (| Value.Integer 0 |) + |) + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + byte_count_ones + |)) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "halo2_proofs::plonk::error::Error" ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String "bit table: assign u32" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| col |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |), + M.read (| + M.SubPointer.get_array_field (| + M.get_constant (| + "delphinus_zkwasm::circuits::bit_table::U32_OFFSET" + |), + M.alloc (| Value.Integer 1 |) + |) + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| high_u32_popcnt |)) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ Ty.path "u32" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ Ty.path "u32" ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "array") [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ M.read (| high_u8s_popcnt |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ Ty.path "u32" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let index := M.copy (| γ1_0 |) in + let byte_count_ones := M.copy (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "bit table: assign u8" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| col |); + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |), + Value.Integer 1 + |), + M.read (| index |) + |), + M.read (| + M.SubPointer.get_array_field (| + M.get_constant (| + "delphinus_zkwasm::circuits::bit_table::U32_OFFSET" + |), + M.alloc (| Value.Integer 1 |) + |) + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + byte_count_ones + |)) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_u64_popcnt : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign_u64_popcnt" (assign_u64_popcnt F). + + (* + fn assign_u64_le( + &self, + ctx: &mut Context<'_, F>, + col: Column, + value: u64, + ) -> Result<(), Error> { + let low_u32 = value as u32; + let high_u32 = (value >> 32) as u32; + + ctx.region.assign_advice( + || "bit table: assign u64", + col, + ctx.offset, + || Ok(F::from(value)), + )?; + + macro_rules! assign_u32 { + ($v: expr, $offset: expr) => {{ + let bytes = $v.to_le_bytes(); + + ctx.region.assign_advice( + || "bit table: assign u32", + col, + ctx.offset + $offset, + || Ok(F::from($v as u64)), + )?; + + for (index, byte) in bytes.into_iter().enumerate() { + ctx.region.assign_advice( + || "bit table: assign u8", + col, + ctx.offset + 1 + index + $offset, + || Ok(F::from(byte as u64)), + )?; + } + }}; + } + + assign_u32!(low_u32, U32_OFFSET[0]); + assign_u32!(high_u32, U32_OFFSET[1]); + + Ok(()) + } + *) + Definition assign_u64_le (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; col; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let col := M.alloc (| col |) in + let value := M.alloc (| value |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let low_u32 := M.alloc (| M.rust_cast (M.read (| value |)) |) in + let high_u32 := + M.alloc (| + M.rust_cast (BinOp.Panic.shr (| M.read (| value |), Value.Integer 32 |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "halo2_proofs::plonk::error::Error" ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String "bit table: assign u64" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| col |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| value |) ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + let bytes := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "to_le_bytes", [] |), + [ M.read (| low_u32 |) ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "halo2_proofs::plonk::error::Error" ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String "bit table: assign u32" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| col |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |), + M.read (| + M.SubPointer.get_array_field (| + M.get_constant (| + "delphinus_zkwasm::circuits::bit_table::U32_OFFSET" + |), + M.alloc (| Value.Integer 0 |) + |) + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| low_u32 |)) ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ Ty.path "u8" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ Ty.path "u8" ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "array") [ Ty.path "u8" ], + [], + "into_iter", + [] + |), + [ M.read (| bytes |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ Ty.path "u8" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let index := M.copy (| γ1_0 |) in + let byte := M.copy (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "bit table: assign u8" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| col |); + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |), + Value.Integer 1 + |), + M.read (| index |) + |), + M.read (| + M.SubPointer.get_array_field (| + M.get_constant (| + "delphinus_zkwasm::circuits::bit_table::U32_OFFSET" + |), + M.alloc (| Value.Integer 0 |) + |) + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + byte + |)) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + let bytes := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "to_le_bytes", [] |), + [ M.read (| high_u32 |) ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "halo2_proofs::plonk::error::Error" ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String "bit table: assign u32" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| col |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |), + M.read (| + M.SubPointer.get_array_field (| + M.get_constant (| + "delphinus_zkwasm::circuits::bit_table::U32_OFFSET" + |), + M.alloc (| Value.Integer 1 |) + |) + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| high_u32 |)) ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ Ty.path "u8" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ Ty.path "u8" ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "array") [ Ty.path "u8" ], + [], + "into_iter", + [] + |), + [ M.read (| bytes |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ Ty.path "u8" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let index := M.copy (| γ1_0 |) in + let byte := M.copy (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "bit table: assign u8" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| col |); + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |), + Value.Integer 1 + |), + M.read (| index |) + |), + M.read (| + M.SubPointer.get_array_field (| + M.get_constant (| + "delphinus_zkwasm::circuits::bit_table::U32_OFFSET" + |), + M.alloc (| Value.Integer 1 |) + |) + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + byte + |)) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_u64_le : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign_u64_le" (assign_u64_le F). + + (* + fn assign_entries( + &self, + ctx: &mut Context<'_, F>, + entries: &Vec, + ) -> Result<(), Error> { + assert!(entries.len() <= self.max_available_rows / STEP_SIZE); + + for entry in entries { + self.assign_op(ctx, entry.op)?; + self.assign_u64_le(ctx, self.config.left, entry.left)?; + self.assign_u64_le(ctx, self.config.right, entry.right)?; + if entry.op == BitTableOp::Popcnt { + // entry.left: Compute left's decompose popcnt + self.assign_u64_popcnt(ctx, self.config.result, entry.left)?; + } else { + self.assign_u64_le(ctx, self.config.result, entry.result)?; + } + + ctx.step(STEP_SIZE); + } + + Ok(()) + } + *) + Definition assign_entries (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; entries ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let entries := M.alloc (| entries |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.le + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::bit_table::assign::BitTableAssign"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| entries |) ] + |)) + (BinOp.Panic.div (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableChip", + "max_available_rows" + |) + |), + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::bit_table::STEP_SIZE" + |) + |) + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "assertion failed: entries.len() <= self.max_available_rows / STEP_SIZE" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::bit_table::assign::BitTableAssign"; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ M.read (| entries |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::bit_table::assign::BitTableAssign" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let entry := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::bit_table::BitTableChip") + [ F ], + "assign_op", + [] + |), + [ + M.read (| self |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::bit_table::assign::BitTableAssign", + "op" + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::bit_table::BitTableChip") + [ F ], + "assign_u64_le", + [] + |), + [ + M.read (| self |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableChip", + "config" + |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "left" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::bit_table::assign::BitTableAssign", + "left" + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::bit_table::BitTableChip") + [ F ], + "assign_u64_le", + [] + |), + [ + M.read (| self |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableChip", + "config" + |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "right" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::bit_table::assign::BitTableAssign", + "right" + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "delphinus_zkwasm::circuits::bit_table::BitTableOp", + [ + Ty.path + "delphinus_zkwasm::circuits::bit_table::BitTableOp" + ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::bit_table::assign::BitTableAssign", + "op" + |); + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::bit_table::BitTableOp::Popcnt" + [] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::bit_table::BitTableChip") + [ F ], + "assign_u64_popcnt", + [] + |), + [ + M.read (| self |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableChip", + "config" + |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "result" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::bit_table::assign::BitTableAssign", + "left" + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::bit_table::BitTableChip") + [ F ], + "assign_u64_le", + [] + |), + [ + M.read (| self |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableChip", + "config" + |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "result" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::bit_table::assign::BitTableAssign", + "result" + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "step", + [] + |), + [ + M.read (| ctx |); + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::bit_table::STEP_SIZE" + |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_entries : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign_entries" (assign_entries F). + + (* + pub(crate) fn assign( + &self, + layouter: impl Layouter, + event_table: Vec, + ) -> Result<(), Error> { + layouter.assign_region( + || "bit table", + |region| { + let mut ctx = Context::new(region); + + self.init(&mut ctx)?; + + ctx.reset(); + + self.assign_entries(&mut ctx, &event_table)?; + + Ok(()) + }, + ) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Layouter_F_ ], [ self; layouter; event_table ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let layouter := M.alloc (| layouter |) in + let event_table := M.alloc (| event_table |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::Layouter", + impl_Layouter_F_, + [ F ], + "assign_region", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ] ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ]); + Ty.tuple []; + Ty.function [ Ty.tuple [] ] (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + layouter; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ fun γ => ltac:(M.monadic (M.read (| Value.String "bit table" |))) ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let region := M.copy (| γ |) in + M.read (| + let ctx := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "new", + [] + |), + [ M.read (| region |) ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::bit_table::BitTableChip") + [ F ], + "init", + [] + |), + [ M.read (| self |); ctx ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "reset", + [] + |), + [ ctx ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::bit_table::BitTableChip") + [ F ], + "assign_entries", + [] + |), + [ M.read (| self |); ctx; event_table ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_circuits_bit_table_BitTableChip_F. + End assign. + End bit_table. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/bit_table/configure.v b/CoqOfRust/zkWasm/circuits/bit_table/configure.v new file mode 100644 index 000000000..9d13f121f --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/bit_table/configure.v @@ -0,0 +1,398 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module bit_table. + Module configure. + Module Impl_delphinus_zkwasm_circuits_bit_table_BitTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableConfig") [ F ]. + + (* + pub(crate) fn configure_in_table( + &self, + meta: &mut ConstraintSystem, + key: &'static str, + expr: impl FnOnce( + &mut VirtualCells<'_, F>, + ) -> ( + Expression, + Expression, + Expression, + Expression, + Expression, + ), + ) { + meta.lookup_any(key, |meta| { + let (sel, op, left, right, result) = expr(meta); + + vec![ + // To prevent `fixed_curr!(meta, self.block_sel) * expr` which makes the h_poly degree up to 5 + (sel, fixed_curr!(meta, self.block_sel)), + (op, prev!(meta, self.op)), + (left, prev!(meta, self.left)), + (right, prev!(meta, self.right)), + (result, prev!(meta, self.result)), + ] + }); + } + *) + Definition configure_in_table (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ + impl_FnOnce__mut_VirtualCells_'___F___arrow__Expression_F___Expression_F___Expression_F___Expression_F___Expression_F__ + ], + [ self; meta; key; expr ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let key := M.alloc (| key |) in + let expr := M.alloc (| expr |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "lookup_any", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| key |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow__Expression_F___Expression_F___Expression_F___Expression_F___Expression_F__, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ + M.read (| expr |); + Value.Tuple [ M.read (| meta |) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_2 := + M.SubPointer.get_tuple_field (| γ, 2 |) in + let γ0_3 := + M.SubPointer.get_tuple_field (| γ, 3 |) in + let γ0_4 := + M.SubPointer.get_tuple_field (| γ, 4 |) in + let sel := M.copy (| γ0_0 |) in + let op := M.copy (| γ0_1 |) in + let left := M.copy (| γ0_2 |) in + let right := M.copy (| γ0_3 |) in + let result := M.copy (| γ0_4 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.read (| sel |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "block_sel" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ]; + Value.Tuple + [ + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "op" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "prev", + [] + |), + [] + |) + ] + |) + ]; + Value.Tuple + [ + M.read (| left |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "left" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "prev", + [] + |), + [] + |) + ] + |) + ]; + Value.Tuple + [ + M.read (| right |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "right" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "prev", + [] + |), + [] + |) + ] + |) + ]; + Value.Tuple + [ + M.read (| result |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "result" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "prev", + [] + |), + [] + |) + ] + |) + ] + ] + |) + ] + |) + |)) + ] + |) + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure_in_table : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure_in_table" (configure_in_table F). + End Impl_delphinus_zkwasm_circuits_bit_table_BitTableConfig_F. + End configure. + End bit_table. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/bit_table/mod.v b/CoqOfRust/zkWasm/circuits/bit_table/mod.v new file mode 100644 index 000000000..2dec8f23f --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/bit_table/mod.v @@ -0,0 +1,4855 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module bit_table. + (* Trait *) + (* Empty module 'BitTableTrait' *) + + (* + Enum BitTableOp + { + ty_params := []; + variants := + [ + { + name := "BinaryBit"; + item := StructTuple [ Ty.path "specs::itable::BitOp" ]; + discriminant := None; + }; + { + name := "Popcnt"; + item := StructTuple []; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_clone_Clone_for_delphinus_zkwasm_circuits_bit_table_BitTableOp. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableOp". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.read (| self |))) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_delphinus_zkwasm_circuits_bit_table_BitTableOp. + + Module Impl_core_marker_Copy_for_delphinus_zkwasm_circuits_bit_table_BitTableOp. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableOp". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_delphinus_zkwasm_circuits_bit_table_BitTableOp. + + Module Impl_core_marker_StructuralPartialEq_for_delphinus_zkwasm_circuits_bit_table_BitTableOp. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableOp". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_delphinus_zkwasm_circuits_bit_table_BitTableOp. + + Module Impl_core_cmp_PartialEq_for_delphinus_zkwasm_circuits_bit_table_BitTableOp. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableOp". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableOp" ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableOp" ] + |), + [ M.read (| other |) ] + |) + |) in + M.alloc (| + LogicalOp.and (| + BinOp.Pure.eq (M.read (| __self_tag |)) (M.read (| __arg1_tag |)), + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [ M.read (| self |); M.read (| other |) ] |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_0, + "delphinus_zkwasm::circuits::bit_table::BitTableOp::BinaryBit", + 0 + |) in + let __self_0 := M.alloc (| γ2_0 |) in + let γ0_1 := M.read (| γ0_1 |) in + let γ2_0 := + M.SubPointer.get_struct_tuple_field (| + γ0_1, + "delphinus_zkwasm::circuits::bit_table::BitTableOp::BinaryBit", + 0 + |) in + let __arg1_0 := M.alloc (| γ2_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::itable::BitOp", + [ Ty.path "specs::itable::BitOp" ], + "eq", + [] + |), + [ M.read (| __self_0 |); M.read (| __arg1_0 |) ] + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Bool true |))) + ] + |) + |))) + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_delphinus_zkwasm_circuits_bit_table_BitTableOp. + + Module Impl_delphinus_zkwasm_circuits_bit_table_BitTableOp. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableOp". + + (* + pub(crate) fn index(&self) -> usize { + match self { + BitTableOp::BinaryBit(op) => *op as usize, + BitTableOp::Popcnt => BitOp::iter().len(), + } + } + *) + Definition index (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "delphinus_zkwasm::circuits::bit_table::BitTableOp::BinaryBit", + 0 + |) in + let op := M.alloc (| γ1_0 |) in + M.alloc (| M.rust_cast (M.read (| M.read (| op |) |)) |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::exact_size::ExactSizeIterator", + Ty.path "specs::itable::BitOpIter", + [], + "len", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "strum::IntoEnumIterator", + Ty.path "specs::itable::BitOp", + [], + "iter", + [] + |), + [] + |) + |) + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_index : M.IsAssociatedFunction Self "index" index. + End Impl_delphinus_zkwasm_circuits_bit_table_BitTableOp. + + (* StructRecord + { + name := "BitTableConfig"; + ty_params := [ "F" ]; + fields := + [ + ("block_sel", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]); + ("u32_sel", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]); + ("lookup_sel", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]); + ("op", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + ("helper", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + ("left", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + ("right", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + ("result", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + ("_mark", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_bit_table_BitTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableConfig") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::bit_table::BitTableConfig" + [ + ("block_sel", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "block_sel" + |) + ] + |)); + ("u32_sel", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "u32_sel" + |) + ] + |)); + ("lookup_sel", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "lookup_sel" + |) + ] + |)); + ("op", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "op" + |) + ] + |)); + ("helper", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "helper" + |) + ] + |)); + ("left", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "left" + |) + ] + |)); + ("right", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "right" + |) + ] + |)); + ("result", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "result" + |) + ] + |)); + ("_mark", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::bit_table::BitTableConfig", + "_mark" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_bit_table_BitTableConfig_F. + + Definition value_STEP_SIZE : Value.t := M.run ltac:(M.monadic (M.alloc (| Value.Integer 11 |))). + + Definition value_BLOCK_SEL_OFFSET : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 1 |))). + + Definition value_U32_OFFSET : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Array [ Value.Integer 1; Value.Integer 6 ] |))). + + Definition value_U8_OFFSET : Value.t := + M.run + ltac:(M.monadic + (M.alloc (| + Value.Array + [ + Value.Integer 2; + Value.Integer 3; + Value.Integer 4; + Value.Integer 5; + Value.Integer 7; + Value.Integer 8; + Value.Integer 9; + Value.Integer 10 + ] + |))). + + Module Impl_delphinus_zkwasm_circuits_bit_table_BitTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableConfig") [ F ]. + + (* + pub(crate) fn configure(meta: &mut ConstraintSystem, rtable: &RangeTableConfig) -> Self { + let block_sel = meta.fixed_column(); + let u32_sel = meta.fixed_column(); + let lookup_sel = meta.fixed_column(); + let op = meta.advice_column(); + let helper = meta.advice_column(); + let left = meta.advice_column(); + let right = meta.advice_column(); + let result = meta.advice_column(); + + rtable.configure_in_op_table( + meta, + "bit table lookup in rtable", + |meta| curr!(meta, op), + |meta| curr!(meta, left), + |meta| curr!(meta, right), + |meta| curr!(meta, result), + |meta| fixed_curr!(meta, lookup_sel), + ); + + meta.create_gate("bit table: 1. op consistent", |meta| { + vec![ + (fixed_curr!(meta, u32_sel) + fixed_curr!(meta, lookup_sel)) + * (prev!(meta, op) - curr!(meta, op)), + fixed_curr!(meta, u32_sel) + * curr!(meta, helper) + * (curr!(meta, op) - constant_from!(BitTableOp::Popcnt.index())), + fixed_curr!(meta, u32_sel) + * (curr!(meta, helper) - constant_from!(1)) + * curr!(meta, op) // - constant_from!(BitOp::And)): 0 + * (curr!(meta, op) - constant_from!(BitOp::Or)) + * (curr!(meta, op) - constant_from!(BitOp::Xor)), + // is_popcnt cell is bit + fixed_curr!(meta, u32_sel) + * curr!(meta, helper) + * (curr!(meta, helper) - constant_from!(1)), + ] + }); + + meta.create_gate("bit table: 2. acc u32", |meta| { + let is_popcnt = curr!(meta, helper); + let is_bit = constant_from!(1) - is_popcnt.clone(); + + // For bit operator + macro_rules! compose_u32_helper { + ($col:expr) => { + (0..4) + .into_iter() + .map(|x| { + if x == 0 { + nextn!(meta, $col, 1) + } else { + (nextn!(meta, $col, x + 1)) * constant_from!(1u64 << (8 * x)) + } + }) + .reduce(|acc, x| acc + x) + .unwrap() + }; + } + + // For popcnt operator + macro_rules! acc_u32_helper { + ($col:expr) => { + (0..4) + .into_iter() + .map(|x| (nextn!(meta, $col, 1 + x))) + .reduce(|acc, x| acc + x) + .unwrap() + }; + } + + macro_rules! compose_u32 { + ($col:ident) => { + fixed_curr!(meta, u32_sel) * (compose_u32_helper!($col) - curr!(meta, $col)) + }; + } + + macro_rules! compose_u32_if_bit { + ($col:ident) => { + compose_u32!($col) * is_bit.clone() + }; + } + + macro_rules! acc_u32_if_popcnt { + ($col:ident) => { + fixed_curr!(meta, u32_sel) + * (acc_u32_helper!($col) - curr!(meta, $col)) + * is_popcnt + }; + } + + vec![ + compose_u32!(left), + compose_u32!(right), + compose_u32_if_bit!(result), + acc_u32_if_popcnt!(result), + ] + }); + + meta.create_gate("bit table: 3. acc u64", |meta| { + let is_popcnt = curr!(meta, helper); + let is_bit = constant_from!(1) - is_popcnt.clone(); + + macro_rules! compose_u64 { + ($col: expr) => { + fixed_curr!(meta, block_sel) + * (prev!(meta, $col) + - curr!(meta, $col) + - nextn!(meta, $col, 5) * constant_from!(1u64 << 32)) + }; + } + + macro_rules! compose_u64_if_bit { + ($col: expr) => { + compose_u64!($col) * is_bit.clone() + }; + } + + macro_rules! acc_u64_if_popcnt { + ($col: expr) => { + fixed_curr!(meta, block_sel) + * is_popcnt + * (prev!(meta, $col) - curr!(meta, $col) - nextn!(meta, $col, 5)) + }; + } + + vec![ + compose_u64!(left), + compose_u64!(right), + compose_u64_if_bit!(result), + acc_u64_if_popcnt!(result), + ] + }); + + Self { + block_sel, + u32_sel, + lookup_sel, + op, + helper, + left, + right, + result, + _mark: PhantomData, + } + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ meta; rtable ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + let rtable := M.alloc (| rtable |) in + M.read (| + let block_sel := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "fixed_column", + [] + |), + [ M.read (| meta |) ] + |) + |) in + let u32_sel := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "fixed_column", + [] + |), + [ M.read (| meta |) ] + |) + |) in + let lookup_sel := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "fixed_column", + [] + |), + [ M.read (| meta |) ] + |) + |) in + let op := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "advice_column", + [] + |), + [ M.read (| meta |) ] + |) + |) in + let helper := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "advice_column", + [] + |), + [ M.read (| meta |) ] + |) + |) in + let left := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "advice_column", + [] + |), + [ M.read (| meta |) ] + |) + |) in + let right := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "advice_column", + [] + |), + [ M.read (| meta |) ] + |) + |) in + let result := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "advice_column", + [] + |), + [ M.read (| meta |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::rtable::RangeTableConfig") + [ F ], + "configure_in_op_table", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]) + ] + |), + [ + M.read (| rtable |); + M.read (| meta |); + M.read (| Value.String "bit table lookup in rtable" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| left |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| right |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| result |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| lookup_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "bit table: 1. op consistent" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| u32_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| lookup_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "prev", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| u32_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| helper |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::bit_table::BitTableOp", + "index", + [] + |), + [ + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::bit_table::BitTableOp::Popcnt" + [] + |) + ] + |)) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| u32_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| helper |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::BitOp::Or_discriminant" + |), + Value.Integer 0 + |)) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::BitOp::Xor_discriminant" + |), + Value.Integer 0 + |)) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| u32_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| helper |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| helper |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "bit table: 2. acc u32" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let is_popcnt := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| helper |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + |) in + let is_bit := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ is_popcnt ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| u32_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "i32" ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "i32" + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "reduce", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "i32" ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "i32" + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "i32" + ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + Value.Integer + 0); + ("end_", + Value.Integer + 4) + ] + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + x := + M.copy (| + γ + |) in + M.read (| + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| + x + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ], + "query_advice", + [] + |), + [ + M.read (| + meta + |); + M.read (| + left + |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + Value.Integer + 1 + ] + ] + |) + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ], + "query_advice", + [] + |), + [ + M.read (| + meta + |); + M.read (| + left + |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + BinOp.Panic.add (| + Integer.I32, + M.read (| + x + |), + Value.Integer + 1 + |) + ] + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + Value.Integer + 1, + BinOp.Panic.mul (| + Integer.I32, + Value.Integer + 8, + M.read (| + x + |) + |) + |) + |)) + |) + ] + |) + ] + ] + |) + |))) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + acc := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + x := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "add", + [] + |), + [ + M.read (| + acc + |); + M.read (| + x + |) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| left |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| u32_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "i32" ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "i32" + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "reduce", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "i32" ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "i32" + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "i32" + ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + Value.Integer + 0); + ("end_", + Value.Integer + 4) + ] + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + x := + M.copy (| + γ + |) in + M.read (| + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| + x + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ], + "query_advice", + [] + |), + [ + M.read (| + meta + |); + M.read (| + right + |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + Value.Integer + 1 + ] + ] + |) + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ], + "query_advice", + [] + |), + [ + M.read (| + meta + |); + M.read (| + right + |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + BinOp.Panic.add (| + Integer.I32, + M.read (| + x + |), + Value.Integer + 1 + |) + ] + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + Value.Integer + 1, + BinOp.Panic.mul (| + Integer.I32, + Value.Integer + 8, + M.read (| + x + |) + |) + |) + |)) + |) + ] + |) + ] + ] + |) + |))) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + acc := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + x := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "add", + [] + |), + [ + M.read (| + acc + |); + M.read (| + x + |) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| right |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| u32_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "i32" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "i32" + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "reduce", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "i32" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "i32" + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "i32" + ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + Value.Integer + 0); + ("end_", + Value.Integer + 4) + ] + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + x := + M.copy (| + γ + |) in + M.read (| + M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| + x + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ], + "query_advice", + [] + |), + [ + M.read (| + meta + |); + M.read (| + result + |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + Value.Integer + 1 + ] + ] + |) + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ], + "query_advice", + [] + |), + [ + M.read (| + meta + |); + M.read (| + result + |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + BinOp.Panic.add (| + Integer.I32, + M.read (| + x + |), + Value.Integer + 1 + |) + ] + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + Value.Integer + 1, + BinOp.Panic.mul (| + Integer.I32, + Value.Integer + 8, + M.read (| + x + |) + |) + |) + |)) + |) + ] + |) + ] + ] + |) + |))) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + acc := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + x := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "add", + [] + |), + [ + M.read (| + acc + |); + M.read (| + x + |) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| result |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ is_bit ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| u32_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "i32" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "i32" + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "reduce", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "i32" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "i32" + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "i32" + ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + Value.Integer + 0); + ("end_", + Value.Integer + 4) + ] + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + x := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ], + "query_advice", + [] + |), + [ + M.read (| + meta + |); + M.read (| + result + |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + BinOp.Panic.add (| + Integer.I32, + Value.Integer + 1, + M.read (| + x + |) + |) + ] + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + acc := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + x := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "add", + [] + |), + [ + M.read (| + acc + |); + M.read (| + x + |) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| result |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |); + M.read (| is_popcnt |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "bit table: 3. acc u64" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let is_popcnt := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| helper |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + |) in + let is_bit := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ is_popcnt ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| block_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| left |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "prev", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| left |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| left |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ Value.Integer 5 ] + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 32 + |) + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| block_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| right |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "prev", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| right |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| right |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ Value.Integer 5 ] + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 32 + |) + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| block_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| result |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "prev", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| result |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| result |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ Value.Integer 5 + ] + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 32 + |) + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ is_bit ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| block_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.read (| is_popcnt |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| result |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "prev", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| result |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| result |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ Value.Integer 5 ] + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::bit_table::BitTableConfig" + [ + ("block_sel", M.read (| block_sel |)); + ("u32_sel", M.read (| u32_sel |)); + ("lookup_sel", M.read (| lookup_sel |)); + ("op", M.read (| op |)); + ("helper", M.read (| helper |)); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("result", M.read (| result |)); + ("_mark", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure" (configure F). + End Impl_delphinus_zkwasm_circuits_bit_table_BitTableConfig_F. + + (* StructRecord + { + name := "BitTableChip"; + ty_params := [ "F" ]; + fields := + [ + ("config", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableConfig") [ F ]); + ("max_available_rows", Ty.path "usize") + ]; + } *) + + Module Impl_delphinus_zkwasm_circuits_bit_table_BitTableChip_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableChip") [ F ]. + + (* + pub fn new(config: BitTableConfig, max_available_rows: usize) -> Self { + BitTableChip { + config, + max_available_rows: max_available_rows / STEP_SIZE * STEP_SIZE, + } + } + *) + Definition new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ config; max_available_rows ] => + ltac:(M.monadic + (let config := M.alloc (| config |) in + let max_available_rows := M.alloc (| max_available_rows |) in + Value.StructRecord + "delphinus_zkwasm::circuits::bit_table::BitTableChip" + [ + ("config", M.read (| config |)); + ("max_available_rows", + BinOp.Panic.mul (| + Integer.Usize, + BinOp.Panic.div (| + Integer.Usize, + M.read (| max_available_rows |), + M.read (| + M.get_constant (| "delphinus_zkwasm::circuits::bit_table::STEP_SIZE" |) + |) + |), + M.read (| + M.get_constant (| "delphinus_zkwasm::circuits::bit_table::STEP_SIZE" |) + |) + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "new" (new F). + End Impl_delphinus_zkwasm_circuits_bit_table_BitTableChip_F. + End bit_table. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/cell.v b/CoqOfRust/zkWasm/circuits/cell.v new file mode 100644 index 000000000..d405579f9 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/cell.v @@ -0,0 +1,5403 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module cell. + (* StructRecord + { + name := "AllocatedCell"; + ty_params := [ "F" ]; + fields := + [ + ("col", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + ("rot", Ty.path "i32"); + ("_mark", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AllocatedCell" |); + M.read (| Value.String "col" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "col" + |)); + M.read (| Value.String "rot" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "rot" + |)); + M.read (| Value.String "_mark" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "_mark" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedCell_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedCell" + [ + ("col", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "col" + |) + ] + |)); + ("rot", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "i32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "rot" + |) + ] + |)); + ("_mark", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "_mark" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedCell_F. + + Module Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedCell_F. + + (* Trait *) + Module CellExpression. + Definition expr (F Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Self, + [ F ], + "curr_expr", + [] + |), + [ M.read (| self |); M.read (| meta |) ] + |))) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_expr : + forall (F : Ty.t), + M.IsProvidedMethod "delphinus_zkwasm::circuits::cell::CellExpression" "expr" (expr F). + Definition assign_bn (F Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; ctx; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let value := M.alloc (| value |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Self, + [ F ], + "assign", + [] + |), + [ + M.read (| self |); + M.read (| ctx |); + M.call_closure (| + M.get_function (| "delphinus_zkwasm::circuits::utils::bn_to_field", [ F ] |), + [ M.read (| value |) ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_assign_bn : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::cell::CellExpression" + "assign_bn" + (assign_bn F). + Definition assign_u32 (F Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; ctx; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let value := M.alloc (| value |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Self, + [ F ], + "assign", + [] + |), + [ + M.read (| self |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| "core::convert::Into", Ty.path "u64", [ F ], "into", [] |), + [ M.rust_cast (M.read (| value |)) ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_assign_u32 : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::cell::CellExpression" + "assign_u32" + (assign_u32 F). + Definition assign_bool (F Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; ctx; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let value := M.alloc (| value |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Self, + [ F ], + "assign", + [] + |), + [ + M.read (| self |); + M.read (| ctx |); + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use value in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "one", [] |), + [] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "zero", [] |), + [] + |) + |))) + ] + |) + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_assign_bool : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::cell::CellExpression" + "assign_bool" + (assign_bool F). + End CellExpression. + + Module Impl_delphinus_zkwasm_circuits_cell_CellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ]. + + (* + fn curr_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + nextn!(meta, self.col, self.rot) + } + *) + Definition curr_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "col" + |) + |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "rot" + |) + |) + ] + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign(&self, ctx: &mut Context<'_, F>, value: F) -> Result, Error> { + ctx.region.assign_advice( + || "assign cell", + self.col, + (ctx.offset as i32 + self.rot) as usize, + || Ok(value), + ) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let value := M.alloc (| value |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "halo2_proofs::plonk::error::Error" ]); + F; + Ty.function [ Ty.tuple [] ] (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ fun γ => ltac:(M.monadic (M.read (| Value.String "assign cell" |))) ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "col" + |) + |); + M.rust_cast + (BinOp.Panic.add (| + Integer.I32, + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |)), + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "rot" + |) + |) + |)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ M.read (| value |) ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::cell::CellExpression" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("curr_expr", InstanceField.Method (curr_expr F)); + ("assign", InstanceField.Method (assign F)) + ]. + End Impl_delphinus_zkwasm_circuits_cell_CellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedCell_F. + + (* StructRecord + { + name := "AllocatedU64Cell"; + ty_params := [ "F" ]; + fields := + [ + ("u16_cells_le", + Ty.apply + (Ty.path "array") + [ Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") [ F ] ]); + ("u64_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU64Cell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AllocatedU64Cell" |); + M.read (| Value.String "u16_cells_le" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |)); + M.read (| Value.String "u64_cell" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU64Cell_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU64Cell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell" + [ + ("u16_cells_le", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ] + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |) + ] + |)); + ("u64_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU64Cell_F. + + Module Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU64Cell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU64Cell_F. + + Module Impl_delphinus_zkwasm_circuits_cell_AllocatedU64Cell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]. + + (* + pub(crate) fn expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.u64_cell.expr(meta) + } + *) + Definition expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_expr : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "expr" (expr F). + (* + pub(crate) fn assign(&self, ctx: &mut Context<'_, F>, value: u64) -> Result<(), Error> { + for i in 0..4 { + self.u16_cells_le[i].assign(ctx, ((value >> (i * 16)) & 0xffffu64).into())?; + } + self.u64_cell.assign(ctx, value.into())?; + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let value := M.alloc (| value |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", Value.Integer 4) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + i + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ + BinOp.Pure.bit_and + (BinOp.Panic.shr (| + M.read (| value |), + BinOp.Panic.mul (| + Integer.Usize, + M.read (| i |), + Value.Integer 16 + |) + |)) + (Value.Integer 65535) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| value |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_circuits_cell_AllocatedU64Cell_F. + + (* StructRecord + { + name := "AllocatedU32Cell"; + ty_params := [ "F" ]; + fields := + [ + ("u16_cells_le", + Ty.apply + (Ty.path "array") + [ Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") [ F ] ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU32Cell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AllocatedU32Cell" |); + M.read (| Value.String "u16_cells_le" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell", + "u16_cells_le" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU32Cell_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU32Cell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell" + [ + ("u16_cells_le", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ] + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell", + "u16_cells_le" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU32Cell_F. + + Module Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU32Cell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU32Cell_F. + + (* StructRecord + { + name := "AllocatedU32PermutationCell"; + ty_params := [ "F" ]; + fields := + [ + ("u16_cells_le", + Ty.apply + (Ty.path "array") + [ Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") [ F ] ]); + ("u32_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU32PermutationCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AllocatedU32PermutationCell" |); + M.read (| Value.String "u16_cells_le" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell", + "u16_cells_le" + |)); + M.read (| Value.String "u32_cell" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell", + "u32_cell" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU32PermutationCell_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU32PermutationCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell" + [ + ("u16_cells_le", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ] + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell", + "u16_cells_le" + |) + ] + |)); + ("u32_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell", + "u32_cell" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU32PermutationCell_F. + + Module Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU32PermutationCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU32PermutationCell_F. + + (* StructRecord + { + name := "AllocatedU64CellWithFlagBitDyn"; + ty_params := [ "F" ]; + fields := + [ + ("u16_cells_le", + Ty.apply + (Ty.path "array") + [ Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") [ F ] ]); + ("u64_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]); + ("flag_bit_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("flag_u16_rem_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("flag_u16_rem_diff_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") [ F ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU64CellWithFlagBitDyn_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field5_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AllocatedU64CellWithFlagBitDyn" |); + M.read (| Value.String "u16_cells_le" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u16_cells_le" + |)); + M.read (| Value.String "u64_cell" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |)); + M.read (| Value.String "flag_bit_cell" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "flag_bit_cell" + |)); + M.read (| Value.String "flag_u16_rem_cell" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "flag_u16_rem_cell" + |)); + M.read (| Value.String "flag_u16_rem_diff_cell" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "flag_u16_rem_diff_cell" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU64CellWithFlagBitDyn_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU64CellWithFlagBitDyn_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn" + [ + ("u16_cells_le", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ] + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u16_cells_le" + |) + ] + |)); + ("u64_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |) + ] + |)); + ("flag_bit_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "flag_bit_cell" + |) + ] + |)); + ("flag_u16_rem_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "flag_u16_rem_cell" + |) + ] + |)); + ("flag_u16_rem_diff_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "flag_u16_rem_diff_cell" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU64CellWithFlagBitDyn_F. + + Module Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU64CellWithFlagBitDyn_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU64CellWithFlagBitDyn_F. + + (* StructRecord + { + name := "AllocatedU64CellWithFlagBitDynSign"; + ty_params := [ "F" ]; + fields := + [ + ("u16_cells_le", + Ty.apply + (Ty.path "array") + [ Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") [ F ] ]); + ("u64_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]); + ("flag_bit_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("flag_u16_rem_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("flag_u16_rem_diff_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") [ F ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU64CellWithFlagBitDynSign_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign") + [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field5_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AllocatedU64CellWithFlagBitDynSign" |); + M.read (| Value.String "u16_cells_le" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "u16_cells_le" + |)); + M.read (| Value.String "u64_cell" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "u64_cell" + |)); + M.read (| Value.String "flag_bit_cell" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "flag_bit_cell" + |)); + M.read (| Value.String "flag_u16_rem_cell" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "flag_u16_rem_cell" + |)); + M.read (| Value.String "flag_u16_rem_diff_cell" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "flag_u16_rem_diff_cell" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU64CellWithFlagBitDynSign_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU64CellWithFlagBitDynSign_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign") + [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign" + [ + ("u16_cells_le", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ] + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "u16_cells_le" + |) + ] + |)); + ("u64_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "u64_cell" + |) + ] + |)); + ("flag_bit_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "flag_bit_cell" + |) + ] + |)); + ("flag_u16_rem_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "flag_u16_rem_cell" + |) + ] + |)); + ("flag_u16_rem_diff_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "flag_u16_rem_diff_cell" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU64CellWithFlagBitDynSign_F. + + Module Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU64CellWithFlagBitDynSign_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign") + [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU64CellWithFlagBitDynSign_F. + + (* StructRecord + { + name := "AllocatedBitCell"; + ty_params := [ "F" ]; + fields := + [ ("cell", Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ]) ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedBitCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AllocatedBitCell" |); + M.read (| Value.String "cell" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedBitCell", + "cell" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedBitCell_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedBitCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedBitCell" + [ + ("cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedBitCell", + "cell" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedBitCell_F. + + Module Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedBitCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedBitCell_F. + + Module Impl_delphinus_zkwasm_circuits_cell_CellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedBitCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]. + + (* + fn curr_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.curr_expr(meta) + } + *) + Definition curr_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedBitCell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + value: F, + ) -> Result, Error> { + assert!( + value <= $limit, + "assigned value {:?} exceeds the limit {:?}", + value, + $limit + ); + + self.cell.assign(ctx, value) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let value := M.alloc (| value |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + F, + [ F ], + "le", + [] + |), + [ + value; + M.alloc (| + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "one", [] |), + [] + |) + |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic_fmt", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "assigned value " |); + M.read (| Value.String " exceeds the limit " |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ F ] + |), + [ value ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedBitCell", + "cell" + |); + M.read (| ctx |); + M.read (| value |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::cell::CellExpression" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("curr_expr", InstanceField.Method (curr_expr F)); + ("assign", InstanceField.Method (assign F)) + ]. + End Impl_delphinus_zkwasm_circuits_cell_CellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedBitCell_F. + + (* StructRecord + { + name := "AllocatedU8Cell"; + ty_params := [ "F" ]; + fields := + [ ("cell", Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ]) ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU8Cell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AllocatedU8Cell" |); + M.read (| Value.String "cell" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell", + "cell" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU8Cell_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU8Cell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell" + [ + ("cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell", + "cell" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU8Cell_F. + + Module Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU8Cell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU8Cell_F. + + Module Impl_delphinus_zkwasm_circuits_cell_CellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedU8Cell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") [ F ]. + + (* + fn curr_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.curr_expr(meta) + } + *) + Definition curr_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + value: F, + ) -> Result, Error> { + assert!( + value <= $limit, + "assigned value {:?} exceeds the limit {:?}", + value, + $limit + ); + + self.cell.assign(ctx, value) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let value := M.alloc (| value |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + F, + [ F ], + "le", + [] + |), + [ + value; + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| M.get_constant (| "core::num::MAX" |) |)) + ] + |) + |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic_fmt", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "assigned value " |); + M.read (| Value.String " exceeds the limit " |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ F ] + |), + [ value ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.get_constant (| "core::num::MAX" |) + |)) + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell", + "cell" + |); + M.read (| ctx |); + M.read (| value |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::cell::CellExpression" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("curr_expr", InstanceField.Method (curr_expr F)); + ("assign", InstanceField.Method (assign F)) + ]. + End Impl_delphinus_zkwasm_circuits_cell_CellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedU8Cell_F. + + (* StructRecord + { + name := "AllocatedU16Cell"; + ty_params := [ "F" ]; + fields := + [ ("cell", Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ]) ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU16Cell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AllocatedU16Cell" |); + M.read (| Value.String "cell" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell", + "cell" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU16Cell_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU16Cell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell" + [ + ("cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell", + "cell" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU16Cell_F. + + Module Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU16Cell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedU16Cell_F. + + Module Impl_delphinus_zkwasm_circuits_cell_CellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedU16Cell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") [ F ]. + + (* + fn curr_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.curr_expr(meta) + } + *) + Definition curr_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + value: F, + ) -> Result, Error> { + assert!( + value <= $limit, + "assigned value {:?} exceeds the limit {:?}", + value, + $limit + ); + + self.cell.assign(ctx, value) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let value := M.alloc (| value |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + F, + [ F ], + "le", + [] + |), + [ + value; + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| M.get_constant (| "core::num::MAX" |) |)) + ] + |) + |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic_fmt", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "assigned value " |); + M.read (| Value.String " exceeds the limit " |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ F ] + |), + [ value ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.get_constant (| "core::num::MAX" |) + |)) + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell", + "cell" + |); + M.read (| ctx |); + M.read (| value |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::cell::CellExpression" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("curr_expr", InstanceField.Method (curr_expr F)); + ("assign", InstanceField.Method (assign F)) + ]. + End Impl_delphinus_zkwasm_circuits_cell_CellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedU16Cell_F. + + (* StructRecord + { + name := "AllocatedUnlimitedCell"; + ty_params := [ "F" ]; + fields := + [ ("cell", Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ]) ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedUnlimitedCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AllocatedUnlimitedCell" |); + M.read (| Value.String "cell" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell", + "cell" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedUnlimitedCell_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedUnlimitedCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell" + [ + ("cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell", + "cell" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedUnlimitedCell_F. + + Module Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedUnlimitedCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedUnlimitedCell_F. + + Module Impl_delphinus_zkwasm_circuits_cell_CellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedUnlimitedCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]. + + (* + fn curr_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.curr_expr(meta) + } + *) + Definition curr_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + value: F, + ) -> Result, Error> { + assert!( + value <= $limit, + "assigned value {:?} exceeds the limit {:?}", + value, + $limit + ); + + self.cell.assign(ctx, value) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let value := M.alloc (| value |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + F, + [ F ], + "le", + [] + |), + [ + value; + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Neg", + F, + [], + "neg", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "one", [] |), + [] + |) + ] + |) + |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic_fmt", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "assigned value " |); + M.read (| Value.String " exceeds the limit " |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ F ] + |), + [ value ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Neg", + F, + [], + "neg", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell", + "cell" + |); + M.read (| ctx |); + M.read (| value |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::cell::CellExpression" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("curr_expr", InstanceField.Method (curr_expr F)); + ("assign", InstanceField.Method (assign F)) + ]. + End Impl_delphinus_zkwasm_circuits_cell_CellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedUnlimitedCell_F. + + (* StructRecord + { + name := "AllocatedCommonRangeCell"; + ty_params := [ "F" ]; + fields := + [ + ("cell", Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ]); + ("upper_bound", F) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedCommonRangeCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AllocatedCommonRangeCell" |); + M.read (| Value.String "cell" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell", + "cell" + |)); + M.read (| Value.String "upper_bound" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell", + "upper_bound" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedCommonRangeCell_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedCommonRangeCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell" + [ + ("cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell", + "cell" + |) + ] + |)); + ("upper_bound", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", F, [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell", + "upper_bound" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedCommonRangeCell_F. + + Module Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedCommonRangeCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_cell_AllocatedCommonRangeCell_F. + + Module Impl_delphinus_zkwasm_circuits_cell_CellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedCommonRangeCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") [ F ]. + + (* + fn curr_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.curr_expr(meta) + } + *) + Definition curr_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign(&self, ctx: &mut Context<'_, F>, value: F) -> Result, Error> { + assert!( + value <= self.upper_bound, + "assigned value {:?} exceeds the limit {:?}", + value, + self.upper_bound + ); + + self.cell.assign(ctx, value) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let value := M.alloc (| value |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + F, + [ F ], + "le", + [] + |), + [ + value; + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell", + "upper_bound" + |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic_fmt", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "assigned value " |); + M.read (| Value.String " exceeds the limit " |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ F ] + |), + [ value ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ F ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell", + "upper_bound" + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell", + "cell" + |); + M.read (| ctx |); + M.read (| value |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::cell::CellExpression" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("curr_expr", InstanceField.Method (curr_expr F)); + ("assign", InstanceField.Method (assign F)) + ]. + End Impl_delphinus_zkwasm_circuits_cell_CellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedCommonRangeCell_F. + + Module Impl_delphinus_zkwasm_circuits_cell_AllocatedU32Cell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") [ F ]. + + (* + pub(crate) fn expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.u16_cells_le[0].curr_expr(meta) + + (self.u16_cells_le[1].curr_expr(meta) * constant_from!(1 << 16)) + } + *) + Definition expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell", + "u16_cells_le" + |), + M.alloc (| Value.Integer 0 |) + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell", + "u16_cells_le" + |), + M.alloc (| Value.Integer 1 |) + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (BinOp.Panic.shl (| Value.Integer 1, Value.Integer 16 |)) ] + |) + ] + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_expr : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "expr" (expr F). + + (* + pub(crate) fn curr_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.expr(meta) + } + *) + Definition curr_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") [ F ], + "expr", + [] + |), + [ M.read (| self |); M.read (| meta |) ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_curr_expr : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "curr_expr" (curr_expr F). + + (* + pub(crate) fn assign(&self, ctx: &mut Context<'_, F>, value: u32) -> Result<(), Error> { + for i in 0..2 { + self.u16_cells_le[i].assign(ctx, (((value >> (i * 16)) & 0xffffu32) as u64).into())?; + } + + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let value := M.alloc (| value |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", Value.Integer 2) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell", + "u16_cells_le" + |), + i + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ + M.rust_cast + (BinOp.Pure.bit_and + (BinOp.Panic.shr (| + M.read (| value |), + BinOp.Panic.mul (| + Integer.Usize, + M.read (| i |), + Value.Integer 16 + |) + |)) + (Value.Integer 65535)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_circuits_cell_AllocatedU32Cell_F. + + Module Impl_delphinus_zkwasm_circuits_cell_AllocatedU32PermutationCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell") [ F ]. + + (* + pub(crate) fn expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.curr_expr(meta) + } + *) + Definition expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell") + [ F ], + "curr_expr", + [] + |), + [ M.read (| self |); M.read (| meta |) ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_expr : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "expr" (expr F). + + (* + pub(crate) fn curr_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.u32_cell.expr(meta) + } + *) + Definition curr_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell", + "u32_cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_curr_expr : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "curr_expr" (curr_expr F). + + (* + pub(crate) fn next_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + nextn!( + meta, + self.u32_cell.cell.col, + self.u32_cell.cell.rot + EVENT_TABLE_ENTRY_ROWS + ) + } + *) + Definition next_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell", + "u32_cell" + |), + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell", + "cell" + |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "col" + |) + |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + BinOp.Panic.add (| + Integer.I32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell", + "u32_cell" + |), + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell", + "cell" + |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "rot" + |) + |), + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::etable::EVENT_TABLE_ENTRY_ROWS" + |) + |) + |) + ] + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_next_expr : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "next_expr" (next_expr F). + + (* + pub(crate) fn assign( + &self, + ctx: &mut Context<'_, F>, + value: u32, + ) -> Result, Error> { + for i in 0..2 { + self.u16_cells_le[i].assign(ctx, (((value >> (i * 16)) & 0xffffu32) as u64).into())?; + } + self.u32_cell.assign(ctx, (value as u64).into()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let value := M.alloc (| value |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", Value.Integer 2) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell", + "u16_cells_le" + |), + i + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ + M.rust_cast + (BinOp.Pure.bit_and + (BinOp.Panic.shr (| + M.read (| value |), + BinOp.Panic.mul (| + Integer.Usize, + M.read (| i |), + Value.Integer 16 + |) + |)) + (Value.Integer 65535)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell", + "u32_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.rust_cast (M.read (| value |)) ] + |) + ] + |) + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_circuits_cell_AllocatedU32PermutationCell_F. + + + Module Impl_delphinus_zkwasm_circuits_cell_AllocatedU64CellWithFlagBitDyn_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn") [ F ]. + + (* + pub(crate) fn assign( + &self, + ctx: &mut Context<'_, F>, + value: u64, + is_i32: bool, + ) -> Result<(), Error> { + for i in 0..4 { + self.u16_cells_le[i].assign(ctx, ((value >> (i * 16)) & 0xffffu64).into())?; + } + self.u64_cell.assign(ctx, value.into())?; + + let pos = if is_i32 { 1 } else { 3 }; + let u16_value = (value >> (pos * 16)) & 0xffff; + let u16_flag_bit = u16_value >> 15; + let u16_rem = u16_value & 0x7fff; + let u16_rem_diff = 0x7fff - u16_rem; + self.flag_bit_cell.assign_u32(ctx, u16_flag_bit as u32)?; + self.flag_u16_rem_cell.assign_u32(ctx, u16_rem as u32)?; + self.flag_u16_rem_diff_cell + .assign_u32(ctx, u16_rem_diff as u32)?; + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; value; is_i32 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let value := M.alloc (| value |) in + let is_i32 := M.alloc (| is_i32 |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", Value.Integer 4) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u16_cells_le" + |), + i + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ + BinOp.Pure.bit_and + (BinOp.Panic.shr (| + M.read (| value |), + BinOp.Panic.mul (| + Integer.Usize, + M.read (| i |), + Value.Integer 16 + |) + |)) + (Value.Integer 65535) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| value |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let pos := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use is_i32 in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| Value.Integer 1 |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Integer 3 |))) + ] + |) + |) in + let u16_value := + M.alloc (| + BinOp.Pure.bit_and + (BinOp.Panic.shr (| + M.read (| value |), + BinOp.Panic.mul (| Integer.I32, M.read (| pos |), Value.Integer 16 |) + |)) + (Value.Integer 65535) + |) in + let u16_flag_bit := + M.alloc (| BinOp.Panic.shr (| M.read (| u16_value |), Value.Integer 15 |) |) in + let u16_rem := + M.alloc (| + BinOp.Pure.bit_and (M.read (| u16_value |)) (Value.Integer 32767) + |) in + let u16_rem_diff := + M.alloc (| + BinOp.Panic.sub (| Integer.U64, Value.Integer 32767, M.read (| u16_rem |) |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "flag_bit_cell" + |); + M.read (| ctx |); + M.rust_cast (M.read (| u16_flag_bit |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "flag_u16_rem_cell" + |); + M.read (| ctx |); + M.rust_cast (M.read (| u16_rem |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "flag_u16_rem_diff_cell" + |); + M.read (| ctx |); + M.rust_cast (M.read (| u16_rem_diff |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_circuits_cell_AllocatedU64CellWithFlagBitDyn_F. + + Module Impl_delphinus_zkwasm_circuits_cell_AllocatedU64CellWithFlagBitDynSign_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign") + [ F ]. + + (* + pub(crate) fn assign( + &self, + ctx: &mut Context<'_, F>, + value: u64, + is_i32: bool, + is_sign: bool, + ) -> Result<(), Error> { + for i in 0..4 { + self.u16_cells_le[i].assign(ctx, ((value >> (i * 16)) & 0xffffu64).into())?; + } + self.u64_cell.assign(ctx, value.into())?; + + if is_sign { + let pos = if is_i32 { 1 } else { 3 }; + let u16_value = (value >> (pos * 16)) & 0xffff; + let u16_flag_bit = u16_value >> 15; + let u16_rem = u16_value & 0x7fff; + let u16_rem_diff = 0x7fff - u16_rem; + self.flag_bit_cell.assign_u32(ctx, u16_flag_bit as u32)?; + self.flag_u16_rem_cell.assign_u32(ctx, u16_rem as u32)?; + self.flag_u16_rem_diff_cell + .assign_u32(ctx, u16_rem_diff as u32)?; + } + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; value; is_i32; is_sign ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let value := M.alloc (| value |) in + let is_i32 := M.alloc (| is_i32 |) in + let is_sign := M.alloc (| is_sign |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", Value.Integer 4) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "u16_cells_le" + |), + i + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ + BinOp.Pure.bit_and + (BinOp.Panic.shr (| + M.read (| value |), + BinOp.Panic.mul (| + Integer.Usize, + M.read (| i |), + Value.Integer 16 + |) + |)) + (Value.Integer 65535) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "u64_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| value |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use is_sign in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let pos := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use is_i32 in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| Value.Integer 1 |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Integer 3 |))) + ] + |) + |) in + let u16_value := + M.alloc (| + BinOp.Pure.bit_and + (BinOp.Panic.shr (| + M.read (| value |), + BinOp.Panic.mul (| + Integer.I32, + M.read (| pos |), + Value.Integer 16 + |) + |)) + (Value.Integer 65535) + |) in + let u16_flag_bit := + M.alloc (| + BinOp.Panic.shr (| M.read (| u16_value |), Value.Integer 15 |) + |) in + let u16_rem := + M.alloc (| + BinOp.Pure.bit_and (M.read (| u16_value |)) (Value.Integer 32767) + |) in + let u16_rem_diff := + M.alloc (| + BinOp.Panic.sub (| + Integer.U64, + Value.Integer 32767, + M.read (| u16_rem |) + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "flag_bit_cell" + |); + M.read (| ctx |); + M.rust_cast (M.read (| u16_flag_bit |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "flag_u16_rem_cell" + |); + M.read (| ctx |); + M.rust_cast (M.read (| u16_rem |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "flag_u16_rem_diff_cell" + |); + M.read (| ctx |); + M.rust_cast (M.read (| u16_rem_diff |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_circuits_cell_AllocatedU64CellWithFlagBitDynSign_F. + End cell. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/config.v b/CoqOfRust/zkWasm/circuits/config.v new file mode 100644 index 000000000..4aff0dfa2 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/config.v @@ -0,0 +1,311 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module config. + Definition value_POW_TABLE_POWER_START : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 128 |))). + + Definition value_MIN_K : Value.t := M.run ltac:(M.monadic (M.alloc (| Value.Integer 18 |))). + + Definition value_MAX_K : Value.t := M.run ltac:(M.monadic (M.alloc (| Value.Integer 25 |))). + + (* + pub(crate) fn set_zkwasm_k(k: u32) { + assert!(k >= MIN_K); + assert!(k <= MAX_K); + + let mut zkwasm_k = ( *ZKWASM_K).lock().unwrap(); + *zkwasm_k = Some(k); + } + *) + Definition set_zkwasm_k (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ k ] => + ltac:(M.monadic + (let k := M.alloc (| k |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.ge + (M.read (| k |)) + (M.read (| + M.get_constant (| "delphinus_zkwasm::circuits::config::MIN_K" |) + |))) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "assertion failed: k >= MIN_K" |) ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.le + (M.read (| k |)) + (M.read (| + M.get_constant (| "delphinus_zkwasm::circuits::config::MAX_K" |) + |))) + |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "assertion failed: k <= MAX_K" |) ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let zkwasm_k := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.path "u32" ] ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.path "u32" ] ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.path "u32" ] ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "delphinus_zkwasm::circuits::config::ZKWASM_K", + [], + "deref", + [] + |), + [ + M.read (| + M.get_constant (| "delphinus_zkwasm::circuits::config::ZKWASM_K" |) + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.path "u32" ] ], + [], + "deref_mut", + [] + |), + [ zkwasm_k ] + |), + Value.StructTuple "core::option::Option::Some" [ M.read (| k |) ] + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + (* + pub(in crate::circuits) fn zkwasm_k() -> u32 { + ZKWASM_K + .lock() + .unwrap() + .expect("ZKWASM_K is not set, please make sure 'init_zkwasm_runtime' have called.") + } + *) + Definition zkwasm_k (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [] => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.path "u32" ], + "expect", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.path "u32" ] ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.path "u32" ] ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "std::sync::mutex::MutexGuard") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.path "u32" ] ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ Ty.apply (Ty.path "core::option::Option") [ Ty.path "u32" ] ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "delphinus_zkwasm::circuits::config::ZKWASM_K", + [], + "deref", + [] + |), + [ + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::config::ZKWASM_K" + |) + |) + ] + |) + ] + |) + ] + |) + |) + ] + |) + |); + M.read (| + Value.String + "ZKWASM_K is not set, please make sure 'init_zkwasm_runtime' have called." + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + pub(crate) fn init_zkwasm_runtime(k: u32) { + set_zkwasm_k(k); + } + *) + Definition init_zkwasm_runtime (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ k ] => + ltac:(M.monadic + (let k := M.alloc (| k |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| "delphinus_zkwasm::circuits::config::set_zkwasm_k", [] |), + [ M.read (| k |) ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + (* + pub(crate) fn common_range(k: u32) -> u32 { + (1 << k) - 256 + } + *) + Definition common_range (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ k ] => + ltac:(M.monadic + (let k := M.alloc (| k |) in + BinOp.Panic.sub (| + Integer.U32, + BinOp.Panic.shl (| Value.Integer 1, M.read (| k |) |), + Value.Integer 256 + |))) + | _, _ => M.impossible + end. + + (* + pub(crate) fn common_range_max(k: u32) -> u32 { + common_range(k) - 1 + } + *) + Definition common_range_max (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ k ] => + ltac:(M.monadic + (let k := M.alloc (| k |) in + BinOp.Panic.sub (| + Integer.U32, + M.call_closure (| + M.get_function (| "delphinus_zkwasm::circuits::config::common_range", [] |), + [ M.read (| k |) ] + |), + Value.Integer 1 + |))) + | _, _ => M.impossible + end. + End config. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/allocator.v b/CoqOfRust/zkWasm/circuits/etable/allocator.v new file mode 100644 index 000000000..47c6061b8 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/allocator.v @@ -0,0 +1,16075 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module allocator. + (* Trait *) + (* Empty module 'EventTableCellExpression' *) + + Module Impl_delphinus_zkwasm_circuits_etable_allocator_EventTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ]. + + (* + fn next_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + nextn!(meta, self.col, self.rot + EVENT_TABLE_ENTRY_ROWS as i32) + } + *) + Definition next_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "col" + |) + |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + BinOp.Panic.add (| + Integer.I32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "rot" + |) + |), + M.read (| + M.use + (M.get_constant (| + "delphinus_zkwasm::circuits::etable::EVENT_TABLE_ENTRY_ROWS" + |)) + |) + |) + ] + ] + |))) + | _, _ => M.impossible + end. + + (* + fn prev_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + nextn!(meta, self.col, self.rot - EVENT_TABLE_ENTRY_ROWS as i32) + } + *) + Definition prev_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "col" + |) + |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + BinOp.Panic.sub (| + Integer.I32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "rot" + |) + |), + M.read (| + M.use + (M.get_constant (| + "delphinus_zkwasm::circuits::etable::EVENT_TABLE_ENTRY_ROWS" + |)) + |) + |) + ] + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("next_expr", InstanceField.Method (next_expr F)); + ("prev_expr", InstanceField.Method (prev_expr F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_allocator_EventTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedCell_F. + + Module Impl_delphinus_zkwasm_circuits_etable_allocator_EventTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedBitCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]. + + (* + fn next_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.next_expr(meta) + } + *) + Definition next_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "next_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedBitCell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn prev_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.prev_expr(meta) + } + *) + Definition prev_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "prev_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedBitCell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("next_expr", InstanceField.Method (next_expr F)); + ("prev_expr", InstanceField.Method (prev_expr F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_allocator_EventTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedBitCell_F. + + Module Impl_delphinus_zkwasm_circuits_etable_allocator_EventTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedU8Cell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") [ F ]. + + (* + fn next_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.next_expr(meta) + } + *) + Definition next_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "next_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn prev_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.prev_expr(meta) + } + *) + Definition prev_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "prev_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("next_expr", InstanceField.Method (next_expr F)); + ("prev_expr", InstanceField.Method (prev_expr F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_allocator_EventTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedU8Cell_F. + + Module Impl_delphinus_zkwasm_circuits_etable_allocator_EventTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedU16Cell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") [ F ]. + + (* + fn next_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.next_expr(meta) + } + *) + Definition next_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "next_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn prev_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.prev_expr(meta) + } + *) + Definition prev_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "prev_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("next_expr", InstanceField.Method (next_expr F)); + ("prev_expr", InstanceField.Method (prev_expr F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_allocator_EventTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedU16Cell_F. + + Module Impl_delphinus_zkwasm_circuits_etable_allocator_EventTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedCommonRangeCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") [ F ]. + + (* + fn next_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.next_expr(meta) + } + *) + Definition next_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "next_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn prev_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.prev_expr(meta) + } + *) + Definition prev_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "prev_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("next_expr", InstanceField.Method (next_expr F)); + ("prev_expr", InstanceField.Method (prev_expr F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_allocator_EventTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedCommonRangeCell_F. + + Module Impl_delphinus_zkwasm_circuits_etable_allocator_EventTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedUnlimitedCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]. + + (* + fn next_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.next_expr(meta) + } + *) + Definition next_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "next_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn prev_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.prev_expr(meta) + } + *) + Definition prev_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "prev_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("next_expr", InstanceField.Method (next_expr F)); + ("prev_expr", InstanceField.Method (prev_expr F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_allocator_EventTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedUnlimitedCell_F. + + Module Impl_delphinus_zkwasm_circuits_etable_allocator_EventTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedJumpTableLookupCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell") + [ F ]. + + (* + fn next_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.next_expr(meta) + } + *) + Definition next_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "next_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn prev_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.prev_expr(meta) + } + *) + Definition prev_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "prev_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("next_expr", InstanceField.Method (next_expr F)); + ("prev_expr", InstanceField.Method (prev_expr F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_allocator_EventTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedJumpTableLookupCell_F. + + (* StructRecord + { + name := "AllocatedJumpTableLookupCell"; + ty_params := [ "F" ]; + fields := + [ ("cell", Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedJumpTableLookupCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell") + [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AllocatedJumpTableLookupCell" |); + M.read (| Value.String "cell" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell", + "cell" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedJumpTableLookupCell_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedJumpTableLookupCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell") + [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell" + [ + ("cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell", + "cell" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedJumpTableLookupCell_F. + + Module Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedJumpTableLookupCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell") + [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedJumpTableLookupCell_F. + + (* StructRecord + { + name := "AllocatedMemoryTableLookupReadCell"; + ty_params := [ "F" ]; + fields := + [ + ("encode_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("start_eid_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("end_eid_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("start_eid_diff_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("end_eid_diff_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("value_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedMemoryTableLookupReadCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let names := + M.alloc (| + M.alloc (| + Value.Array + [ + M.read (| Value.String "encode_cell" |); + M.read (| Value.String "start_eid_cell" |); + M.read (| Value.String "end_eid_cell" |); + M.read (| Value.String "start_eid_diff_cell" |); + M.read (| Value.String "end_eid_diff_cell" |); + M.read (| Value.String "value_cell" |) + ] + |) + |) in + let values := + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "encode_cell" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "start_eid_cell" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "end_eid_cell" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "start_eid_diff_cell" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "end_eid_diff_cell" + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "value_cell" + |) + |)) + ] + |)) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_fields_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AllocatedMemoryTableLookupReadCell" |); + (* Unsize *) M.pointer_coercion (M.read (| names |)); + M.read (| values |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedMemoryTableLookupReadCell_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedMemoryTableLookupReadCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell" + [ + ("encode_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "encode_cell" + |) + ] + |)); + ("start_eid_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "start_eid_cell" + |) + ] + |)); + ("end_eid_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "end_eid_cell" + |) + ] + |)); + ("start_eid_diff_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "start_eid_diff_cell" + |) + ] + |)); + ("end_eid_diff_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "end_eid_diff_cell" + |) + ] + |)); + ("value_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "value_cell" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedMemoryTableLookupReadCell_F. + + Module Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedMemoryTableLookupReadCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedMemoryTableLookupReadCell_F. + + (* StructRecord + { + name := "AllocatedMemoryTableLookupWriteCell"; + ty_params := [ "F" ]; + fields := + [ + ("encode_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("start_eid_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("end_eid_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("value_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedMemoryTableLookupWriteCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field4_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "AllocatedMemoryTableLookupWriteCell" |); + M.read (| Value.String "encode_cell" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "encode_cell" + |)); + M.read (| Value.String "start_eid_cell" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "start_eid_cell" + |)); + M.read (| Value.String "end_eid_cell" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "end_eid_cell" + |)); + M.read (| Value.String "value_cell" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "value_cell" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedMemoryTableLookupWriteCell_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedMemoryTableLookupWriteCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell" + [ + ("encode_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "encode_cell" + |) + ] + |)); + ("start_eid_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "start_eid_cell" + |) + ] + |)); + ("end_eid_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "end_eid_cell" + |) + ] + |)); + ("value_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "value_cell" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedMemoryTableLookupWriteCell_F. + + Module Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedMemoryTableLookupWriteCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedMemoryTableLookupWriteCell_F. + + Module Impl_delphinus_zkwasm_circuits_etable_allocator_AllocatedMemoryTableLookupReadCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]. + + (* + pub(crate) fn assign( + &self, + ctx: &mut Context<'_, F>, + start_eid: u32, + eid: u32, + end_eid: u32, + offset: u32, + l_type: LocationType, + is_i32: bool, + value: u64, + ) -> Result<(), Error> { + self.encode_cell.assign_bn( + ctx, + &encode_memory_table_entry( + (offset as u64).into(), + (l_type as u64).into(), + (is_i32 as u64).into(), + ), + )?; + self.start_eid_cell.assign_u32(ctx, start_eid)?; + cfg_if::cfg_if! { + if #[cfg(feature="continuation")] { + self.start_eid_diff_cell.assign(ctx, eid - start_eid - 1)?; + self.end_eid_diff_cell.assign(ctx, end_eid - eid)?; + } else { + self.start_eid_diff_cell.assign_u32(ctx, eid - start_eid - 1)?; + self.end_eid_diff_cell.assign_u32(ctx, end_eid - eid)?; + } + } + self.end_eid_cell.assign_u32(ctx, end_eid)?; + self.value_cell.assign(ctx, value.into())?; + + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; start_eid; eid; end_eid; offset; l_type; is_i32; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let start_eid := M.alloc (| start_eid |) in + let eid := M.alloc (| eid |) in + let end_eid := M.alloc (| end_eid |) in + let offset := M.alloc (| offset |) in + let l_type := M.alloc (| l_type |) in + let is_i32 := M.alloc (| is_i32 |) in + let value := M.alloc (| value |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_bn", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "encode_cell" + |); + M.read (| ctx |); + M.alloc (| + M.call_closure (| + M.get_function (| + "specs::encode::memory_table::encode_memory_table_entry", + [ Ty.path "num_bigint::biguint::BigUint" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ Ty.path "num_bigint::biguint::BigUint" ], + "into", + [] + |), + [ M.rust_cast (M.read (| offset |)) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ Ty.path "num_bigint::biguint::BigUint" ], + "into", + [] + |), + [ M.rust_cast (M.read (| l_type |)) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ Ty.path "num_bigint::biguint::BigUint" ], + "into", + [] + |), + [ M.rust_cast (M.read (| is_i32 |)) ] + |) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "start_eid_cell" + |); + M.read (| ctx |); + M.read (| start_eid |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "start_eid_diff_cell" + |); + M.read (| ctx |); + BinOp.Panic.sub (| + Integer.U32, + BinOp.Panic.sub (| + Integer.U32, + M.read (| eid |), + M.read (| start_eid |) + |), + Value.Integer 1 + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "end_eid_diff_cell" + |); + M.read (| ctx |); + BinOp.Panic.sub (| + Integer.U32, + M.read (| end_eid |), + M.read (| eid |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "end_eid_cell" + |); + M.read (| ctx |); + M.read (| end_eid |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "value_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| value |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_circuits_etable_allocator_AllocatedMemoryTableLookupReadCell_F. + + Module Impl_delphinus_zkwasm_circuits_etable_allocator_AllocatedMemoryTableLookupWriteCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]. + + (* + pub(crate) fn assign( + &self, + ctx: &mut Context<'_, F>, + eid: u32, + end_eid: u32, + offset: u32, + l_type: LocationType, + is_i32: bool, + value: u64, + ) -> Result<(), Error> { + self.encode_cell.assign_bn( + ctx, + &encode_memory_table_entry( + (offset as u64).into(), + (l_type as u64).into(), + (is_i32 as u64).into(), + ), + )?; + self.start_eid_cell.assign_u32(ctx, eid)?; + self.end_eid_cell.assign_u32(ctx, end_eid)?; + self.value_cell.assign(ctx, value.into())?; + + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; eid; end_eid; offset; l_type; is_i32; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let eid := M.alloc (| eid |) in + let end_eid := M.alloc (| end_eid |) in + let offset := M.alloc (| offset |) in + let l_type := M.alloc (| l_type |) in + let is_i32 := M.alloc (| is_i32 |) in + let value := M.alloc (| value |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_bn", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "encode_cell" + |); + M.read (| ctx |); + M.alloc (| + M.call_closure (| + M.get_function (| + "specs::encode::memory_table::encode_memory_table_entry", + [ Ty.path "num_bigint::biguint::BigUint" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ Ty.path "num_bigint::biguint::BigUint" ], + "into", + [] + |), + [ M.rust_cast (M.read (| offset |)) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ Ty.path "num_bigint::biguint::BigUint" ], + "into", + [] + |), + [ M.rust_cast (M.read (| l_type |)) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ Ty.path "num_bigint::biguint::BigUint" ], + "into", + [] + |), + [ M.rust_cast (M.read (| is_i32 |)) ] + |) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "start_eid_cell" + |); + M.read (| ctx |); + M.read (| eid |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "end_eid_cell" + |); + M.read (| ctx |); + M.read (| end_eid |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "value_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| value |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_circuits_etable_allocator_AllocatedMemoryTableLookupWriteCell_F. + + (* + Enum EventTableCellType + { + ty_params := []; + variants := + [ + { + name := "Bit"; + item := StructTuple []; + discriminant := Some 1; + }; + { + name := "U8"; + item := StructTuple []; + discriminant := None; + }; + { + name := "U16"; + item := StructTuple []; + discriminant := None; + }; + { + name := "CommonRange"; + item := StructTuple []; + discriminant := None; + }; + { + name := "Unlimited"; + item := StructTuple []; + discriminant := None; + }; + { + name := "MTableLookup"; + item := StructTuple []; + discriminant := None; + }; + { + name := "JTableLookup"; + item := StructTuple []; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_fmt_Debug_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellType. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ + M.read (| f |); + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| M.read (| Value.String "Bit" |) |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| M.read (| Value.String "U8" |) |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| M.read (| Value.String "U16" |) |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| M.read (| Value.String "CommonRange" |) |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| M.read (| Value.String "Unlimited" |) |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| M.read (| Value.String "MTableLookup" |) |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| M.read (| Value.String "JTableLookup" |) |))) + ] + |) + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellType. + + Module Impl_core_clone_Clone_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellType. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| M.read (| self |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellType. + + Module Impl_core_marker_Copy_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellType. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellType. + + Module Impl_core_marker_StructuralPartialEq_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellType. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellType. + + Module Impl_core_cmp_PartialEq_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellType. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType" + ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType" + ] + |), + [ M.read (| other |) ] + |) + |) in + M.alloc (| BinOp.Pure.eq (M.read (| __self_tag |)) (M.read (| __arg1_tag |)) |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellType. + + Module Impl_core_marker_StructuralEq_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellType. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralEq_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellType. + + Module Impl_core_cmp_Eq_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellType. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType". + + (* Eq *) + Definition assert_receiver_is_total_eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.Tuple [])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Eq" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("assert_receiver_is_total_eq", InstanceField.Method assert_receiver_is_total_eq) ]. + End Impl_core_cmp_Eq_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellType. + + Module Impl_core_cmp_PartialOrd_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellType. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType". + + (* PartialOrd *) + Definition partial_cmp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType" + ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType" + ] + |), + [ M.read (| other |) ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "isize", + [ Ty.path "isize" ], + "partial_cmp", + [] + |), + [ __self_tag; __arg1_tag ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialOrd" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("partial_cmp", InstanceField.Method partial_cmp) ]. + End Impl_core_cmp_PartialOrd_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellType. + + Module Impl_core_cmp_Ord_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellType. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType". + + (* Ord *) + Definition cmp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType" + ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType" + ] + |), + [ M.read (| other |) ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::cmp::Ord", Ty.path "isize", [], "cmp", [] |), + [ __self_tag; __arg1_tag ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Ord" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("cmp", InstanceField.Method cmp) ]. + End Impl_core_cmp_Ord_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellType. + + Definition value_BIT_COLUMNS : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 12 |))). + + Definition value_U8_COLUMNS : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 1 |))). + + Definition value_U32_CELLS : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 2 |))). + + Definition value_U32_PERMUTATION_CELLS : Value.t := + M.run + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use (M.alloc (| Value.Bool false |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| Value.Integer 10 |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Integer 0 |))) + ] + |))). + + Definition value_U64_CELLS : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 5 |))). + + Definition value_U16_COLUMNS : Value.t := + M.run + ltac:(M.monadic + (M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.get_constant (| "delphinus_zkwasm::circuits::etable::allocator::U64_CELLS" |) + |), + BinOp.Panic.div (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| Ty.path "usize", "next_multiple_of", [] |), + [ + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::etable::allocator::U32_CELLS" + |) + |), + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::etable::allocator::U32_PERMUTATION_CELLS" + |) + |) + |); + Value.Integer 2 + ] + |), + Value.Integer 2 + |) + |) + |))). + + Definition value_COMMON_RANGE_COLUMNS : Value.t := + M.run + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use (M.alloc (| Value.Bool false |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| Value.Integer 4 |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Integer 6 |))) + ] + |))). + + Definition value_UNLIMITED_COLUMNS : Value.t := + M.run + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use (M.alloc (| Value.Bool false |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| Value.Integer 10 |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Integer 7 |))) + ] + |))). + + Definition value_MEMORY_TABLE_LOOKUP_COLUMNS : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 2 |))). + + Definition value_JUMP_TABLE_LOOKUP_COLUMNS : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 1 |))). + + (* StructRecord + { + name := "AllocatedBitTableLookupCells"; + ty_params := [ "F" ]; + fields := + [ + ("op", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("left", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("right", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("result", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedBitTableLookupCells_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells") + [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells" + [ + ("op", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells", + "op" + |) + ] + |)); + ("left", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells", + "left" + |) + ] + |)); + ("right", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells", + "right" + |) + ] + |)); + ("result", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells", + "result" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedBitTableLookupCells_F. + + Module Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedBitTableLookupCells_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells") + [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Copy" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_where_core_marker_Copy_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_AllocatedBitTableLookupCells_F. + + Module Impl_delphinus_zkwasm_circuits_etable_allocator_AllocatedBitTableLookupCells_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells") + [ F ]. + + (* + pub(crate) fn assign( + &self, + ctx: &mut Context<'_, F>, + op: BitTableOp, + left: u64, + right: u64, + result: u64, + ) -> Result<(), Error> { + self.op.assign(ctx, F::from(op.index() as u64))?; + self.left.assign(ctx, F::from(left))?; + self.right.assign(ctx, F::from(right))?; + self.result.assign(ctx, F::from(result))?; + + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; op; _ as left; _ as right; result ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let op := M.alloc (| op |) in + let left := M.alloc (| left |) in + let right := M.alloc (| right |) in + let result := M.alloc (| result |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells", + "op" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::bit_table::BitTableOp", + "index", + [] + |), + [ op ] + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells", + "left" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| left |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells", + "right" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| right |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells", + "result" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| result |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_circuits_etable_allocator_AllocatedBitTableLookupCells_F. + + (* StructRecord + { + name := "AllocatorFreeCellsProfiler"; + ty_params := []; + fields := + [ + ("free_cells", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]); + ("free_u32_cells", Ty.path "usize"); + ("free_u32_permutation_cells", Ty.path "usize"); + ("free_u64_cells", Ty.path "usize") + ]; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_allocator_AllocatorFreeCellsProfiler. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler". + + (* + pub(crate) fn new(allocator: &EventTableCellAllocator) -> Self { + Self { + free_cells: allocator.free_cells.clone(), + free_u32_cells: allocator.free_u32_cells.len(), + free_u32_permutation_cells: allocator.free_u32_permutation_cells.len(), + free_u64_cells: allocator.free_u64_cells.len(), + } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ allocator ] => + ltac:(M.monadic + (let allocator := M.alloc (| allocator |) in + Value.StructRecord + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler" + [ + ("free_cells", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| allocator |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_cells" + |) + ] + |)); + ("free_u32_cells", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| allocator |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_u32_cells" + |) + ] + |)); + ("free_u32_permutation_cells", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| allocator |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_u32_permutation_cells" + |) + ] + |)); + ("free_u64_cells", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| allocator |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_u64_cells" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + + (* + pub(crate) fn update(&mut self, allocator: &EventTableCellAllocator) { + for (t, (i, j)) in allocator.free_cells.iter() { + let v = self.free_cells.get_mut(t).unwrap(); + + if *i > v.0 { + v.0 = *i; + v.1 = *j; + } else if *i == v.0 { + v.1 = u32::max(v.1, *j); + } + } + + self.free_u32_cells = usize::min(self.free_u32_cells, allocator.free_u32_cells.len()); + self.free_u32_permutation_cells = usize::min( + self.free_u32_permutation_cells, + allocator.free_u32_permutation_cells.len(), + ); + self.free_u64_cells = usize::min(self.free_u64_cells, allocator.free_u64_cells.len()); + } + *) + Definition update (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ self; allocator ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let allocator := M.alloc (| allocator |) in + M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + "iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| allocator |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_cells" + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let t := M.copy (| γ1_0 |) in + let γ1_1 := M.read (| γ1_1 |) in + let γ3_0 := M.SubPointer.get_tuple_field (| γ1_1, 0 |) in + let γ3_1 := M.SubPointer.get_tuple_field (| γ1_1, 1 |) in + let i := M.alloc (| γ3_0 |) in + let j := M.alloc (| γ3_1 |) in + let v := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.tuple + [ Ty.path "usize"; Ty.path "u32" ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.tuple + [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + "get_mut", + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "free_cells" + |); + M.read (| t |) + ] + |) + ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| M.read (| i |) |)) + (M.read (| + M.SubPointer.get_tuple_field (| + M.read (| v |), + 0 + |) + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.write (| + M.SubPointer.get_tuple_field (| + M.read (| v |), + 0 + |), + M.read (| M.read (| i |) |) + |) in + let _ := + M.write (| + M.SubPointer.get_tuple_field (| + M.read (| v |), + 1 + |), + M.read (| M.read (| j |) |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| M.read (| i |) |)) + (M.read (| + M.SubPointer.get_tuple_field (| + M.read (| v |), + 0 + |) + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.write (| + M.SubPointer.get_tuple_field (| + M.read (| v |), + 1 + |), + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path "u32", + [], + "max", + [] + |), + [ + M.read (| + M.SubPointer.get_tuple_field (| + M.read (| v |), + 1 + |) + |); + M.read (| M.read (| j |) |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "free_u32_cells" + |), + M.call_closure (| + M.get_trait_method (| "core::cmp::Ord", Ty.path "usize", [], "min", [] |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "free_u32_cells" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| allocator |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_u32_cells" + |) + ] + |) + ] + |) + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "free_u32_permutation_cells" + |), + M.call_closure (| + M.get_trait_method (| "core::cmp::Ord", Ty.path "usize", [], "min", [] |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "free_u32_permutation_cells" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| allocator |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_u32_permutation_cells" + |) + ] + |) + ] + |) + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "free_u64_cells" + |), + M.call_closure (| + M.get_trait_method (| "core::cmp::Ord", Ty.path "usize", [], "min", [] |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "free_u64_cells" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| allocator |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_u64_cells" + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_update : M.IsAssociatedFunction Self "update" update. + + (* + pub(crate) fn assert_no_free_cells(&self, allocator: &EventTableCellAllocator) { + for (t, (i, j)) in &self.free_cells { + let cols = allocator.all_cols.get(t).unwrap(); + + assert!( + *i == cols.len() || ( *i == cols.len() - 1 && *j > 0), + "unused {:?} col should be removed: {}.", + t, + cols.len() - *i - ( *j != 0) as usize + ); + } + + assert!( + self.free_u32_cells == 0, + "unused u32 cells should be removed: {:?}.", + self.free_u32_cells + ); + assert!( + self.free_u32_permutation_cells == 0, + "unused u32 permutation cells should be removed: {:?}.", + self.free_u32_permutation_cells + ); + assert!( + self.free_u64_cells == 0, + "unused u64 cells should be removed: {:?}.", + self.free_u64_cells + ); + } + *) + Definition assert_no_free_cells (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ self; allocator ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let allocator := M.alloc (| allocator |) in + M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "free_cells" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let t := M.copy (| γ1_0 |) in + let γ1_1 := M.read (| γ1_1 |) in + let γ3_0 := M.SubPointer.get_tuple_field (| γ1_1, 0 |) in + let γ3_1 := M.SubPointer.get_tuple_field (| γ1_1, 1 |) in + let i := M.alloc (| γ3_0 |) in + let j := M.alloc (| γ3_1 |) in + let cols := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "get", + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| allocator |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "all_cols" + |); + M.read (| t |) + ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (LogicalOp.or (| + BinOp.Pure.eq + (M.read (| M.read (| i |) |)) + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| cols |) ] + |)), + ltac:(M.monadic + (LogicalOp.and (| + BinOp.Pure.eq + (M.read (| M.read (| i |) |)) + (BinOp.Panic.sub (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| cols |) ] + |), + Value.Integer 1 + |)), + ltac:(M.monadic + (BinOp.Pure.gt + (M.read (| M.read (| j |) |)) + (Value.Integer 0))) + |))) + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic_fmt", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String "unused " + |); + M.read (| + Value.String + " col should be removed: " + |); + M.read (| + Value.String "." + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_debug", + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType" + ] + ] + |), + [ t ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + BinOp.Panic.sub (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.read (| + cols + |) + ] + |), + M.read (| + M.read (| i |) + |) + |), + M.rust_cast + (BinOp.Pure.ne + (M.read (| + M.read (| j |) + |)) + (Value.Integer + 0)) + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) + |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "free_u32_cells" + |) + |)) + (Value.Integer 0)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic_fmt", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String "unused u32 cells should be removed: " + |); + M.read (| Value.String "." |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "free_u32_cells" + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "free_u32_permutation_cells" + |) + |)) + (Value.Integer 0)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic_fmt", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "unused u32 permutation cells should be removed: " + |); + M.read (| Value.String "." |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "free_u32_permutation_cells" + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "free_u64_cells" + |) + |)) + (Value.Integer 0)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic_fmt", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String "unused u64 cells should be removed: " + |); + M.read (| Value.String "." |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "free_u64_cells" + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assert_no_free_cells : + M.IsAssociatedFunction Self "assert_no_free_cells" assert_no_free_cells. + End Impl_delphinus_zkwasm_circuits_etable_allocator_AllocatorFreeCellsProfiler. + + (* StructRecord + { + name := "EventTableCellAllocator"; + ty_params := [ "F" ]; + fields := + [ + ("k", Ty.path "u32"); + ("free_cells", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]); + ("all_cols", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]); + ("free_u32_cells", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") [ F ]; + Ty.path "alloc::alloc::Global" + ]); + ("free_u32_permutation_cells", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + ("free_u64_cells", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]; + Ty.path "alloc::alloc::Global" + ]); + ("_mark", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellAllocator_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let names := + M.alloc (| + M.alloc (| + Value.Array + [ + M.read (| Value.String "k" |); + M.read (| Value.String "free_cells" |); + M.read (| Value.String "all_cols" |); + M.read (| Value.String "free_u32_cells" |); + M.read (| Value.String "free_u32_permutation_cells" |); + M.read (| Value.String "free_u64_cells" |); + M.read (| Value.String "_mark" |) + ] + |) + |) in + let values := + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "k" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_cells" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "all_cols" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_u32_cells" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_u32_permutation_cells" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_u64_cells" + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "_mark" + |) + |)) + ] + |)) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_fields_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "EventTableCellAllocator" |); + (* Unsize *) M.pointer_coercion (M.read (| names |)); + M.read (| values |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellAllocator_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellAllocator_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator" + [ + ("k", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "k" + |) + ] + |)); + ("free_cells", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_cells" + |) + ] + |)); + ("all_cols", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "all_cols" + |) + ] + |)); + ("free_u32_cells", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_u32_cells" + |) + ] + |)); + ("free_u32_permutation_cells", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_u32_permutation_cells" + |) + ] + |)); + ("free_u64_cells", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_u64_cells" + |) + ] + |)); + ("_mark", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "_mark" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_allocator_EventTableCellAllocator_F. + + Module Impl_delphinus_zkwasm_circuits_etable_allocator_EventTableCellAllocator_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ]. + + (* + pub fn enable_equality( + &mut self, + meta: &mut ConstraintSystem, + t: &EventTableCellType, + count: usize, + ) { + for c in self.all_cols.get(t).unwrap().iter().take(count) { + for c in c { + meta.enable_equality( *c); + } + } + } + *) + Definition enable_equality (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta; t; count ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let t := M.alloc (| t |) in + let count := M.alloc (| count |) in + M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::take::Take") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "take", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "get", + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "all_cols" + |); + M.read (| t |) + ] + |) + ] + |) + ] + |) + ] + |); + M.read (| count |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::take::Take") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let c := M.copy (| γ0_0 |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ M.read (| c |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let c := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "enable_equality", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ] + |), + [ + M.read (| meta |); + M.read (| M.read (| c |) |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_enable_equality : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "enable_equality" (enable_equality F). + + (* + pub(super) fn prepare_alloc_u32_cell(&mut self) -> AllocatedU32Cell { + let u16_cells_le = [0; 2].map(|_| self.alloc_u16_cell()); + + AllocatedU32Cell { u16_cells_le } + } + *) + Definition prepare_alloc_u32_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let u16_cells_le := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.path "i32" ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "i32" ] ] + (Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ]); + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ] + ] + |), + [ + repeat (Value.Integer 0) 2; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u16_cell", + [] + |), + [ M.read (| self |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell" + [ ("u16_cells_le", M.read (| u16_cells_le |)) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_prepare_alloc_u32_cell : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "prepare_alloc_u32_cell" (prepare_alloc_u32_cell F). + + (* + pub(super) fn prepare_alloc_u32_permutation_cell( + &mut self, + meta: &mut ConstraintSystem, + enable: impl Fn(&mut VirtualCells<'_, F>) -> Expression, + ) -> AllocatedU32PermutationCell { + let u16_cells_le = [0; 2].map(|_| self.alloc_u16_cell()); + let u32_cell = self.alloc_unlimited_cell(); + meta.create_gate("c9. u32 decompose", |meta| { + let init = u32_cell.curr_expr(meta); + vec![ + (0..2) + .into_iter() + .map(|x| u16_cells_le[x].curr_expr(meta) * constant_from!(1u64 << (16 * x))) + .fold(init, |acc, x| acc - x) + * enable(meta), + ] + }); + meta.enable_equality(u32_cell.cell.col); + + AllocatedU32PermutationCell { + u16_cells_le, + u32_cell, + } + } + *) + Definition prepare_alloc_u32_permutation_cell + (F : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_ ], [ self; meta; enable ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let enable := M.alloc (| enable |) in + M.read (| + let u16_cells_le := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.path "i32" ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "i32" ] ] + (Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ]); + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ] + ] + |), + [ + repeat (Value.Integer 0) 2; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u16_cell", + [] + |), + [ M.read (| self |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let u32_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| self |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c9. u32 decompose" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let init := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ u32_cell; M.read (| meta |) ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ + Ty.tuple + [ Ty.path "usize" ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "fold", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ Ty.path "usize" + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + Value.Integer + 0); + ("end_", + Value.Integer 2) + ] + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let x := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ + F + ], + [ + F + ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + u16_cells_le, + x + |); + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + Value.Integer + 1, + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer + 16, + M.read (| + x + |) + |) + |) + |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |); + M.read (| init |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (let + x := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "sub", + [] + |), + [ + M.read (| + acc + |); + M.read (| + x + |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + enable; + Value.Tuple + [ M.read (| meta |) ] + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "enable_equality", + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + u32_cell, + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell", + "cell" + |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "col" + |) + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell" + [ + ("u16_cells_le", M.read (| u16_cells_le |)); + ("u32_cell", M.read (| u32_cell |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_prepare_alloc_u32_permutation_cell : + forall (F : Ty.t), + M.IsAssociatedFunction + (Self F) + "prepare_alloc_u32_permutation_cell" + (prepare_alloc_u32_permutation_cell F). + + (* + pub(super) fn prepare_alloc_u64_cell( + &mut self, + meta: &mut ConstraintSystem, + enable: impl Fn(&mut VirtualCells<'_, F>) -> Expression, + ) -> AllocatedU64Cell { + let u16_cells_le = [0; 4].map(|_| self.alloc_u16_cell()); + let u64_cell = self.alloc_unlimited_cell(); + meta.create_gate("c9. u64 decompose", |meta| { + let init = u64_cell.curr_expr(meta); + vec![ + (0..4) + .into_iter() + .map(|x| u16_cells_le[x].curr_expr(meta) * constant_from!(1u64 << (16 * x))) + .fold(init, |acc, x| acc - x) + * enable(meta), + ] + }); + AllocatedU64Cell { + u16_cells_le, + u64_cell, + } + } + *) + Definition prepare_alloc_u64_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_ ], [ self; meta; enable ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let enable := M.alloc (| enable |) in + M.read (| + let u16_cells_le := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.path "i32" ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "i32" ] ] + (Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ]); + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ] + ] + |), + [ + repeat (Value.Integer 0) 4; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u16_cell", + [] + |), + [ M.read (| self |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let u64_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| self |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c9. u64 decompose" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let init := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ u64_cell; M.read (| meta |) ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ + Ty.tuple + [ Ty.path "usize" ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "fold", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ Ty.path "usize" + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + Value.Integer + 0); + ("end_", + Value.Integer 4) + ] + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let x := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ + F + ], + [ + F + ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + u16_cells_le, + x + |); + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + Value.Integer + 1, + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer + 16, + M.read (| + x + |) + |) + |) + |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |); + M.read (| init |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (let + x := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "sub", + [] + |), + [ + M.read (| + acc + |); + M.read (| + x + |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + enable; + Value.Tuple + [ M.read (| meta |) ] + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell" + [ + ("u16_cells_le", M.read (| u16_cells_le |)); + ("u64_cell", M.read (| u64_cell |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_prepare_alloc_u64_cell : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "prepare_alloc_u64_cell" (prepare_alloc_u64_cell F). + + (* + pub(super) fn new( + meta: &mut ConstraintSystem, + k: u32, + sel: Column, + rtable: &RangeTableConfig, + mtable: &impl ConfigureLookupTable, + jtable: &JumpTableConfig, + cols: &mut impl Iterator>, + ) -> Self { + let mut allocator = Self::_new(meta, k, sel, rtable, mtable, jtable, cols); + for _ in 0..U32_CELLS { + let cell = allocator.prepare_alloc_u32_cell(); + allocator.free_u32_cells.push(cell); + } + for _ in 0..U32_PERMUTATION_CELLS { + let cell = + allocator.prepare_alloc_u32_permutation_cell(meta, |meta| fixed_curr!(meta, sel)); + allocator.free_u32_permutation_cells.push(cell); + } + for _ in 0..U64_CELLS { + let cell = allocator.prepare_alloc_u64_cell(meta, |meta| fixed_curr!(meta, sel)); + allocator.free_u64_cells.push(cell); + } + allocator + } + *) + Definition new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_ConfigureLookupTable_F_; impl_Iterator_Item___Column_Advice__ ], + [ meta; k; sel; rtable; mtable; jtable; cols ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + let k := M.alloc (| k |) in + let sel := M.alloc (| sel |) in + let rtable := M.alloc (| rtable |) in + let mtable := M.alloc (| mtable |) in + let jtable := M.alloc (| jtable |) in + let cols := M.alloc (| cols |) in + M.read (| + let allocator := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "_new", + [ impl_ConfigureLookupTable_F_; impl_Iterator_Item___Column_Advice__ ] + |), + [ + M.read (| meta |); + M.read (| k |); + M.read (| sel |); + M.read (| rtable |); + M.read (| mtable |); + M.read (| jtable |); + M.read (| cols |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::etable::allocator::U32_CELLS" + |) + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "prepare_alloc_u32_cell", + [] + |), + [ allocator ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + allocator, + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_u32_cells" + |); + M.read (| cell |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::etable::allocator::U32_PERMUTATION_CELLS" + |) + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "prepare_alloc_u32_permutation_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + allocator; + M.read (| meta |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + allocator, + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_u32_permutation_cells" + |); + M.read (| cell |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::etable::allocator::U64_CELLS" + |) + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "prepare_alloc_u64_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + allocator; + M.read (| meta |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + allocator, + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_u64_cells" + |); + M.read (| cell |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + allocator + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "new" (new F). + + (* + fn _new( + meta: &mut ConstraintSystem, + k: u32, + sel: Column, + rtable: &RangeTableConfig, + mtable: &impl ConfigureLookupTable, + jtable: &JumpTableConfig, + cols: &mut impl Iterator>, + ) -> Self { + let mut all_cols = BTreeMap::new(); + all_cols.insert( + EventTableCellType::Bit, + [0; BIT_COLUMNS] + .map(|_| vec![BitColumn::configure(meta, cols, |meta| fixed_curr!(meta, sel)).col]) + .into_iter() + .collect(), + ); + all_cols.insert( + EventTableCellType::U8, + [0; U8_COLUMNS] + .map(|_| vec![U8Column::configure(meta, cols, rtable, |_| constant_from!(1)).col]) + .into_iter() + .collect(), + ); + all_cols.insert( + EventTableCellType::U16, + [0; U16_COLUMNS] + .map(|_| vec![U16Column::configure(meta, cols, rtable, |_| constant_from!(1)).col]) + .into_iter() + .collect(), + ); + all_cols.insert( + EventTableCellType::CommonRange, + [0; COMMON_RANGE_COLUMNS] + .map(|_| { + vec![ + CommonRangeColumn::configure(meta, cols, rtable, |_| constant_from!(1)).col, + ] + }) + .into_iter() + .collect(), + ); + all_cols.insert( + EventTableCellType::Unlimited, + [0; UNLIMITED_COLUMNS] + .map(|_| vec![cols.next().unwrap()]) + .into_iter() + .collect(), + ); + all_cols.insert( + EventTableCellType::JTableLookup, + [0; JUMP_TABLE_LOOKUP_COLUMNS] + .map(|_| { + let col = cols.next().unwrap(); + jtable.configure_in_table(meta, "c8c. jtable_lookup in jtable", |meta| { + curr!(meta, col) + }); + vec![col] + }) + .into_iter() + .collect(), + ); + all_cols.insert( + EventTableCellType::MTableLookup, + [0; MEMORY_TABLE_LOOKUP_COLUMNS] + .map(|_| { + let start_eid_col = cols.next().unwrap(); + let end_eid_col = cols.next().unwrap(); + let encode_col = cols.next().unwrap(); + let value_col = cols.next().unwrap(); + mtable.configure_in_table(meta, "c8e. mtable_lookup in mtable", |meta| { + vec![ + curr!(meta, start_eid_col), + curr!(meta, end_eid_col), + curr!(meta, encode_col), + curr!(meta, value_col), + ] + }); + vec![start_eid_col, end_eid_col, encode_col, value_col] + }) + .into_iter() + .collect(), + ); + + Self { + k, + all_cols, + free_cells: BTreeMap::from_iter( + vec![ + (EventTableCellType::Bit, (0, 0)), + (EventTableCellType::U8, (0, 0)), + (EventTableCellType::U16, (0, 0)), + (EventTableCellType::CommonRange, (0, 0)), + (EventTableCellType::Unlimited, (0, 0)), + (EventTableCellType::MTableLookup, (0, 0)), + (EventTableCellType::JTableLookup, (0, 0)), + ] + .into_iter(), + ), + free_u32_cells: vec![], + free_u32_permutation_cells: vec![], + free_u64_cells: vec![], + _mark: PhantomData, + } + } + *) + Definition _new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_ConfigureLookupTable_F_; impl_Iterator_Item___Column_Advice__ ], + [ meta; k; sel; rtable; mtable; jtable; cols ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + let k := M.alloc (| k |) in + let sel := M.alloc (| sel |) in + let rtable := M.alloc (| rtable |) in + let mtable := M.alloc (| mtable |) in + let jtable := M.alloc (| jtable |) in + let cols := M.alloc (| cols |) in + M.read (| + let all_cols := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + all_cols; + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::Bit" + []; + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.path "i32" ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "i32" ] ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + repeat (Value.Integer 0) 12; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::bit::BitColumn") + [ F ], + "configure", + [ + impl_Iterator_Item___Column_Advice__; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| meta |); + M.read (| cols |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + meta := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ], + "query_fixed", + [] + |), + [ + M.read (| + meta + |); + M.read (| + sel + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |), + "delphinus_zkwasm::circuits::utils::bit::BitColumn", + "col" + |) + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + all_cols; + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::U8" + []; + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.path "i32" ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "i32" ] ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + repeat (Value.Integer 0) 1; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::u8::U8Column") + [ F ], + "configure", + [ + impl_Iterator_Item___Column_Advice__; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| meta |); + M.read (| cols |); + M.read (| rtable |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |), + "delphinus_zkwasm::circuits::utils::u8::U8Column", + "col" + |) + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + all_cols; + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::U16" + []; + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.path "i32" ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "i32" ] ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + repeat (Value.Integer 0) 6; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::u16::U16Column") + [ F ], + "configure", + [ + impl_Iterator_Item___Column_Advice__; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| meta |); + M.read (| cols |); + M.read (| rtable |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |), + "delphinus_zkwasm::circuits::utils::u16::U16Column", + "col" + |) + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + all_cols; + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::CommonRange" + []; + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.path "i32" ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "i32" ] ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + repeat (Value.Integer 0) 6; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::common_range::CommonRangeColumn") + [ F ], + "configure", + [ + impl_Iterator_Item___Column_Advice__; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| meta |); + M.read (| cols |); + M.read (| rtable |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + |), + "delphinus_zkwasm::circuits::utils::common_range::CommonRangeColumn", + "col" + |) + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + all_cols; + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::Unlimited" + []; + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.path "i32" ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "i32" ] ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + repeat (Value.Integer 0) 7; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___Column_Advice__, + [], + "next", + [] + |), + [ M.read (| cols |) ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + all_cols; + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::JTableLookup" + []; + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.path "i32" ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "i32" ] ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + repeat (Value.Integer 0) 1; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let col := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___Column_Advice__, + [], + "next", + [] + |), + [ M.read (| cols |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::Lookup", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + [ F ], + "configure_in_table", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| jtable |); + M.read (| meta |); + M.read (| + Value.String + "c8c. jtable_lookup in jtable" + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := + M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| col |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ M.read (| col |) ] + |) + ] + |) + |)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + all_cols; + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::MTableLookup" + []; + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.path "i32" ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "i32" ] ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + repeat (Value.Integer 0) 2; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let start_eid_col := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___Column_Advice__, + [], + "next", + [] + |), + [ M.read (| cols |) ] + |) + ] + |) + |) in + let end_eid_col := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___Column_Advice__, + [], + "next", + [] + |), + [ M.read (| cols |) ] + |) + ] + |) + |) in + let encode_col := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___Column_Advice__, + [], + "next", + [] + |), + [ M.read (| cols |) ] + |) + ] + |) + |) in + let value_col := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___Column_Advice__, + [], + "next", + [] + |), + [ M.read (| cols |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::traits::ConfigureLookupTable", + impl_ConfigureLookupTable_F_, + [ F ], + "configure_in_table", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| mtable |); + M.read (| meta |); + M.read (| + Value.String + "c8e. mtable_lookup in mtable" + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := + M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ + Ty.path + "alloc::alloc::Global" + ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ], + "query_advice", + [] + |), + [ + M.read (| + meta + |); + M.read (| + start_eid_col + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ], + "query_advice", + [] + |), + [ + M.read (| + meta + |); + M.read (| + end_eid_col + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ], + "query_advice", + [] + |), + [ + M.read (| + meta + |); + M.read (| + encode_col + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ], + "query_advice", + [] + |), + [ + M.read (| + meta + |); + M.read (| + value_col + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.read (| + start_eid_col + |); + M.read (| end_eid_col |); + M.read (| encode_col |); + M.read (| value_col |) + ] + |) + ] + |) + |)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator" + [ + ("k", M.read (| k |)); + ("all_cols", M.read (| all_cols |)); + ("free_cells", + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::FromIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.tuple + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] + ] + ], + "from_iter", + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::Bit" + []; + Value.Tuple + [ Value.Integer 0; Value.Integer 0 ] + ]; + Value.Tuple + [ + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::U8" + []; + Value.Tuple + [ Value.Integer 0; Value.Integer 0 ] + ]; + Value.Tuple + [ + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::U16" + []; + Value.Tuple + [ Value.Integer 0; Value.Integer 0 ] + ]; + Value.Tuple + [ + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::CommonRange" + []; + Value.Tuple + [ Value.Integer 0; Value.Integer 0 ] + ]; + Value.Tuple + [ + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::Unlimited" + []; + Value.Tuple + [ Value.Integer 0; Value.Integer 0 ] + ]; + Value.Tuple + [ + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::MTableLookup" + []; + Value.Tuple + [ Value.Integer 0; Value.Integer 0 ] + ]; + Value.Tuple + [ + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::JTableLookup" + []; + Value.Tuple + [ Value.Integer 0; Value.Integer 0 ] + ] + ] + |) + ] + |) + |)) + ] + |) + ] + |) + ] + |)); + ("free_u32_cells", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("free_u32_permutation_cells", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("free_u64_cells", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("_mark", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction__new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "_new" (_new F). + + (* + fn alloc(&mut self, t: &EventTableCellType) -> AllocatedCell { + let v = self.free_cells.get_mut(t).unwrap(); + + let res = AllocatedCell { + col: self.all_cols.get(t).unwrap()[v.0][0], + rot: v.1 as i32, + _mark: PhantomData, + }; + + v.1 += 1; + if v.1 == EVENT_TABLE_ENTRY_ROWS as u32 { + v.0 += 1; + v.1 = 0; + } + + res + } + *) + Definition alloc (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; t ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let t := M.alloc (| t |) in + M.read (| + let v := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + "get_mut", + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_cells" + |); + M.read (| t |) + ] + |) + ] + |) + |) in + let res := + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedCell" + [ + ("col", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "get", + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "all_cols" + |); + M.read (| t |) + ] + |) + ] + |); + M.read (| + M.SubPointer.get_tuple_field (| M.read (| v |), 0 |) + |) + ] + |); + Value.Integer 0 + ] + |) + |)); + ("rot", + M.rust_cast + (M.read (| M.SubPointer.get_tuple_field (| M.read (| v |), 1 |) |))); + ("_mark", Value.StructTuple "core::marker::PhantomData" []) + ] + |) in + let _ := + let β := M.SubPointer.get_tuple_field (| M.read (| v |), 1 |) in + M.write (| + β, + BinOp.Panic.add (| Integer.U32, M.read (| β |), Value.Integer 1 |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| + M.SubPointer.get_tuple_field (| M.read (| v |), 1 |) + |)) + (M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::etable::EVENT_TABLE_ENTRY_ROWS" + |) + |))) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let _ := + let β := M.SubPointer.get_tuple_field (| M.read (| v |), 0 |) in + M.write (| + β, + BinOp.Panic.add (| Integer.Usize, M.read (| β |), Value.Integer 1 |) + |) in + let _ := + M.write (| + M.SubPointer.get_tuple_field (| M.read (| v |), 1 |), + Value.Integer 0 + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + res + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "alloc" (alloc F). + + (* + fn alloc_group(&mut self, t: &EventTableCellType) -> Vec> { + let v = self.free_cells.get_mut(t).unwrap(); + + let res = self.all_cols.get(t).unwrap()[v.0] + .iter() + .map(|col| AllocatedCell { + col: *col, + rot: v.1 as i32, + _mark: PhantomData, + }) + .collect(); + + v.1 += 1; + if v.1 == EVENT_TABLE_ENTRY_ROWS as u32 { + v.0 += 1; + v.1 = 0; + } + + res + } + *) + Definition alloc_group (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; t ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let t := M.alloc (| t |) in + M.read (| + let v := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + "get_mut", + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_cells" + |); + M.read (| t |) + ] + |) + ] + |) + |) in + let res := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ] + ] + ] + (Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + [], + "map", + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ] + ] + ] + (Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "get", + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "all_cols" + |); + M.read (| t |) + ] + |) + ] + |); + M.read (| + M.SubPointer.get_tuple_field (| M.read (| v |), 0 |) + |) + ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let col := M.copy (| γ |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedCell" + [ + ("col", M.read (| M.read (| col |) |)); + ("rot", + M.rust_cast + (M.read (| + M.SubPointer.get_tuple_field (| + M.read (| v |), + 1 + |) + |))); + ("_mark", + Value.StructTuple "core::marker::PhantomData" []) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let _ := + let β := M.SubPointer.get_tuple_field (| M.read (| v |), 1 |) in + M.write (| + β, + BinOp.Panic.add (| Integer.U32, M.read (| β |), Value.Integer 1 |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| + M.SubPointer.get_tuple_field (| M.read (| v |), 1 |) + |)) + (M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::etable::EVENT_TABLE_ENTRY_ROWS" + |) + |))) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let _ := + let β := M.SubPointer.get_tuple_field (| M.read (| v |), 0 |) in + M.write (| + β, + BinOp.Panic.add (| Integer.Usize, M.read (| β |), Value.Integer 1 |) + |) in + let _ := + M.write (| + M.SubPointer.get_tuple_field (| M.read (| v |), 1 |), + Value.Integer 0 + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + res + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_group : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "alloc_group" (alloc_group F). + + (* + pub(crate) fn alloc_bit_cell(&mut self) -> AllocatedBitCell { + AllocatedBitCell { + cell: self.alloc(&EventTableCellType::Bit), + } + } + *) + Definition alloc_bit_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedBitCell" + [ + ("cell", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc", + [] + |), + [ + M.read (| self |); + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::Bit" + [] + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_bit_cell : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "alloc_bit_cell" (alloc_bit_cell F). + + (* + pub(crate) fn alloc_common_range_cell(&mut self) -> AllocatedCommonRangeCell { + AllocatedCommonRangeCell { + cell: self.alloc(&EventTableCellType::CommonRange), + upper_bound: F::from(common_range_max(self.k) as u64), + } + } + *) + Definition alloc_common_range_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell" + [ + ("cell", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc", + [] + |), + [ + M.read (| self |); + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::CommonRange" + [] + |) + ] + |)); + ("upper_bound", + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::config::common_range_max", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "k" + |) + |) + ] + |)) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_common_range_cell : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "alloc_common_range_cell" (alloc_common_range_cell F). + + (* + pub(crate) fn alloc_u32_state_cell(&mut self) -> AllocatedU32StateCell { + cfg_if::cfg_if! { + if #[cfg(feature = "continuation")] { + self.alloc_u32_permutation_cell() + } else { + self.alloc_common_range_cell() + } + } + } + *) + Definition alloc_u32_state_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| self |) ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_u32_state_cell : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "alloc_u32_state_cell" (alloc_u32_state_cell F). + + (* + pub(crate) fn alloc_u8_cell(&mut self) -> AllocatedU8Cell { + AllocatedU8Cell { + cell: self.alloc(&EventTableCellType::U8), + } + } + *) + Definition alloc_u8_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell" + [ + ("cell", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc", + [] + |), + [ + M.read (| self |); + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::U8" + [] + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_u8_cell : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "alloc_u8_cell" (alloc_u8_cell F). + + (* + pub(crate) fn alloc_u16_cell(&mut self) -> AllocatedU16Cell { + AllocatedU16Cell { + cell: self.alloc(&EventTableCellType::U16), + } + } + *) + Definition alloc_u16_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell" + [ + ("cell", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc", + [] + |), + [ + M.read (| self |); + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::U16" + [] + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_u16_cell : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "alloc_u16_cell" (alloc_u16_cell F). + + (* + pub(crate) fn alloc_unlimited_cell(&mut self) -> AllocatedUnlimitedCell { + AllocatedUnlimitedCell { + cell: self.alloc(&EventTableCellType::Unlimited), + } + } + *) + Definition alloc_unlimited_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell" + [ + ("cell", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc", + [] + |), + [ + M.read (| self |); + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::Unlimited" + [] + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_unlimited_cell : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "alloc_unlimited_cell" (alloc_unlimited_cell F). + + (* + pub(crate) fn alloc_jump_table_lookup_cell(&mut self) -> AllocatedJumpTableLookupCell { + AllocatedJumpTableLookupCell { + cell: self.alloc(&EventTableCellType::JTableLookup), + } + } + *) + Definition alloc_jump_table_lookup_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell" + [ + ("cell", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc", + [] + |), + [ + M.read (| self |); + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::JTableLookup" + [] + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_jump_table_lookup_cell : + forall (F : Ty.t), + M.IsAssociatedFunction + (Self F) + "alloc_jump_table_lookup_cell" + (alloc_jump_table_lookup_cell F). + + (* + pub(crate) fn alloc_memory_table_lookup_read_cell( + &mut self, + name: &'static str, + constraint_builder: &mut ConstraintBuilder, + eid: AllocatedU32StateCell, + location_type: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + offset: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + is_i32: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + value: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + enable: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + ) -> AllocatedMemoryTableLookupReadCell { + let cells: Vec<_> = self + .alloc_group(&EventTableCellType::MTableLookup) + .into_iter() + .map(|x| AllocatedUnlimitedCell { cell: x }) + .collect(); + + let cell = AllocatedMemoryTableLookupReadCell { + start_eid_cell: cells[0], + end_eid_cell: cells[1], + encode_cell: cells[2], + value_cell: cells[3], + start_eid_diff_cell: self.alloc_u32_state_cell(), + end_eid_diff_cell: self.alloc_u32_state_cell(), + }; + + constraint_builder.constraints.push(( + name, + Box::new(move |meta| { + let enable = enable(meta); + vec![ + (eid.expr(meta) + - cell.start_eid_cell.expr(meta) + - cell.start_eid_diff_cell.expr(meta) + - constant_from!(1)) + * enable.clone(), + (eid.expr(meta) + cell.end_eid_diff_cell.expr(meta) + - cell.end_eid_cell.expr(meta)) + * enable.clone(), + (encode_memory_table_entry(offset(meta), location_type(meta), is_i32(meta)) + - cell.encode_cell.expr(meta)) + * enable.clone(), + (cell.value_cell.expr(meta) - value(meta)) * enable, + ] + }), + )); + + cell + } + *) + Definition alloc_memory_table_lookup_read_cell + (F : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F in + match τ, α with + | [ + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'1; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'2; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'3; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'4 + ], + [ self; name; constraint_builder; eid; location_type; offset; is_i32; value; enable + ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + let constraint_builder := M.alloc (| constraint_builder |) in + let eid := M.alloc (| eid |) in + let location_type := M.alloc (| location_type |) in + let offset := M.alloc (| offset |) in + let is_i32 := M.alloc (| is_i32 |) in + let value := M.alloc (| value |) in + let enable := M.alloc (| enable |) in + M.read (| + let cells := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ] + ] + ] + (Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_group", + [] + |), + [ + M.read (| self |); + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::MTableLookup" + [] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell" + [ ("cell", M.read (| x |)) ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let cell := + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell" + [ + ("start_eid_cell", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ cells; Value.Integer 0 ] + |) + |)); + ("end_eid_cell", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ cells; Value.Integer 1 ] + |) + |)); + ("encode_cell", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ cells; Value.Integer 2 ] + |) + |)); + ("value_cell", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ cells; Value.Integer 3 ] + |) + |)); + ("start_eid_diff_cell", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u32_state_cell", + [] + |), + [ M.read (| self |) ] + |)); + ("end_eid_diff_cell", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u32_state_cell", + [] + |), + [ M.read (| self |) ] + |)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| constraint_builder |), + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder", + "constraints" + |); + Value.Tuple + [ + M.read (| name |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let enable := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'4, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + enable; + Value.Tuple [ M.read (| meta |) ] + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + eid; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cell, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "start_eid_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cell, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "start_eid_diff_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ enable ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + eid; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cell, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "end_eid_diff_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cell, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "end_eid_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ enable ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_function (| + "specs::encode::memory_table::encode_memory_table_entry", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'1, + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ] + ] + ] + ], + "call", + [] + |), + [ + offset; + Value.Tuple + [ + M.read (| + meta + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static, + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ] + ] + ] + ], + "call", + [] + |), + [ + location_type; + Value.Tuple + [ + M.read (| + meta + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'2, + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ] + ] + ] + ], + "call", + [] + |), + [ + is_i32; + Value.Tuple + [ + M.read (| + meta + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cell, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "encode_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ enable ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cell, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "value_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'3, + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F + ] + ] + ] + ], + "call", + [] + |), + [ + value; + Value.Tuple + [ + M.read (| + meta + |) + ] + ] + |) + ] + |); + M.read (| enable |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + ] + |) + |) in + cell + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_memory_table_lookup_read_cell : + forall (F : Ty.t), + M.IsAssociatedFunction + (Self F) + "alloc_memory_table_lookup_read_cell" + (alloc_memory_table_lookup_read_cell F). + + (* + pub(crate) fn alloc_memory_table_lookup_write_cell( + &mut self, + name: &'static str, + constraint_builder: &mut ConstraintBuilder, + eid: AllocatedU32StateCell, + location_type: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + offset: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + is_i32: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + value: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + enable: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + ) -> AllocatedMemoryTableLookupWriteCell { + let cells: Vec<_> = self + .alloc_group(&EventTableCellType::MTableLookup) + .into_iter() + .map(|x| AllocatedUnlimitedCell { cell: x }) + .collect(); + + let cell = AllocatedMemoryTableLookupWriteCell { + start_eid_cell: cells[0], + end_eid_cell: cells[1], + encode_cell: cells[2], + value_cell: cells[3], + }; + + constraint_builder.constraints.push(( + name, + Box::new(move |meta| { + let enable = enable(meta); + vec![ + (encode_memory_table_entry(offset(meta), location_type(meta), is_i32(meta)) + - cell.encode_cell.expr(meta)) + * enable.clone(), + (cell.start_eid_cell.expr(meta) - eid.expr(meta)) * enable.clone(), + (cell.value_cell.expr(meta) - value(meta)) * enable, + ] + }), + )); + + cell + } + *) + Definition alloc_memory_table_lookup_write_cell + (F : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F in + match τ, α with + | [ + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'1; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'2; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'3; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'4 + ], + [ self; name; constraint_builder; eid; location_type; offset; is_i32; value; enable + ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + let constraint_builder := M.alloc (| constraint_builder |) in + let eid := M.alloc (| eid |) in + let location_type := M.alloc (| location_type |) in + let offset := M.alloc (| offset |) in + let is_i32 := M.alloc (| is_i32 |) in + let value := M.alloc (| value |) in + let enable := M.alloc (| enable |) in + M.read (| + let cells := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ] + ] + ] + (Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_group", + [] + |), + [ + M.read (| self |); + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::MTableLookup" + [] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell" + [ ("cell", M.read (| x |)) ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let cell := + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell" + [ + ("start_eid_cell", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ cells; Value.Integer 0 ] + |) + |)); + ("end_eid_cell", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ cells; Value.Integer 1 ] + |) + |)); + ("encode_cell", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ cells; Value.Integer 2 ] + |) + |)); + ("value_cell", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ cells; Value.Integer 3 ] + |) + |)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| constraint_builder |), + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder", + "constraints" + |); + Value.Tuple + [ + M.read (| name |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let enable := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'4, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + enable; + Value.Tuple [ M.read (| meta |) ] + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_function (| + "specs::encode::memory_table::encode_memory_table_entry", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'1, + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ] + ] + ] + ], + "call", + [] + |), + [ + offset; + Value.Tuple + [ + M.read (| + meta + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static, + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ] + ] + ] + ], + "call", + [] + |), + [ + location_type; + Value.Tuple + [ + M.read (| + meta + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'2, + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ] + ] + ] + ], + "call", + [] + |), + [ + is_i32; + Value.Tuple + [ + M.read (| + meta + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cell, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "encode_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ enable ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cell, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "start_eid_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + eid; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ enable ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cell, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "value_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'3, + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F + ] + ] + ] + ], + "call", + [] + |), + [ + value; + Value.Tuple + [ + M.read (| + meta + |) + ] + ] + |) + ] + |); + M.read (| enable |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + ] + |) + |) in + cell + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_memory_table_lookup_write_cell : + forall (F : Ty.t), + M.IsAssociatedFunction + (Self F) + "alloc_memory_table_lookup_write_cell" + (alloc_memory_table_lookup_write_cell F). + + (* + pub(crate) fn alloc_memory_table_lookup_read_cell_with_value( + &mut self, + name: &'static str, + constraint_builder: &mut ConstraintBuilder, + eid: AllocatedU32StateCell, + location_type: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + offset: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + is_i32: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + enable: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + ) -> AllocatedMemoryTableLookupReadCell { + let cells: Vec<_> = self + .alloc_group(&EventTableCellType::MTableLookup) + .into_iter() + .map(|x| AllocatedUnlimitedCell { cell: x }) + .collect(); + + let cell = AllocatedMemoryTableLookupReadCell { + start_eid_cell: cells[0], + end_eid_cell: cells[1], + encode_cell: cells[2], + value_cell: cells[3], + start_eid_diff_cell: self.alloc_u32_state_cell(), + end_eid_diff_cell: self.alloc_u32_state_cell(), + }; + + constraint_builder.constraints.push(( + name, + Box::new(move |meta| { + let enable = enable(meta); + vec![ + (eid.expr(meta) + - cell.start_eid_cell.expr(meta) + - cell.start_eid_diff_cell.expr(meta) + - constant_from!(1)) + * enable.clone(), + (eid.expr(meta) + cell.end_eid_diff_cell.expr(meta) + - cell.end_eid_cell.expr(meta)) + * enable.clone(), + (encode_memory_table_entry(offset(meta), location_type(meta), is_i32(meta)) + - cell.encode_cell.expr(meta)) + * enable, + ] + }), + )); + + cell + } + *) + Definition alloc_memory_table_lookup_read_cell_with_value + (F : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F in + match τ, α with + | [ + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'1; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'2; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'3 + ], + [ self; name; constraint_builder; eid; location_type; offset; is_i32; enable ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + let constraint_builder := M.alloc (| constraint_builder |) in + let eid := M.alloc (| eid |) in + let location_type := M.alloc (| location_type |) in + let offset := M.alloc (| offset |) in + let is_i32 := M.alloc (| is_i32 |) in + let enable := M.alloc (| enable |) in + M.read (| + let cells := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ] + ] + ] + (Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_group", + [] + |), + [ + M.read (| self |); + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::MTableLookup" + [] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell" + [ ("cell", M.read (| x |)) ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let cell := + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell" + [ + ("start_eid_cell", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ cells; Value.Integer 0 ] + |) + |)); + ("end_eid_cell", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ cells; Value.Integer 1 ] + |) + |)); + ("encode_cell", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ cells; Value.Integer 2 ] + |) + |)); + ("value_cell", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ cells; Value.Integer 3 ] + |) + |)); + ("start_eid_diff_cell", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u32_state_cell", + [] + |), + [ M.read (| self |) ] + |)); + ("end_eid_diff_cell", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u32_state_cell", + [] + |), + [ M.read (| self |) ] + |)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| constraint_builder |), + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder", + "constraints" + |); + Value.Tuple + [ + M.read (| name |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let enable := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'3, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + enable; + Value.Tuple [ M.read (| meta |) ] + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + eid; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cell, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "start_eid_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cell, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "start_eid_diff_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ enable ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + eid; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cell, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "end_eid_diff_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cell, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "end_eid_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ enable ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_function (| + "specs::encode::memory_table::encode_memory_table_entry", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'1, + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ] + ] + ] + ], + "call", + [] + |), + [ + offset; + Value.Tuple + [ + M.read (| + meta + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static, + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ] + ] + ] + ], + "call", + [] + |), + [ + location_type; + Value.Tuple + [ + M.read (| + meta + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'2, + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ] + ] + ] + ], + "call", + [] + |), + [ + is_i32; + Value.Tuple + [ + M.read (| + meta + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cell, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "encode_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.read (| enable |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + ] + |) + |) in + cell + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_memory_table_lookup_read_cell_with_value : + forall (F : Ty.t), + M.IsAssociatedFunction + (Self F) + "alloc_memory_table_lookup_read_cell_with_value" + (alloc_memory_table_lookup_read_cell_with_value F). + + (* + pub(crate) fn alloc_memory_table_lookup_write_cell_with_value( + &mut self, + name: &'static str, + constraint_builder: &mut ConstraintBuilder, + eid: AllocatedU32StateCell, + location_type: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + offset: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + is_i32: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + enable: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + ) -> AllocatedMemoryTableLookupWriteCell { + let cells: Vec<_> = self + .alloc_group(&EventTableCellType::MTableLookup) + .into_iter() + .map(|x| AllocatedUnlimitedCell { cell: x }) + .collect(); + + let cell = AllocatedMemoryTableLookupWriteCell { + start_eid_cell: cells[0], + end_eid_cell: cells[1], + encode_cell: cells[2], + value_cell: cells[3], + }; + + constraint_builder.constraints.push(( + name, + Box::new(move |meta| { + let enable = enable(meta); + vec![ + (encode_memory_table_entry(offset(meta), location_type(meta), is_i32(meta)) + - cell.encode_cell.expr(meta)) + * enable.clone(), + (cell.start_eid_cell.expr(meta) - eid.expr(meta)) * enable, + ] + }), + )); + + cell + } + *) + Definition alloc_memory_table_lookup_write_cell_with_value + (F : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F in + match τ, α with + | [ + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'1; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'2; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'3 + ], + [ self; name; constraint_builder; eid; location_type; offset; is_i32; enable ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + let constraint_builder := M.alloc (| constraint_builder |) in + let eid := M.alloc (| eid |) in + let location_type := M.alloc (| location_type |) in + let offset := M.alloc (| offset |) in + let is_i32 := M.alloc (| is_i32 |) in + let enable := M.alloc (| enable |) in + M.read (| + let cells := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ] + ] + ] + (Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_group", + [] + |), + [ + M.read (| self |); + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::MTableLookup" + [] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell" + [ ("cell", M.read (| x |)) ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let cell := + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell" + [ + ("start_eid_cell", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ cells; Value.Integer 0 ] + |) + |)); + ("end_eid_cell", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ cells; Value.Integer 1 ] + |) + |)); + ("encode_cell", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ cells; Value.Integer 2 ] + |) + |)); + ("value_cell", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ cells; Value.Integer 3 ] + |) + |)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| constraint_builder |), + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder", + "constraints" + |); + Value.Tuple + [ + M.read (| name |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let enable := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'3, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + enable; + Value.Tuple [ M.read (| meta |) ] + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_function (| + "specs::encode::memory_table::encode_memory_table_entry", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'1, + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ] + ] + ] + ], + "call", + [] + |), + [ + offset; + Value.Tuple + [ + M.read (| + meta + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static, + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ] + ] + ] + ], + "call", + [] + |), + [ + location_type; + Value.Tuple + [ + M.read (| + meta + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'2, + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ] + ] + ] + ], + "call", + [] + |), + [ + is_i32; + Value.Tuple + [ + M.read (| + meta + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cell, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "encode_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ enable ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cell, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "start_eid_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + eid; + M.read (| + meta + |) + ] + |) + ] + |); + M.read (| enable |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + ] + |) + |) in + cell + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_memory_table_lookup_write_cell_with_value : + forall (F : Ty.t), + M.IsAssociatedFunction + (Self F) + "alloc_memory_table_lookup_write_cell_with_value" + (alloc_memory_table_lookup_write_cell_with_value F). + + (* + pub(crate) fn alloc_u32_cell(&mut self) -> AllocatedU32Cell { + self.free_u32_cells.pop().expect("no more free u32 cells") + } + *) + Definition alloc_u32_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") [ F ] + ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "pop", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_u32_cells" + |) + ] + |); + M.read (| Value.String "no more free u32 cells" |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_u32_cell : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "alloc_u32_cell" (alloc_u32_cell F). + + (* + pub(crate) fn alloc_u32_permutation_cell(&mut self) -> AllocatedU32PermutationCell { + self.free_u32_permutation_cells + .pop() + .expect("no more free u32 permutation cells") + } + *) + Definition alloc_u32_permutation_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell") + [ F ] + ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32PermutationCell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "pop", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_u32_permutation_cells" + |) + ] + |); + M.read (| Value.String "no more free u32 permutation cells" |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_u32_permutation_cell : + forall (F : Ty.t), + M.IsAssociatedFunction + (Self F) + "alloc_u32_permutation_cell" + (alloc_u32_permutation_cell F). + + (* + pub(crate) fn alloc_u64_cell(&mut self) -> AllocatedU64Cell { + self.free_u64_cells.pop().expect("no more free u64 cells") + } + *) + Definition alloc_u64_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ] + ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "pop", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_u64_cells" + |) + ] + |); + M.read (| Value.String "no more free u64 cells" |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_u64_cell : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "alloc_u64_cell" (alloc_u64_cell F). + + (* + pub(crate) fn alloc_u64_with_flag_bit_cell_dyn( + &mut self, + constraint_builder: &mut ConstraintBuilder, + is_i32: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + ) -> AllocatedU64CellWithFlagBitDyn { + let value = self.free_u64_cells.pop().expect("no more free u64 cells"); + let flag_bit_cell = self.alloc_bit_cell(); + let flag_u16_rem_cell = self.alloc_common_range_cell(); + let flag_u16_rem_diff_cell = self.alloc_common_range_cell(); + + constraint_builder.push( + "flag bit dyn", + Box::new(move |meta| { + let flag_u16 = value.u16_cells_le[3].expr(meta) + + is_i32(meta) + * (value.u16_cells_le[1].expr(meta) - value.u16_cells_le[3].expr(meta)); + vec![ + (flag_bit_cell.expr(meta) * constant_from!(1 << 15) + + flag_u16_rem_cell.expr(meta) + - flag_u16), + (flag_u16_rem_cell.expr(meta) + flag_u16_rem_diff_cell.expr(meta) + - constant_from!((1 << 15) - 1)), + ] + }), + ); + + AllocatedU64CellWithFlagBitDyn { + u16_cells_le: value.u16_cells_le, + u64_cell: value.u64_cell, + flag_bit_cell, + flag_u16_rem_cell, + flag_u16_rem_diff_cell, + } + } + *) + Definition alloc_u64_with_flag_bit_cell_dyn + (F : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static ], + [ self; constraint_builder; is_i32 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let constraint_builder := M.alloc (| constraint_builder |) in + let is_i32 := M.alloc (| is_i32 |) in + M.read (| + let value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ] + ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "pop", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_u64_cells" + |) + ] + |); + M.read (| Value.String "no more free u64 cells" |) + ] + |) + |) in + let flag_bit_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| self |) ] + |) + |) in + let flag_u16_rem_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| self |) ] + |) + |) in + let flag_u16_rem_diff_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| self |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "flag bit dyn" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let flag_u16 := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| Value.Integer 3 |) + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + is_i32; + Value.Tuple [ M.read (| meta |) ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| Value.Integer 1 |) + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| Value.Integer 3 |) + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + flag_bit_cell; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 15 + |)) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + flag_u16_rem_cell; + M.read (| meta |) + ] + |) + ] + |); + M.read (| flag_u16 |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + flag_u16_rem_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + flag_u16_rem_diff_cell; + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.sub (| + Integer.I32, + BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 15 + |), + Value.Integer 1 + |)) + ] + |) + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn" + [ + ("u16_cells_le", + M.read (| + M.SubPointer.get_struct_record_field (| + value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |) + |)); + ("u64_cell", + M.read (| + M.SubPointer.get_struct_record_field (| + value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |) + |)); + ("flag_bit_cell", M.read (| flag_bit_cell |)); + ("flag_u16_rem_cell", M.read (| flag_u16_rem_cell |)); + ("flag_u16_rem_diff_cell", M.read (| flag_u16_rem_diff_cell |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_u64_with_flag_bit_cell_dyn : + forall (F : Ty.t), + M.IsAssociatedFunction + (Self F) + "alloc_u64_with_flag_bit_cell_dyn" + (alloc_u64_with_flag_bit_cell_dyn F). + + (* + pub(crate) fn alloc_u64_with_flag_bit_cell_dyn_sign( + &mut self, + constraint_builder: &mut ConstraintBuilder, + is_i32: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + is_sign: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + ) -> AllocatedU64CellWithFlagBitDynSign { + let value = self.free_u64_cells.pop().expect("no more free u64 cells"); + let flag_bit_cell = self.alloc_bit_cell(); + let flag_u16_rem_cell = self.alloc_common_range_cell(); + let flag_u16_rem_diff_cell = self.alloc_common_range_cell(); + + constraint_builder.push( + "flag bit dyn sign", + Box::new(move |meta| { + let flag_u16 = value.u16_cells_le[3].expr(meta) + + is_i32(meta) + * (value.u16_cells_le[1].expr(meta) - value.u16_cells_le[3].expr(meta)); + let is_sign = is_sign(meta); + vec![ + is_sign.clone() + * (flag_bit_cell.expr(meta) * constant_from!(1 << 15) + + flag_u16_rem_cell.expr(meta) + - flag_u16), + is_sign.clone() + * (flag_u16_rem_cell.expr(meta) + flag_u16_rem_diff_cell.expr(meta) + - constant_from!((1 << 15) - 1)), + (is_sign - constant_from!(1)) * flag_bit_cell.expr(meta), + ] + }), + ); + + AllocatedU64CellWithFlagBitDynSign { + u16_cells_le: value.u16_cells_le, + u64_cell: value.u64_cell, + flag_bit_cell, + flag_u16_rem_cell, + flag_u16_rem_diff_cell, + } + } + *) + Definition alloc_u64_with_flag_bit_cell_dyn_sign + (F : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F in + match τ, α with + | [ + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'1 + ], + [ self; constraint_builder; is_i32; is_sign ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let constraint_builder := M.alloc (| constraint_builder |) in + let is_i32 := M.alloc (| is_i32 |) in + let is_sign := M.alloc (| is_sign |) in + M.read (| + let value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ] + ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "pop", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_u64_cells" + |) + ] + |); + M.read (| Value.String "no more free u64 cells" |) + ] + |) + |) in + let flag_bit_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| self |) ] + |) + |) in + let flag_u16_rem_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| self |) ] + |) + |) in + let flag_u16_rem_diff_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| self |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "flag bit dyn sign" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let flag_u16 := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| Value.Integer 3 |) + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + is_i32; + Value.Tuple [ M.read (| meta |) ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| Value.Integer 1 |) + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| Value.Integer 3 |) + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + let is_sign := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F___plus__'static'1, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ is_sign; Value.Tuple [ M.read (| meta |) ] ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ is_sign ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + flag_bit_cell; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 15 + |)) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + flag_u16_rem_cell; + M.read (| + meta + |) + ] + |) + ] + |); + M.read (| flag_u16 |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ is_sign ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + flag_u16_rem_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + flag_u16_rem_diff_cell; + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.sub (| + Integer.I32, + BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 15 + |), + Value.Integer + 1 + |)) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.read (| is_sign |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + flag_bit_cell; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign" + [ + ("u16_cells_le", + M.read (| + M.SubPointer.get_struct_record_field (| + value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |) + |)); + ("u64_cell", + M.read (| + M.SubPointer.get_struct_record_field (| + value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |) + |)); + ("flag_bit_cell", M.read (| flag_bit_cell |)); + ("flag_u16_rem_cell", M.read (| flag_u16_rem_cell |)); + ("flag_u16_rem_diff_cell", M.read (| flag_u16_rem_diff_cell |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_u64_with_flag_bit_cell_dyn_sign : + forall (F : Ty.t), + M.IsAssociatedFunction + (Self F) + "alloc_u64_with_flag_bit_cell_dyn_sign" + (alloc_u64_with_flag_bit_cell_dyn_sign F). + + (* + pub(crate) fn alloc_bit_table_lookup_cells(&mut self) -> AllocatedBitTableLookupCells { + AllocatedBitTableLookupCells { + op: self.alloc_unlimited_cell(), + left: self.alloc_unlimited_cell(), + right: self.alloc_unlimited_cell(), + result: self.alloc_unlimited_cell(), + } + } + *) + Definition alloc_bit_table_lookup_cells (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells" + [ + ("op", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| self |) ] + |)); + ("left", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| self |) ] + |)); + ("right", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| self |) ] + |)); + ("result", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| self |) ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_bit_table_lookup_cells : + forall (F : Ty.t), + M.IsAssociatedFunction + (Self F) + "alloc_bit_table_lookup_cells" + (alloc_bit_table_lookup_cells F). + End Impl_delphinus_zkwasm_circuits_etable_allocator_EventTableCellAllocator_F. + End allocator. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/assign.v b/CoqOfRust/zkWasm/circuits/etable/assign.v new file mode 100644 index 000000000..51bc4c288 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/assign.v @@ -0,0 +1,6756 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module assign. + (* StructRecord + { + name := "EventTablePermutationCells"; + ty_params := [ "F" ]; + fields := + [ + ("rest_mops", Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]); + ("rest_jops", + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] ]); + ("pre_initialization_state", + Ty.apply + (Ty.path "specs::state::InitializationState") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] + ]); + ("post_initialization_state", + Ty.apply + (Ty.path "specs::state::InitializationState") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] + ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_assign_EventTablePermutationCells_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field4_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "EventTablePermutationCells" |); + M.read (| Value.String "rest_mops" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells", + "rest_mops" + |)); + M.read (| Value.String "rest_jops" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells", + "rest_jops" + |)); + M.read (| Value.String "pre_initialization_state" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells", + "pre_initialization_state" + |)); + M.read (| Value.String "post_initialization_state" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells", + "post_initialization_state" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_assign_EventTablePermutationCells_F. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableChip_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::etable::EventTableChip") [ F ]. + + (* + fn assign_step_state( + &self, + ctx: &mut Context<'_, F>, + state: &InitializationState, + ) -> Result, AssignedCell>, Error> { + cfg_if::cfg_if! { + if #[cfg(feature="continuation")] { + macro_rules! assign_u32_state { + ($cell:ident, $value:expr) => { + self.config.common_config.$cell.assign(ctx, $value)? + }; + } + } else { + macro_rules! assign_u32_state { + ($cell:ident, $value:expr) => { + self.config.common_config.$cell.assign_u32(ctx, $value)? + }; + } + } + } + + macro_rules! assign_common_range_advice { + ($cell:ident, $value:expr) => { + self.config + .common_config + .$cell + .assign(ctx, F::from($value as u64))? + }; + } + + #[cfg(feature = "continuation")] + macro_rules! assign_biguint { + ($cell:ident, $value:expr) => { + self.config + .common_config + .$cell + .assign(ctx, bn_to_field(&$value))? + }; + } + + let eid = assign_u32_state!(eid_cell, state.eid); + let fid = assign_common_range_advice!(fid_cell, state.fid); + let iid = assign_common_range_advice!(iid_cell, state.iid); + let sp = assign_common_range_advice!(sp_cell, state.sp); + let frame_id = assign_u32_state!(frame_id_cell, state.frame_id); + + let host_public_inputs = + assign_common_range_advice!(input_index_cell, state.host_public_inputs); + let context_in_index = + assign_common_range_advice!(context_input_index_cell, state.context_in_index); + let context_out_index = + assign_common_range_advice!(context_output_index_cell, state.context_out_index); + let external_host_call_call_index = assign_common_range_advice!( + external_host_call_index_cell, + state.external_host_call_call_index + ); + + let initial_memory_pages = + assign_common_range_advice!(mpages_cell, state.initial_memory_pages); + let maximal_memory_pages = + assign_common_range_advice!(maximal_memory_pages_cell, state.maximal_memory_pages); + + #[cfg(feature = "continuation")] + let jops = assign_biguint!(jops_cell, state.jops); + + ctx.step(EVENT_TABLE_ENTRY_ROWS as usize); + + Ok(InitializationState { + eid, + fid, + iid, + frame_id, + sp, + + host_public_inputs, + context_in_index, + context_out_index, + external_host_call_call_index, + + initial_memory_pages, + maximal_memory_pages, + + #[cfg(feature = "continuation")] + jops, + + #[cfg(not(feature = "continuation"))] + _phantom: core::marker::PhantomData, + }) + } + *) + Definition assign_step_state (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; state ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let state := M.alloc (| state |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let eid := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| state |), + "specs::state::InitializationState", + "eid" + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let fid := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "fid_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| state |), + "specs::state::InitializationState", + "fid" + |) + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let iid := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "iid_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| state |), + "specs::state::InitializationState", + "iid" + |) + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let sp := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| state |), + "specs::state::InitializationState", + "sp" + |) + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let frame_id := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "frame_id_cell" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| state |), + "specs::state::InitializationState", + "frame_id" + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let host_public_inputs := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "input_index_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| state |), + "specs::state::InitializationState", + "host_public_inputs" + |) + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let context_in_index := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "context_input_index_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| state |), + "specs::state::InitializationState", + "context_in_index" + |) + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let context_out_index := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "context_output_index_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| state |), + "specs::state::InitializationState", + "context_out_index" + |) + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let external_host_call_call_index := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "external_host_call_index_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| state |), + "specs::state::InitializationState", + "external_host_call_call_index" + |) + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let initial_memory_pages := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "mpages_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| state |), + "specs::state::InitializationState", + "initial_memory_pages" + |) + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let maximal_memory_pages := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "maximal_memory_pages_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| state |), + "specs::state::InitializationState", + "maximal_memory_pages" + |) + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "delphinus_zkwasm::circuits::utils::Context") [ F ], + "step", + [] + |), + [ + M.read (| ctx |); + M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::etable::EVENT_TABLE_ENTRY_ROWS" + |) + |)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "specs::state::InitializationState" + [ + ("eid", M.read (| eid |)); + ("fid", M.read (| fid |)); + ("iid", M.read (| iid |)); + ("frame_id", M.read (| frame_id |)); + ("sp", M.read (| sp |)); + ("host_public_inputs", M.read (| host_public_inputs |)); + ("context_in_index", M.read (| context_in_index |)); + ("context_out_index", M.read (| context_out_index |)); + ("external_host_call_call_index", + M.read (| external_host_call_call_index |)); + ("initial_memory_pages", M.read (| initial_memory_pages |)); + ("maximal_memory_pages", M.read (| maximal_memory_pages |)); + ("_phantom", Value.StructTuple "core::marker::PhantomData" []) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_step_state : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign_step_state" (assign_step_state F). + + (* + fn compute_rest_mops_and_jops( + &self, + op_configs: Arc>>, + itable: &InstructionTable, + event_table: &EventTableWithMemoryInfo, + _initialization_state: &InitializationState, + ) -> (u32, BigUint) { + let (rest_mops, _rest_jops) = event_table.0.iter().fold( + (0, BigUint::from(0u64)), + |(rest_mops_sum, rest_jops_sum), entry| { + let instruction = entry.eentry.get_instruction(itable); + + let op_config = op_configs.get(&((&instruction.opcode).into())).unwrap(); + + ( + rest_mops_sum + op_config.0.memory_writing_ops(&entry.eentry), + rest_jops_sum + op_config.0.jops(), + ) + }, + ); + + cfg_if::cfg_if! { + if #[cfg(feature="continuation")] { + (rest_mops, _initialization_state.jops.clone()) + } else { + (rest_mops, _rest_jops) + } + } + } + *) + Definition compute_rest_mops_and_jops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; op_configs; itable; event_table; _initialization_state ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let op_configs := M.alloc (| op_configs |) in + let itable := M.alloc (| itable |) in + let event_table := M.alloc (| event_table |) in + let _initialization_state := M.alloc (| _initialization_state |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo" + ], + [], + "fold", + [ + Ty.tuple [ Ty.path "u32"; Ty.path "num_bigint::biguint::BigUint" ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "num_bigint::biguint::BigUint" ]; + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo" + ] + ] + ] + (Ty.tuple [ Ty.path "u32"; Ty.path "num_bigint::biguint::BigUint" ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| event_table |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableWithMemoryInfo", + 0 + |) + ] + |) + ] + |); + Value.Tuple + [ + Value.Integer 0; + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 0 ] + |) + ]; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let rest_mops_sum := M.copy (| γ0_0 |) in + let rest_jops_sum := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let entry := M.copy (| γ |) in + M.read (| + let instruction := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::etable::EventTableEntry", + "get_instruction", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |); + M.read (| itable |) + ] + |) + |) in + let op_config := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "get", + [ + Ty.path + "specs::itable::OpcodeClassPlain" + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ op_configs ] + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "&") + [ + Ty.path + "specs::itable::Opcode" + ], + [ + Ty.path + "specs::itable::OpcodeClassPlain" + ], + "into", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| instruction |), + "specs::itable::InstructionTableEntry", + "opcode" + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple + [ + BinOp.Panic.add (| + Integer.U32, + M.read (| rest_mops_sum |), + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ F ], + "memory_writing_ops", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| op_config |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |); + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |) + ] + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "num_bigint::biguint::BigUint" + ], + "add", + [] + |), + [ + M.read (| rest_jops_sum |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ F ], + "jops", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| op_config |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |) + ] + |) + ] + |) + ] + |) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let rest_mops := M.copy (| γ0_0 |) in + let _rest_jops := M.copy (| γ0_1 |) in + M.alloc (| + Value.Tuple [ M.read (| rest_mops |); M.read (| _rest_jops |) ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_compute_rest_mops_and_jops : + forall (F : Ty.t), + M.IsAssociatedFunction + (Self F) + "compute_rest_mops_and_jops" + (compute_rest_mops_and_jops F). + + (* + fn init(&self, ctx: &mut Context<'_, F>) -> Result<(), Error> { + for _ in 0..self.capability { + ctx.region.assign_fixed( + || "etable: step sel", + self.config.step_sel, + ctx.offset, + || Ok(F::one()), + )?; + + ctx.step(EVENT_TABLE_ENTRY_ROWS as usize); + } + + ctx.region.assign_advice_from_constant( + || "etable: rest mops terminates", + self.config.common_config.rest_mops_cell.cell.col, + ctx.offset, + F::zero(), + )?; + + #[cfg(not(feature = "continuation"))] + ctx.region.assign_advice_from_constant( + || "etable: rest jops terminates", + self.config.common_config.jops_cell.cell.col, + ctx.offset, + F::zero(), + )?; + + Ok(()) + } + *) + Definition init (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "capability" + |) + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_fixed", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "etable: step sel" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "step_sel" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "step", + [] + |), + [ + M.read (| ctx |); + M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::etable::EVENT_TABLE_ENTRY_ROWS" + |) + |)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "assign_advice_from_constant", + [ + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String "etable: rest mops terminates" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "rest_mops_cell" + |), + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell", + "cell" + |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "col" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "zero", [] |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "assign_advice_from_constant", + [ + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String "etable: rest jops terminates" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "jops_cell" + |), + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell", + "cell" + |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "col" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "zero", [] |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_init : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "init" (init F). + + (* + fn assign_rest_ops_first_step( + &self, + ctx: &mut Context<'_, F>, + ) -> Result<(AssignedCell, AssignedCell), Error> { + let rest_mops_cell = self + .config + .common_config + .rest_mops_cell + .assign(ctx, F::zero())?; + + let rest_jops_cell = self.config.common_config.jops_cell.assign(ctx, F::zero())?; + + Ok((rest_mops_cell, rest_jops_cell)) + } + *) + Definition assign_rest_ops_first_step (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let rest_mops_cell := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "rest_mops_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "zero", [] |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let rest_jops_cell := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "jops_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "zero", [] |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [ M.read (| rest_mops_cell |); M.read (| rest_jops_cell |) ] ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_rest_ops_first_step : + forall (F : Ty.t), + M.IsAssociatedFunction + (Self F) + "assign_rest_ops_first_step" + (assign_rest_ops_first_step F). + + (* + fn assign_padding_and_post_initialization_state( + &self, + ctx: &mut Context<'_, F>, + initialization_state: &InitializationState, + ) -> Result, AssignedCell>, Error> { + while ctx.offset < self.capability * EVENT_TABLE_ENTRY_ROWS as usize { + self.assign_step_state(ctx, initialization_state)?; + } + + self.assign_step_state(ctx, initialization_state) + } + *) + Definition assign_padding_and_post_initialization_state + (F : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; initialization_state ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let initialization_state := M.alloc (| initialization_state |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.loop (| + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |)) + (BinOp.Panic.mul (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "capability" + |) + |), + M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::etable::EVENT_TABLE_ENTRY_ROWS" + |) + |)) + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::EventTableChip") + [ F ], + "assign_step_state", + [] + |), + [ + M.read (| self |); + M.read (| ctx |); + M.read (| initialization_state |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "specs::state::InitializationState") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + let _ := + M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |) in + M.alloc (| Value.Tuple [] |) + |) + |) + |))) + ] + |))) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::EventTableChip") + [ F ], + "assign_step_state", + [] + |), + [ M.read (| self |); M.read (| ctx |); M.read (| initialization_state |) ] + |) + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_padding_and_post_initialization_state : + forall (F : Ty.t), + M.IsAssociatedFunction + (Self F) + "assign_padding_and_post_initialization_state" + (assign_padding_and_post_initialization_state F). + + (* + fn assign_entries( + &self, + region: &Region<'_, F>, + op_configs: Arc>>, + itable: &InstructionTable, + event_table: &EventTableWithMemoryInfo, + configure_table: &ConfigureTable, + initialization_state: &InitializationState, + post_initialization_state: &InitializationState, + rest_mops: u32, + jops: BigUint, + ) -> Result<(), Error> { + macro_rules! assign_advice { + ($ctx:expr, $cell:ident, $value:expr) => { + self.config + .common_config + .$cell + .assign($ctx, $value) + .unwrap() + }; + } + + macro_rules! assign_advice_cell { + ($ctx:expr, $cell:ident, $value:expr) => { + $cell.assign($ctx, $value).unwrap() + }; + } + + /* + * The length of event_table equals 0: without_witness + */ + if event_table.0.len() == 0 { + return Ok(()); + } + + let status = { + let mut host_public_inputs = initialization_state.host_public_inputs; + let mut context_in_index = initialization_state.context_in_index; + let mut context_out_index = initialization_state.context_out_index; + let mut external_host_call_call_index = + initialization_state.external_host_call_call_index; + + let mut rest_mops = rest_mops; + let mut jops = jops; + + let mut status = event_table + .0 + .iter() + .map(|entry| { + let op_config = op_configs + .get(&((&entry.eentry.get_instruction(itable).opcode).into())) + .unwrap(); + + let status = Status { + eid: entry.eentry.eid, + fid: entry.eentry.fid, + iid: entry.eentry.iid, + sp: entry.eentry.sp, + last_jump_eid: entry.eentry.last_jump_eid, + allocated_memory_pages: entry.eentry.allocated_memory_pages, + + rest_mops, + jops: jops.clone(), + + host_public_inputs, + context_in_index, + context_out_index, + external_host_call_call_index, + + itable, + }; + + if op_config.0.is_host_public_input(&entry.eentry) { + host_public_inputs += 1; + } + if op_config.0.is_context_input_op(&entry.eentry) { + context_in_index += 1; + } + if op_config.0.is_context_output_op(&entry.eentry) { + context_out_index += 1; + } + if op_config.0.is_external_host_call(&entry.eentry) { + external_host_call_call_index += 1; + } + + rest_mops -= op_config.0.memory_writing_ops(&entry.eentry); + if cfg!(feature = "continuation") { + jops += op_config.0.jops() + } else { + jops -= op_config.0.jops() + } + + status + }) + .collect::>(); + + assert_eq!( + post_initialization_state.host_public_inputs, + host_public_inputs + ); + assert_eq!(post_initialization_state.context_in_index, context_in_index); + assert_eq!( + post_initialization_state.context_out_index, + context_out_index + ); + assert_eq!( + post_initialization_state.external_host_call_call_index, + external_host_call_call_index + ); + + let terminate_status = Status { + eid: post_initialization_state.eid, + fid: post_initialization_state.fid, + iid: post_initialization_state.iid, + sp: post_initialization_state.sp, + last_jump_eid: post_initialization_state.frame_id, + allocated_memory_pages: post_initialization_state.initial_memory_pages, + + host_public_inputs: post_initialization_state.host_public_inputs, + context_in_index: post_initialization_state.context_in_index, + context_out_index: post_initialization_state.context_out_index, + external_host_call_call_index: post_initialization_state + .external_host_call_call_index, + + rest_mops, + jops, + + itable, + }; + + status.push(terminate_status); + + status + }; + + event_table + .0 + .par_iter() + .enumerate() + .for_each(|(index, entry)| { + let mut ctx = Context::new(region); + ctx.step((EVENT_TABLE_ENTRY_ROWS as usize * index) as usize); + + let instruction = entry.eentry.get_instruction(itable); + + let step_status = StepStatus { + current: &status[index], + next: &status[index + 1], + configure_table, + }; + + { + let class: OpcodeClassPlain = (&instruction.opcode).into(); + + let op = self.config.common_config.ops[class.index()]; + assign_advice_cell!(&mut ctx, op, F::one()); + } + + assign_advice!(&mut ctx, enabled_cell, F::one()); + assign_advice!( + &mut ctx, + rest_mops_cell, + F::from(status[index].rest_mops as u64) + ); + assign_advice!( + &mut ctx, + itable_lookup_cell, + bn_to_field(&instruction.encode) + ); + assign_advice!(&mut ctx, jops_cell, bn_to_field(&status[index].jops)); + + { + let op_config = op_configs.get(&((&instruction.opcode).into())).unwrap(); + op_config.0.assign(&mut ctx, &step_status, &entry).unwrap(); + } + + // Be careful, the function will step context. + self.assign_step_state( + &mut ctx, + &InitializationState { + eid: entry.eentry.eid, + fid: entry.eentry.fid, + iid: entry.eentry.iid, + sp: entry.eentry.sp, + frame_id: entry.eentry.last_jump_eid, + + host_public_inputs: status[index].host_public_inputs, + context_in_index: status[index].context_in_index, + context_out_index: status[index].context_out_index, + external_host_call_call_index: status[index].external_host_call_call_index, + + initial_memory_pages: entry.eentry.allocated_memory_pages, + maximal_memory_pages: configure_table.maximal_memory_pages, + + #[cfg(feature = "continuation")] + jops: status[index].jops.clone(), + + #[cfg(not(feature = "continuation"))] + _phantom: core::marker::PhantomData, + }, + ) + .unwrap(); + }); + + Ok(()) + } + *) + Definition assign_entries (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], + [ + self; + region; + op_configs; + itable; + event_table; + configure_table; + initialization_state; + post_initialization_state; + rest_mops; + jops + ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let region := M.alloc (| region |) in + let op_configs := M.alloc (| op_configs |) in + let itable := M.alloc (| itable |) in + let event_table := M.alloc (| event_table |) in + let configure_table := M.alloc (| configure_table |) in + let initialization_state := M.alloc (| initialization_state |) in + let post_initialization_state := M.alloc (| post_initialization_state |) in + let rest_mops := M.alloc (| rest_mops |) in + let jops := M.alloc (| jops |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| event_table |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableWithMemoryInfo", + 0 + |) + ] + |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let status := + M.copy (| + let host_public_inputs := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| initialization_state |), + "specs::state::InitializationState", + "host_public_inputs" + |) + |) in + let context_in_index := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| initialization_state |), + "specs::state::InitializationState", + "context_in_index" + |) + |) in + let context_out_index := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| initialization_state |), + "specs::state::InitializationState", + "context_out_index" + |) + |) in + let external_host_call_call_index := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| initialization_state |), + "specs::state::InitializationState", + "external_host_call_call_index" + |) + |) in + let rest_mops := M.copy (| rest_mops |) in + let jops := M.copy (| jops |) in + let status := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo" + ] + ] + ] + (Ty.path + "delphinus_zkwasm::circuits::utils::step_status::Status") + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::step_status::Status"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo" + ], + [], + "map", + [ + Ty.path + "delphinus_zkwasm::circuits::utils::step_status::Status"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo" + ] + ] + ] + (Ty.path + "delphinus_zkwasm::circuits::utils::step_status::Status") + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| event_table |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableWithMemoryInfo", + 0 + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let entry := M.copy (| γ |) in + M.read (| + let op_config := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "get", + [ + Ty.path + "specs::itable::OpcodeClassPlain" + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ op_configs ] + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "&") + [ + Ty.path + "specs::itable::Opcode" + ], + [ + Ty.path + "specs::itable::OpcodeClassPlain" + ], + "into", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::etable::EventTableEntry", + "get_instruction", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |); + M.read (| itable |) + ] + |), + "specs::itable::InstructionTableEntry", + "opcode" + |) + ] + |) + |) + ] + |) + ] + |) + |) in + let status := + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::utils::step_status::Status" + [ + ("eid", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "eid" + |) + |)); + ("fid", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "fid" + |) + |)); + ("iid", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "iid" + |) + |)); + ("sp", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "sp" + |) + |)); + ("last_jump_eid", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "last_jump_eid" + |) + |)); + ("allocated_memory_pages", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "allocated_memory_pages" + |) + |)); + ("rest_mops", M.read (| rest_mops |)); + ("jops", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path + "num_bigint::biguint::BigUint", + [], + "clone", + [] + |), + [ jops ] + |)); + ("host_public_inputs", + M.read (| host_public_inputs |)); + ("context_in_index", + M.read (| context_in_index |)); + ("context_out_index", + M.read (| context_out_index |)); + ("external_host_call_call_index", + M.read (| + external_host_call_call_index + |)); + ("itable", M.read (| itable |)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ F ], + "is_host_public_input", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| + op_config + |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |); + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + let β := host_public_inputs in + M.write (| + β, + BinOp.Panic.add (| + Integer.U32, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ F ], + "is_context_input_op", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| + op_config + |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |); + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + let β := context_in_index in + M.write (| + β, + BinOp.Panic.add (| + Integer.U32, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ F ], + "is_context_output_op", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| + op_config + |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |); + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + let β := context_out_index in + M.write (| + β, + BinOp.Panic.add (| + Integer.U32, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ F ], + "is_external_host_call", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| + op_config + |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |); + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + let β := + external_host_call_call_index in + M.write (| + β, + BinOp.Panic.add (| + Integer.U32, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + let β := rest_mops in + M.write (| + β, + BinOp.Panic.sub (| + Integer.U32, + M.read (| β |), + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ F ], + "memory_writing_ops", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| op_config |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |); + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |) + ] + |) + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + Value.Bool false + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::AddAssign", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "add_assign", + [] + |), + [ + jops; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ F ], + "jops", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| + op_config + |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::SubAssign", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "sub_assign", + [] + |), + [ + jops; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ F ], + "jops", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| + op_config + |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |) + ] + |) + ] + |) + |))) + ] + |) in + status + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.SubPointer.get_struct_record_field (| + M.read (| post_initialization_state |), + "specs::state::InitializationState", + "host_public_inputs" + |); + host_public_inputs + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "u32"; Ty.path "u32" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.SubPointer.get_struct_record_field (| + M.read (| post_initialization_state |), + "specs::state::InitializationState", + "context_in_index" + |); + context_in_index + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "u32"; Ty.path "u32" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.SubPointer.get_struct_record_field (| + M.read (| post_initialization_state |), + "specs::state::InitializationState", + "context_out_index" + |); + context_out_index + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "u32"; Ty.path "u32" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.SubPointer.get_struct_record_field (| + M.read (| post_initialization_state |), + "specs::state::InitializationState", + "external_host_call_call_index" + |); + external_host_call_call_index + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "u32"; Ty.path "u32" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let terminate_status := + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::utils::step_status::Status" + [ + ("eid", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| post_initialization_state |), + "specs::state::InitializationState", + "eid" + |) + |)); + ("fid", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| post_initialization_state |), + "specs::state::InitializationState", + "fid" + |) + |)); + ("iid", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| post_initialization_state |), + "specs::state::InitializationState", + "iid" + |) + |)); + ("sp", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| post_initialization_state |), + "specs::state::InitializationState", + "sp" + |) + |)); + ("last_jump_eid", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| post_initialization_state |), + "specs::state::InitializationState", + "frame_id" + |) + |)); + ("allocated_memory_pages", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| post_initialization_state |), + "specs::state::InitializationState", + "initial_memory_pages" + |) + |)); + ("host_public_inputs", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| post_initialization_state |), + "specs::state::InitializationState", + "host_public_inputs" + |) + |)); + ("context_in_index", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| post_initialization_state |), + "specs::state::InitializationState", + "context_in_index" + |) + |)); + ("context_out_index", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| post_initialization_state |), + "specs::state::InitializationState", + "context_out_index" + |) + |)); + ("external_host_call_call_index", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| post_initialization_state |), + "specs::state::InitializationState", + "external_host_call_call_index" + |) + |)); + ("rest_mops", M.read (| rest_mops |)); + ("jops", M.read (| jops |)); + ("itable", M.read (| itable |)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::step_status::Status"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ status; M.read (| terminate_status |) ] + |) + |) in + status + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo" + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo" + ] + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IndexedParallelIterator", + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo" + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelRefIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo"; + Ty.path "alloc::alloc::Global" + ], + [], + "par_iter", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| event_table |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableWithMemoryInfo", + 0 + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let index := M.copy (| γ0_0 |) in + let entry := M.copy (| γ0_1 |) in + M.read (| + let ctx := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "new", + [] + |), + [ M.read (| region |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "step", + [] + |), + [ + ctx; + M.read (| + M.use + (M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::etable::EVENT_TABLE_ENTRY_ROWS" + |) + |)), + M.read (| index |) + |) + |)) + |) + ] + |) + |) in + let instruction := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::etable::EventTableEntry", + "get_instruction", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |); + M.read (| itable |) + ] + |) + |) in + let step_status := + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::utils::step_status::StepStatus" + [ + ("current", + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::step_status::Status"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ status; M.read (| index |) ] + |)); + ("next", + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::step_status::Status"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + status; + BinOp.Panic.add (| + Integer.Usize, + M.read (| index |), + Value.Integer 1 + |) + ] + |)); + ("configure_table", + M.read (| configure_table |)) + ] + |) in + let _ := + let class := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "&") + [ Ty.path "specs::itable::Opcode" ], + [ Ty.path "specs::itable::OpcodeClassPlain" + ], + "into", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| instruction |), + "specs::itable::InstructionTableEntry", + "opcode" + |) + ] + |) + |) in + let op := + M.copy (| + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "ops" + |), + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| class |) ] + |) + |) + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + op; + ctx; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "enabled_cell" + |); + ctx; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "rest_mops_cell" + |); + ctx; + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::step_status::Status"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ status; M.read (| index |) ] + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "rest_mops" + |) + |)) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "itable_lookup_cell" + |); + ctx; + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| instruction |), + "specs::itable::InstructionTableEntry", + "encode" + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "jops_cell" + |); + ctx; + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::step_status::Status"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ status; M.read (| index |) ] + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "jops" + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + let op_config := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "get", + [ + Ty.path + "specs::itable::OpcodeClassPlain" + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ op_configs ] + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "&") + [ + Ty.path + "specs::itable::Opcode" + ], + [ + Ty.path + "specs::itable::OpcodeClassPlain" + ], + "into", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| instruction |), + "specs::itable::InstructionTableEntry", + "opcode" + |) + ] + |) + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ F ], + "assign", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| op_config |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |); + ctx; + step_status; + M.read (| entry |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "specs::state::InitializationState") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::EventTableChip") + [ F ], + "assign_step_state", + [] + |), + [ + M.read (| self |); + ctx; + M.alloc (| + Value.StructRecord + "specs::state::InitializationState" + [ + ("eid", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "eid" + |) + |)); + ("fid", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "fid" + |) + |)); + ("iid", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "iid" + |) + |)); + ("sp", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "sp" + |) + |)); + ("frame_id", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "last_jump_eid" + |) + |)); + ("host_public_inputs", + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::step_status::Status"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ status; M.read (| index |) + ] + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "host_public_inputs" + |) + |)); + ("context_in_index", + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::step_status::Status"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ status; M.read (| index |) + ] + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "context_in_index" + |) + |)); + ("context_out_index", + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::step_status::Status"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ status; M.read (| index |) + ] + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "context_out_index" + |) + |)); + ("external_host_call_call_index", + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::step_status::Status"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ status; M.read (| index |) + ] + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "external_host_call_call_index" + |) + |)); + ("initial_memory_pages", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "allocated_memory_pages" + |) + |)); + ("maximal_memory_pages", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| configure_table |), + "specs::configure_table::ConfigureTable", + "maximal_memory_pages" + |) + |)); + ("_phantom", + Value.StructTuple + "core::marker::PhantomData" + []) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_entries : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign_entries" (assign_entries F). + + (* + pub(in crate::circuits) fn assign( + &self, + layouter: impl Layouter, + itable: &InstructionTable, + event_table: &EventTableWithMemoryInfo, + configure_table: &ConfigureTable, + initialization_state: &InitializationState, + post_initialization_state: &InitializationState, + _is_last_slice: bool, + ) -> Result, Error> { + layouter.assign_region( + || "event table", + |region| { + let mut ctx = Context::new(region); + + debug!("size of execution table: {}", event_table.0.len()); + + assert!(event_table.0.len() <= self.capability); + + self.init(&mut ctx)?; + ctx.reset(); + + let pre_initialization_state = + self.assign_step_state(&mut ctx, initialization_state)?; + ctx.reset(); + + let (rest_mops_cell, _jops_cell) = self.assign_rest_ops_first_step(&mut ctx)?; + + let (rest_mops, jops) = self.compute_rest_mops_and_jops( + self.config.op_configs.clone(), + itable, + event_table, + initialization_state, + ); + + self.assign_entries( + region, + self.config.op_configs.clone(), + itable, + event_table, + configure_table, + &initialization_state, + post_initialization_state, + rest_mops, + jops, + )?; + ctx.step(EVENT_TABLE_ENTRY_ROWS as usize * event_table.0.len()); + + let post_initialization_state_cells = self + .assign_padding_and_post_initialization_state( + &mut ctx, + &post_initialization_state, + )?; + + cfg_if::cfg_if! { + if #[cfg(feature = "continuation")] { + Ok(EventTablePermutationCells { + rest_mops: rest_mops_cell, + rest_jops: None, + pre_initialization_state, + post_initialization_state: post_initialization_state_cells, + }) + } else { + Ok(EventTablePermutationCells { + rest_mops: rest_mops_cell, + rest_jops: Some(_jops_cell), + pre_initialization_state, + post_initialization_state: post_initialization_state_cells, + }) + } + } + }, + ) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Layouter_F_ ], + [ + self; + layouter; + itable; + event_table; + configure_table; + initialization_state; + post_initialization_state; + _is_last_slice + ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let layouter := M.alloc (| layouter |) in + let itable := M.alloc (| itable |) in + let event_table := M.alloc (| event_table |) in + let configure_table := M.alloc (| configure_table |) in + let initialization_state := M.alloc (| initialization_state |) in + let post_initialization_state := M.alloc (| post_initialization_state |) in + let _is_last_slice := M.alloc (| _is_last_slice |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::Layouter", + impl_Layouter_F_, + [ F ], + "assign_region", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ] ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]); + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ F ]; + Ty.function [ Ty.tuple [] ] (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + layouter; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ fun γ => ltac:(M.monadic (M.read (| Value.String "event table" |))) ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let region := M.copy (| γ |) in + M.read (| + let ctx := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "new", + [] + |), + [ M.read (| region |) ] + |) + |) in + let _ := + let lvl := + M.alloc (| Value.StructTuple "log::Level::Debug" [] |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ + lvl; + M.get_constant (| + "log::STATIC_MAX_LEVEL" + |) + ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ + lvl; + M.alloc (| + M.call_closure (| + M.get_function (| + "log::max_level", + [] + |), + [] + |) + |) + ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "log::__private_api::log", + [ Ty.tuple [] ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "size of execution table: " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo"; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| + event_table + |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableWithMemoryInfo", + 0 + |) + ] + |) + |) + ] + |) + ] + |)) + ] + |); + M.read (| lvl |); + M.alloc (| + Value.Tuple + [ + M.read (| + Value.String + "delphinus_zkwasm::circuits::etable::assign" + |); + M.read (| + Value.String + "delphinus_zkwasm::circuits::etable::assign" + |); + M.read (| + Value.String + "crates/zkwasm/src/circuits/etable/assign.rs" + |) + ] + |); + Value.Integer 475; + Value.Tuple [] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.le + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| event_table |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableWithMemoryInfo", + 0 + |) + ] + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "capability" + |) + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic", + [] + |), + [ + M.read (| + Value.String + "assertion failed: event_table.0.len() <= self.capability" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::EventTableChip") + [ F ], + "init", + [] + |), + [ M.read (| self |); ctx ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "reset", + [] + |), + [ ctx ] + |) + |) in + let pre_initialization_state := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::EventTableChip") + [ F ], + "assign_step_state", + [] + |), + [ + M.read (| self |); + ctx; + M.read (| initialization_state |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "reset", + [] + |), + [ ctx ] + |) + |) in + M.match_operator (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::EventTableChip") + [ F ], + "assign_rest_ops_first_step", + [] + |), + [ M.read (| self |); ctx ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let rest_mops_cell := M.copy (| γ0_0 |) in + let _jops_cell := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::EventTableChip") + [ F ], + "compute_rest_mops_and_jops", + [] + |), + [ + M.read (| self |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "op_configs" + |) + ] + |); + M.read (| itable |); + M.read (| event_table |); + M.read (| initialization_state |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let rest_mops := M.copy (| γ0_0 |) in + let jops := M.copy (| γ0_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::EventTableChip") + [ F ], + "assign_entries", + [] + |), + [ + M.read (| self |); + M.read (| region |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "op_configs" + |) + ] + |); + M.read (| itable |); + M.read (| event_table |); + M.read (| configure_table |); + M.read (| initialization_state |); + M.read (| + post_initialization_state + |); + M.read (| rest_mops |); + M.read (| jops |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "step", + [] + |), + [ + ctx; + BinOp.Panic.mul (| + Integer.Usize, + M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::etable::EVENT_TABLE_ENTRY_ROWS" + |) + |)), + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| event_table |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableWithMemoryInfo", + 0 + |) + ] + |) + |) + ] + |) + |) in + let post_initialization_state_cells := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "specs::state::InitializationState") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::EventTableChip") + [ F ], + "assign_padding_and_post_initialization_state", + [] + |), + [ + M.read (| self |); + ctx; + M.read (| + post_initialization_state + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells" + [ + ("rest_mops", + M.read (| rest_mops_cell |)); + ("rest_jops", + Value.StructTuple + "core::option::Option::Some" + [ M.read (| _jops_cell |) ]); + ("pre_initialization_state", + M.read (| + pre_initialization_state + |)); + ("post_initialization_state", + M.read (| + post_initialization_state_cells + |)) + ] + ] + |))) + ] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_circuits_etable_EventTableChip_F. + End assign. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/constraint_builder.v b/CoqOfRust/zkWasm/circuits/etable/constraint_builder.v new file mode 100644 index 000000000..ffd101f6b --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/constraint_builder.v @@ -0,0 +1,1669 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module constraint_builder. + (* StructRecord + { + name := "ConstraintBuilder"; + ty_params := [ "F" ]; + fields := + [ + ("meta", + Ty.apply + (Ty.path "&mut") + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ] ]); + ("foreign_table_configs", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ] + ]); + ("constraints", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]); + ("lookups", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_constraint_builder_ConstraintBuilder_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ]. + + (* + pub(super) fn new( + meta: &'a mut ConstraintSystem, + foreign_table_configs: &'b BTreeMap<&'static str, Box>>, + ) -> Self { + Self { + meta, + foreign_table_configs, + constraints: vec![], + lookups: BTreeMap::new(), + } + } + *) + Definition new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ meta; foreign_table_configs ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + let foreign_table_configs := M.alloc (| foreign_table_configs |) in + Value.StructRecord + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder" + [ + ("meta", M.read (| meta |)); + ("foreign_table_configs", M.read (| foreign_table_configs |)); + ("constraints", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("lookups", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "new" (new F). + + (* + pub(crate) fn push( + &mut self, + name: &'static str, + constraint: Box) -> Vec>>, + ) { + self.constraints.push((name, constraint)) + } + *) + Definition push (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; name; constraint ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + let constraint := M.alloc (| constraint |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder", + "constraints" + |); + Value.Tuple + [ M.read (| name |); (* Unsize *) M.pointer_coercion (M.read (| constraint |)) ] + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_push : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "push" (push F). + + (* + pub(crate) fn lookup( + &mut self, + foreign_table_id: &'static str, + name: &'static str, + builder: Box) -> Vec>>, + ) { + match self.lookups.get_mut(&foreign_table_id) { + Some(lookups) => lookups.push((name, builder)), + None => { + self.lookups.insert(foreign_table_id, vec![(name, builder)]); + } + } + } + *) + Definition lookup (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; foreign_table_id; name; builder ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let foreign_table_id := M.alloc (| foreign_table_id |) in + let name := M.alloc (| name |) in + let builder := M.alloc (| builder |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "get_mut", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder", + "lookups" + |); + foreign_table_id + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let lookups := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.read (| lookups |); + Value.Tuple + [ + M.read (| name |); + (* Unsize *) M.pointer_coercion (M.read (| builder |)) + ] + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder", + "lookups" + |); + M.read (| foreign_table_id |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.read (| name |); + (* Unsize *) + M.pointer_coercion (M.read (| builder |)) + ] + ] + |) + ] + |) + |)) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_lookup : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "lookup" (lookup F). + + (* + pub(super) fn finalize( + self, + selector: impl Fn(&mut VirtualCells) -> (Expression, Expression), + ) { + for (name, builder) in self.constraints { + self.meta.create_gate(&name, |meta| { + builder(meta) + .into_iter() + .map(|constraint| { + let (step_sel, op_sel) = selector(meta); + + constraint * step_sel * op_sel + }) + .collect::>() + }); + } + + for (id, lookups) in self.lookups { + let config = self.foreign_table_configs.get(&id).unwrap(); + + for (name, expr) in lookups { + config.configure_in_table(self.meta, name, &|meta| { + expr(meta) + .into_iter() + .map(|expr| { + let (step_sel, _op_sel) = selector(meta); + expr * step_sel + }) + .collect() + }); + } + } + } + *) + Definition finalize (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Fn__mut_VirtualCells_F___arrow__Expression_F___Expression_F__ ], + [ self; selector ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let selector := M.alloc (| selector |) in + M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder", + "constraints" + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let name := M.copy (| γ1_0 |) in + let builder := M.copy (| γ1_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "create_gate", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder", + "meta" + |) + |); + M.read (| name |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ + M.read (| + builder + |); + Value.Tuple + [ + M.read (| + meta + |) + ] + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + constraint := + M.copy (| + γ + |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_F___arrow__Expression_F___Expression_F__, + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ] + ] + ] + ], + "call", + [] + |), + [ + selector; + Value.Tuple + [ + M.read (| + meta + |) + ] + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + step_sel := + M.copy (| + γ0_0 + |) in + let + op_sel := + M.copy (| + γ0_1 + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "mul", + [] + |), + [ + M.read (| + constraint + |); + M.read (| + step_sel + |) + ] + |); + M.read (| + op_sel + |) + ] + |) + |))) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder", + "lookups" + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::IntoIter") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let id := M.copy (| γ1_0 |) in + let lookups := M.copy (| γ1_1 |) in + let config := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", + []) + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "get", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder", + "foreign_table_configs" + |) + |); + id + ] + |) + ] + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| lookups |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "str" ]; + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let name := M.copy (| γ1_0 |) in + let expr := M.copy (| γ1_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::foreign::ForeignTableConfig", + Ty.dyn + [ + ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", + []) + ], + [ F ], + "configure_in_table", + [] + |), + [ + M.read (| + M.read (| config |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder", + "meta" + |) + |); + M.read (| name |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + meta := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ] + ] + ] + ], + "call", + [] + |), + [ + expr; + Value.Tuple + [ + M.read (| + meta + |) + ] + ] + |) + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + expr := + M.copy (| + γ + |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_F___arrow__Expression_F___Expression_F__, + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ] + ] + ] + ], + "call", + [] + |), + [ + selector; + Value.Tuple + [ + M.read (| + meta + |) + ] + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + step_sel := + M.copy (| + γ0_0 + |) in + let + _op_sel := + M.copy (| + γ0_1 + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "mul", + [] + |), + [ + M.read (| + expr + |); + M.read (| + step_sel + |) + ] + |) + |))) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_finalize : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "finalize" (finalize F). + End Impl_delphinus_zkwasm_circuits_etable_constraint_builder_ConstraintBuilder_F. + End constraint_builder. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/mod.v b/CoqOfRust/zkWasm/circuits/etable/mod.v new file mode 100644 index 000000000..9eb32226b --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/mod.v @@ -0,0 +1,17492 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Axiom AllocatedU32StateCell : + forall (F : Ty.t), + (Ty.apply (Ty.path "delphinus_zkwasm::circuits::etable::AllocatedU32StateCell") [ F ]) = + (Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") [ F ]). + + Definition value_EVENT_TABLE_ENTRY_ROWS : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 4 |))). + + Definition value_OP_CAPABILITY : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 32 |))). + + Definition value_FOREIGN_LOOKUP_CAPABILITY : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 6 |))). + + (* StructRecord + { + name := "EventTableCommonConfig"; + ty_params := [ "F" ]; + fields := + [ + ("enabled_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("ops", + Ty.apply + (Ty.path "array") + [ Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ] ]); + ("rest_mops_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("jops_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]); + ("input_index_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("context_input_index_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("context_output_index_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("external_host_call_index_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("sp_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("mpages_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("frame_id_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("eid_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("fid_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("iid_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("maximal_memory_pages_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("itable_lookup_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]); + ("brtable_lookup_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]); + ("jtable_lookup_cell", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell") + [ F ]); + ("pow_table_lookup_modulus_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]); + ("pow_table_lookup_power_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]); + ("bit_table_lookup_cells", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells") + [ F ]); + ("external_foreign_call_lookup_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_EventTableCommonConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::etable::EventTableCommonConfig") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig" + [ + ("enabled_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "enabled_cell" + |) + ] + |)); + ("ops", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ] + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "ops" + |) + ] + |)); + ("rest_mops_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "rest_mops_cell" + |) + ] + |)); + ("jops_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "jops_cell" + |) + ] + |)); + ("input_index_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "input_index_cell" + |) + ] + |)); + ("context_input_index_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "context_input_index_cell" + |) + ] + |)); + ("context_output_index_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "context_output_index_cell" + |) + ] + |)); + ("external_host_call_index_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "external_host_call_index_cell" + |) + ] + |)); + ("sp_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + ] + |)); + ("mpages_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "mpages_cell" + |) + ] + |)); + ("frame_id_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "frame_id_cell" + |) + ] + |)); + ("eid_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + ] + |)); + ("fid_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "fid_cell" + |) + ] + |)); + ("iid_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "iid_cell" + |) + ] + |)); + ("maximal_memory_pages_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "maximal_memory_pages_cell" + |) + ] + |)); + ("itable_lookup_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "itable_lookup_cell" + |) + ] + |)); + ("brtable_lookup_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "brtable_lookup_cell" + |) + ] + |)); + ("jtable_lookup_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "jtable_lookup_cell" + |) + ] + |)); + ("pow_table_lookup_modulus_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "pow_table_lookup_modulus_cell" + |) + ] + |)); + ("pow_table_lookup_power_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "pow_table_lookup_power_cell" + |) + ] + |)); + ("bit_table_lookup_cells", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "bit_table_lookup_cells" + |) + ] + |)); + ("external_foreign_call_lookup_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "external_foreign_call_lookup_cell" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_EventTableCommonConfig_F. + + (* Trait *) + (* Empty module 'EventTableOpcodeConfigBuilder' *) + + (* Trait *) + Module EventTableOpcodeConfig. + Definition memory_writing_ops (F Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Integer 0)) ] |))) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_memory_writing_ops : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + "memory_writing_ops" + (memory_writing_ops F). + Definition sp_diff (F Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple "core::option::Option::None" [])) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_sp_diff : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + "sp_diff" + (sp_diff F). + Definition allocated_memory_pages_diff + (F Self : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple "core::option::Option::None" [])) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_allocated_memory_pages_diff : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + "allocated_memory_pages_diff" + (allocated_memory_pages_diff F). + Definition jops_expr (F Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple "core::option::Option::None" [])) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_jops_expr : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + "jops_expr" + (jops_expr F). + Definition jops (F Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| + "num_traits::identities::Zero", + Ty.path "num_bigint::biguint::BigUint", + [], + "zero", + [] + |), + [] + |))) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_jops : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + "jops" + (jops F). + Definition mops (F Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple "core::option::Option::None" [])) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_mops : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + "mops" + (mops F). + Definition next_frame_id (F Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; _meta; _common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + let _common_config := M.alloc (| _common_config |) in + Value.StructTuple "core::option::Option::None" [])) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_next_frame_id : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + "next_frame_id" + (next_frame_id F). + Definition next_fid (F Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; _meta; _common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + let _common_config := M.alloc (| _common_config |) in + Value.StructTuple "core::option::Option::None" [])) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_next_fid : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + "next_fid" + (next_fid F). + Definition next_iid (F Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; _meta; _common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + let _common_config := M.alloc (| _common_config |) in + Value.StructTuple "core::option::Option::None" [])) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_next_iid : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + "next_iid" + (next_iid F). + Definition input_index_increase (F Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; _meta; _common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + let _common_config := M.alloc (| _common_config |) in + Value.StructTuple "core::option::Option::None" [])) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_input_index_increase : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + "input_index_increase" + (input_index_increase F). + Definition is_host_public_input (F Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; _entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _entry := M.alloc (| _entry |) in + Value.Bool false)) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_is_host_public_input : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + "is_host_public_input" + (is_host_public_input F). + Definition context_input_index_increase + (F Self : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + match τ, α with + | [], [ self; _meta; _common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + let _common_config := M.alloc (| _common_config |) in + Value.StructTuple "core::option::Option::None" [])) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_context_input_index_increase : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + "context_input_index_increase" + (context_input_index_increase F). + Definition is_context_input_op (F Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; _entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _entry := M.alloc (| _entry |) in + Value.Bool false)) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_is_context_input_op : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + "is_context_input_op" + (is_context_input_op F). + Definition context_output_index_increase + (F Self : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + match τ, α with + | [], [ self; _meta; _common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + let _common_config := M.alloc (| _common_config |) in + Value.StructTuple "core::option::Option::None" [])) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_context_output_index_increase : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + "context_output_index_increase" + (context_output_index_increase F). + Definition is_context_output_op (F Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; _entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _entry := M.alloc (| _entry |) in + Value.Bool false)) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_is_context_output_op : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + "is_context_output_op" + (is_context_output_op F). + Definition external_host_call_index_increase + (F Self : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + match τ, α with + | [], [ self; _meta; _common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + let _common_config := M.alloc (| _common_config |) in + Value.StructTuple "core::option::Option::None" [])) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_external_host_call_index_increase : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + "external_host_call_index_increase" + (external_host_call_index_increase F). + Definition is_external_host_call (F Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; _entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _entry := M.alloc (| _entry |) in + Value.Bool false)) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_is_external_host_call : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + "is_external_host_call" + (is_external_host_call F). + End EventTableOpcodeConfig. + + (* StructTuple + { + name := "OpcodeConfig"; + ty_params := [ "F" ]; + fields := + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ] + ]; + } *) + + Module Impl_core_marker_Send_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_OpcodeConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Send" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Send_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_OpcodeConfig_F. + + Module Impl_core_marker_Sync_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_OpcodeConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") [ F ]. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::marker::Sync" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Sync_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_OpcodeConfig_F. + + (* StructRecord + { + name := "EventTableConfig"; + ty_params := [ "F" ]; + fields := + [ + ("step_sel", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]); + ("common_config", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::EventTableCommonConfig") + [ F ]); + ("op_configs", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_EventTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::etable::EventTableConfig") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::etable::EventTableConfig" + [ + ("step_sel", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "step_sel" + |) + ] + |)); + ("common_config", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::EventTableCommonConfig") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "common_config" + |) + ] + |)); + ("op_configs", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableConfig", + "op_configs" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_EventTableConfig_F. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::etable::EventTableConfig") [ F ]. + + (* + pub(crate) fn configure( + meta: &mut ConstraintSystem, + k: u32, + cols: &mut (impl Iterator> + Clone), + rtable: &RangeTableConfig, + image_table: &ImageTableConfig, + mtable: &MemoryTableConfig, + jtable: &JumpTableConfig, + bit_table: &BitTableConfig, + external_host_call_table: &ExternalHostCallTableConfig, + foreign_table_configs: &BTreeMap<&'static str, Box>>, + ) -> EventTableConfig { + let step_sel = meta.fixed_column(); + + let mut allocator = + EventTableCellAllocator::new(meta, k, step_sel, rtable, mtable, jtable, cols); + + let ops = [0; OP_CAPABILITY].map(|_| allocator.alloc_bit_cell()); + let enabled_cell = allocator.alloc_bit_cell(); + + let rest_mops_cell = allocator.alloc_common_range_cell(); + let jops_cell = allocator.alloc_unlimited_cell(); + let input_index_cell = allocator.alloc_common_range_cell(); + let context_input_index_cell = allocator.alloc_common_range_cell(); + let context_output_index_cell = allocator.alloc_common_range_cell(); + let external_host_call_index_cell = allocator.alloc_common_range_cell(); + let sp_cell = allocator.alloc_common_range_cell(); + let mpages_cell = allocator.alloc_common_range_cell(); + let frame_id_cell = allocator.alloc_u32_state_cell(); + let eid_cell = allocator.alloc_u32_state_cell(); + let fid_cell = allocator.alloc_common_range_cell(); + let iid_cell = allocator.alloc_common_range_cell(); + let maximal_memory_pages_cell = allocator.alloc_common_range_cell(); + + // We only need to enable equality for the cells of states + let used_common_range_cells_for_state = allocator + .free_cells + .get(&EventTableCellType::CommonRange) + .unwrap(); + allocator.enable_equality( + meta, + &EventTableCellType::CommonRange, + used_common_range_cells_for_state.0 + + (used_common_range_cells_for_state.1 != 0) as usize, + ); + let used_unlimited_cells_for_state = allocator + .free_cells + .get(&EventTableCellType::Unlimited) + .unwrap(); + allocator.enable_equality( + meta, + &EventTableCellType::Unlimited, + used_unlimited_cells_for_state.0 + (used_unlimited_cells_for_state.1 != 0) as usize, + ); + + let itable_lookup_cell = allocator.alloc_unlimited_cell(); + let brtable_lookup_cell = allocator.alloc_unlimited_cell(); + let jtable_lookup_cell = allocator.alloc_jump_table_lookup_cell(); + let pow_table_lookup_modulus_cell = allocator.alloc_unlimited_cell(); + let pow_table_lookup_power_cell = allocator.alloc_unlimited_cell(); + let external_foreign_call_lookup_cell = allocator.alloc_unlimited_cell(); + let bit_table_lookup_cells = allocator.alloc_bit_table_lookup_cells(); + + let mut foreign_table_reserved_lookup_cells = [(); FOREIGN_LOOKUP_CAPABILITY] + .map(|_| allocator.alloc_unlimited_cell()) + .into_iter(); + + let common_config = EventTableCommonConfig { + enabled_cell, + ops, + rest_mops_cell, + jops_cell, + input_index_cell, + context_input_index_cell, + context_output_index_cell, + external_host_call_index_cell, + sp_cell, + mpages_cell, + frame_id_cell, + eid_cell, + fid_cell, + iid_cell, + maximal_memory_pages_cell, + itable_lookup_cell, + brtable_lookup_cell, + jtable_lookup_cell, + pow_table_lookup_modulus_cell, + pow_table_lookup_power_cell, + bit_table_lookup_cells, + external_foreign_call_lookup_cell, + }; + + let mut op_bitmaps: BTreeMap = BTreeMap::new(); + let mut op_configs: BTreeMap> = BTreeMap::new(); + + let mut profiler = AllocatorFreeCellsProfiler::new(&allocator); + + macro_rules! configure { + ($op:expr, $x:ident) => { + let op = OpcodeClassPlain($op as usize); + + let foreign_table_configs = BTreeMap::new(); + let mut constraint_builder = ConstraintBuilder::new(meta, &foreign_table_configs); + + let mut allocator = allocator.clone(); + let config = $x::configure(&common_config, &mut allocator, &mut constraint_builder); + + constraint_builder.finalize(|meta| { + (fixed_curr!(meta, step_sel), ops[op.index()].curr_expr(meta)) + }); + + op_bitmaps.insert(op, op.index()); + op_configs.insert(op, OpcodeConfig::(config)); + + profiler.update(&allocator); + }; + } + + configure!(OpcodeClass::BinShift, BinShiftConfigBuilder); + configure!(OpcodeClass::Bin, BinConfigBuilder); + configure!(OpcodeClass::BrIfEqz, BrIfEqzConfigBuilder); + configure!(OpcodeClass::BrIf, BrIfConfigBuilder); + configure!(OpcodeClass::Br, BrConfigBuilder); + configure!(OpcodeClass::Call, CallConfigBuilder); + configure!(OpcodeClass::CallHost, ExternalCallHostCircuitConfigBuilder); + configure!(OpcodeClass::Const, ConstConfigBuilder); + configure!(OpcodeClass::Conversion, ConversionConfigBuilder); + configure!(OpcodeClass::Drop, DropConfigBuilder); + configure!(OpcodeClass::GlobalGet, GlobalGetConfigBuilder); + configure!(OpcodeClass::GlobalSet, GlobalSetConfigBuilder); + configure!(OpcodeClass::LocalGet, LocalGetConfigBuilder); + configure!(OpcodeClass::LocalSet, LocalSetConfigBuilder); + configure!(OpcodeClass::LocalTee, LocalTeeConfigBuilder); + configure!(OpcodeClass::Rel, RelConfigBuilder); + configure!(OpcodeClass::Return, ReturnConfigBuilder); + configure!(OpcodeClass::Select, SelectConfigBuilder); + configure!(OpcodeClass::Test, TestConfigBuilder); + configure!(OpcodeClass::Unary, UnaryConfigBuilder); + configure!(OpcodeClass::Load, LoadConfigBuilder); + configure!(OpcodeClass::Store, StoreConfigBuilder); + configure!(OpcodeClass::BinBit, BinBitConfigBuilder); + configure!(OpcodeClass::MemorySize, MemorySizeConfigBuilder); + configure!(OpcodeClass::MemoryGrow, MemoryGrowConfigBuilder); + configure!(OpcodeClass::BrTable, BrTableConfigBuilder); + configure!(OpcodeClass::CallIndirect, CallIndirectConfigBuilder); + + macro_rules! configure_foreign { + ($x:ident, $i:expr) => { + let builder = $x::new($i); + let op = OpcodeClass::ForeignPluginStart as usize + $i; + let op = OpcodeClassPlain(op); + + let mut constraint_builder = ConstraintBuilder::new(meta, foreign_table_configs); + let mut allocator = allocator.clone(); + + let config = builder.configure( + &common_config, + &mut allocator, + &mut constraint_builder, + &mut foreign_table_reserved_lookup_cells, + ); + + constraint_builder.finalize(|meta| { + (fixed_curr!(meta, step_sel), ops[op.index()].curr_expr(meta)) + }); + + op_bitmaps.insert(op, op.index()); + op_configs.insert(op, OpcodeConfig(config)); + + profiler.update(&allocator); + }; + } + configure_foreign!(ETableWasmInputHelperTableConfigBuilder, 0); + configure_foreign!(ETableContextHelperTableConfigBuilder, 1); + configure_foreign!(ETableRequireHelperTableConfigBuilder, 2); + + profiler.assert_no_free_cells(&allocator); + + meta.create_gate("c1. enable seq", |meta| { + vec![ + enabled_cell.next_expr(meta) + * (enabled_cell.curr_expr(meta) - constant_from!(1)) + * fixed_curr!(meta, step_sel), + ] + }); + + meta.create_gate("c4. opcode_bit lvl sum equals to 1", |meta| { + vec![ + ops.map(|x| x.curr_expr(meta)) + .into_iter() + .reduce(|acc, x| acc + x) + .unwrap() + - enabled_cell.curr_expr(meta), + ] + .into_iter() + .map(|expr| expr * fixed_curr!(meta, step_sel)) + .collect::>() + }); + + /* + * How `* enabled_cell.curr_expr(meta)` effects on the separate step: + * 1. constrains the relation between the last step and termination. + * 2. ignores rows following the termination step. + */ + let sum_ops_expr_with_init = + |init: Expression, + meta: &mut VirtualCells<'_, F>, + get_expr: &dyn Fn( + &mut VirtualCells<'_, F>, + &OpcodeConfig, + ) -> Option>, + enable: Option<&dyn Fn(&mut VirtualCells<'_, F>) -> Expression>| { + let expr = op_bitmaps + .iter() + .filter_map(|(op, op_index)| { + get_expr(meta, op_configs.get(op).unwrap()) + .map(|expr| expr * ops[*op_index].curr_expr(meta)) + }) + .fold(init, |acc, x| acc + x) + * fixed_curr!(meta, step_sel); + + enable.map_or(expr.clone(), |enable_expr| expr * enable_expr(meta)) + }; + + let sum_ops_expr = |meta: &mut VirtualCells<'_, F>, + get_expr: &dyn Fn( + &mut VirtualCells<'_, F>, + &OpcodeConfig, + ) -> Option>| { + op_bitmaps + .iter() + .filter_map(|(op, op_index)| { + get_expr(meta, op_configs.get(op).unwrap()) + .map(|expr| expr * ops[*op_index].curr_expr(meta)) + }) + .reduce(|acc, x| acc + x) + .unwrap() + }; + + meta.create_gate("c5a. rest_mops change", |meta| { + vec![sum_ops_expr_with_init( + rest_mops_cell.next_expr(meta) - rest_mops_cell.curr_expr(meta), + meta, + &|meta, config: &OpcodeConfig| config.0.mops(meta), + None, + )] + }); + + meta.create_gate("c5b. jops change(increase if continuation)", |meta| { + vec![sum_ops_expr_with_init( + if cfg!(feature = "continuation") { + jops_cell.curr_expr(meta) - jops_cell.next_expr(meta) + } else { + jops_cell.next_expr(meta) - jops_cell.curr_expr(meta) + }, + meta, + &|meta, config: &OpcodeConfig| config.0.jops_expr(meta), + None, + )] + }); + + meta.create_gate("c5c. input_index change", |meta| { + vec![sum_ops_expr_with_init( + input_index_cell.curr_expr(meta) - input_index_cell.next_expr(meta), + meta, + &|meta, config: &OpcodeConfig| { + config.0.input_index_increase(meta, &common_config) + }, + None, + )] + }); + + meta.create_gate("c5d. external_host_call_index change", |meta| { + vec![sum_ops_expr_with_init( + external_host_call_index_cell.curr_expr(meta) + - external_host_call_index_cell.next_expr(meta), + meta, + &|meta, config: &OpcodeConfig| { + config + .0 + .external_host_call_index_increase(meta, &common_config) + }, + None, + )] + }); + + meta.create_gate("c5e. sp change", |meta| { + vec![sum_ops_expr_with_init( + sp_cell.curr_expr(meta) - sp_cell.next_expr(meta), + meta, + &|meta, config: &OpcodeConfig| config.0.sp_diff(meta), + None, + )] + }); + + meta.create_gate("c5f. mpages change", |meta| { + vec![sum_ops_expr_with_init( + mpages_cell.curr_expr(meta) - mpages_cell.next_expr(meta), + meta, + &|meta, config: &OpcodeConfig| config.0.allocated_memory_pages_diff(meta), + None, + )] + }); + + meta.create_gate("c5g. context_input_index change", |meta| { + vec![sum_ops_expr_with_init( + context_input_index_cell.curr_expr(meta) - context_input_index_cell.next_expr(meta), + meta, + &|meta, config: &OpcodeConfig| { + config.0.context_input_index_increase(meta, &common_config) + }, + None, + )] + }); + + meta.create_gate("c5h. context_output_index change", |meta| { + vec![sum_ops_expr_with_init( + context_output_index_cell.curr_expr(meta) + - context_output_index_cell.next_expr(meta), + meta, + &|meta, config: &OpcodeConfig| { + config.0.context_output_index_increase(meta, &common_config) + }, + None, + )] + }); + + meta.create_gate("c6a. eid change", |meta| { + vec![ + (eid_cell.next_expr(meta) + - eid_cell.curr_expr(meta) + - enabled_cell.curr_expr(meta)) + * fixed_curr!(meta, step_sel), + ] + }); + + meta.create_gate("c6b. fid change", |meta| { + vec![sum_ops_expr_with_init( + fid_cell.curr_expr(meta) - fid_cell.next_expr(meta), + meta, + &|meta, config: &OpcodeConfig| { + config + .0 + .next_fid(meta, &common_config) + .map(|x| x - fid_cell.curr_expr(meta)) + }, + None, + )] + }); + + meta.create_gate("c6c. iid change", |meta| { + vec![sum_ops_expr_with_init( + iid_cell.next_expr(meta) - iid_cell.curr_expr(meta) - enabled_cell.curr_expr(meta), + meta, + &|meta, config: &OpcodeConfig| { + config + .0 + .next_iid(meta, &common_config) + .map(|x| iid_cell.curr_expr(meta) + enabled_cell.curr_expr(meta) - x) + }, + None, + )] + }); + + meta.create_gate("c6d. frame_id change", |meta| { + vec![sum_ops_expr_with_init( + frame_id_cell.curr_expr(meta) - frame_id_cell.next_expr(meta), + meta, + &|meta, config: &OpcodeConfig| { + config + .0 + .next_frame_id(meta, &common_config) + .map(|x| x - frame_id_cell.curr_expr(meta)) + }, + None, + )] + }); + + meta.create_gate("c7. itable_lookup_encode", |meta| { + let opcode = sum_ops_expr(meta, &|meta, config: &OpcodeConfig| { + Some(config.0.opcode(meta)) + }); + vec![ + (encode_instruction_table_entry(fid_cell.expr(meta), iid_cell.expr(meta), opcode) + - itable_lookup_cell.curr_expr(meta)) + * fixed_curr!(meta, step_sel), + ] + }); + + image_table.instruction_lookup(meta, "c8a. itable_lookup in itable", |meta| { + itable_lookup_cell.curr_expr(meta) * fixed_curr!(meta, step_sel) + }); + + image_table.br_table_lookup(meta, "c8b. brtable_lookup in brtable", |meta| { + brtable_lookup_cell.curr_expr(meta) * fixed_curr!(meta, step_sel) + }); + + rtable.configure_in_pow_set( + meta, + "c8d. pow_table_lookup in pow_table", + |meta| pow_table_lookup_power_cell.curr_expr(meta), + |meta| pow_table_lookup_modulus_cell.curr_expr(meta), + |meta| fixed_curr!(meta, step_sel), + ); + + external_host_call_table.configure_in_table( + meta, + "c8g. external_foreign_call_lookup in foreign table", + |meta| { + vec![ + external_foreign_call_lookup_cell.curr_expr(meta) * fixed_curr!(meta, step_sel), + ] + }, + ); + + bit_table.configure_in_table(meta, "c8f: bit_table_lookup in bit_table", |meta| { + ( + fixed_curr!(meta, step_sel), + fixed_curr!(meta, step_sel) * bit_table_lookup_cells.op.expr(meta), + fixed_curr!(meta, step_sel) * bit_table_lookup_cells.left.expr(meta), + fixed_curr!(meta, step_sel) * bit_table_lookup_cells.right.expr(meta), + fixed_curr!(meta, step_sel) * bit_table_lookup_cells.result.expr(meta), + ) + }); + + meta.create_gate("c9. maximal memory pages consistent", |meta| { + vec![ + (maximal_memory_pages_cell.next_expr(meta) + - maximal_memory_pages_cell.curr_expr(meta)) + * fixed_curr!(meta, step_sel), + ] + }); + + Self { + step_sel, + common_config, + op_configs: Arc::new(op_configs), + } + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Iterator_Item___Column_Advice____plus__Clone ], + [ + meta; + k; + cols; + rtable; + image_table; + mtable; + jtable; + bit_table; + external_host_call_table; + foreign_table_configs + ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + let k := M.alloc (| k |) in + let cols := M.alloc (| cols |) in + let rtable := M.alloc (| rtable |) in + let image_table := M.alloc (| image_table |) in + let mtable := M.alloc (| mtable |) in + let jtable := M.alloc (| jtable |) in + let bit_table := M.alloc (| bit_table |) in + let external_host_call_table := M.alloc (| external_host_call_table |) in + let foreign_table_configs := M.alloc (| foreign_table_configs |) in + M.read (| + let step_sel := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "fixed_column", + [] + |), + [ M.read (| meta |) ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "new", + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::mtable::MemoryTableConfig") + [ F ]; + impl_Iterator_Item___Column_Advice____plus__Clone + ] + |), + [ + M.read (| meta |); + M.read (| k |); + M.read (| step_sel |); + M.read (| rtable |); + M.read (| mtable |); + M.read (| jtable |); + M.read (| cols |) + ] + |) + |) in + let ops := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.path "i32" ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "i32" ] ] + (Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ]); + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ] + ] + |), + [ + repeat (Value.Integer 0) 32; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ allocator ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let enabled_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ allocator ] + |) + |) in + let rest_mops_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ allocator ] + |) + |) in + let jops_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ allocator ] + |) + |) in + let input_index_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ allocator ] + |) + |) in + let context_input_index_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ allocator ] + |) + |) in + let context_output_index_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ allocator ] + |) + |) in + let external_host_call_index_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ allocator ] + |) + |) in + let sp_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ allocator ] + |) + |) in + let mpages_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ allocator ] + |) + |) in + let frame_id_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u32_state_cell", + [] + |), + [ allocator ] + |) + |) in + let eid_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u32_state_cell", + [] + |), + [ allocator ] + |) + |) in + let fid_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ allocator ] + |) + |) in + let iid_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ allocator ] + |) + |) in + let maximal_memory_pages_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ allocator ] + |) + |) in + let used_common_range_cells_for_state := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] ] ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + "get", + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + allocator, + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_cells" + |); + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::CommonRange" + [] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "enable_equality", + [] + |), + [ + allocator; + M.read (| meta |); + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::CommonRange" + [] + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_tuple_field (| + M.read (| used_common_range_cells_for_state |), + 0 + |) + |), + M.rust_cast + (BinOp.Pure.ne + (M.read (| + M.SubPointer.get_tuple_field (| + M.read (| used_common_range_cells_for_state |), + 1 + |) + |)) + (Value.Integer 0)) + |) + ] + |) + |) in + let used_unlimited_cells_for_state := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] ] ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + "get", + [ + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + allocator, + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator", + "free_cells" + |); + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::Unlimited" + [] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "enable_equality", + [] + |), + [ + allocator; + M.read (| meta |); + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellType::Unlimited" + [] + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_tuple_field (| + M.read (| used_unlimited_cells_for_state |), + 0 + |) + |), + M.rust_cast + (BinOp.Pure.ne + (M.read (| + M.SubPointer.get_tuple_field (| + M.read (| used_unlimited_cells_for_state |), + 1 + |) + |)) + (Value.Integer 0)) + |) + ] + |) + |) in + let itable_lookup_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ allocator ] + |) + |) in + let brtable_lookup_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ allocator ] + |) + |) in + let jtable_lookup_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_jump_table_lookup_cell", + [] + |), + [ allocator ] + |) + |) in + let pow_table_lookup_modulus_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ allocator ] + |) + |) in + let pow_table_lookup_power_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ allocator ] + |) + |) in + let external_foreign_call_lookup_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ allocator ] + |) + |) in + let bit_table_lookup_cells := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_table_lookup_cells", + [] + |), + [ allocator ] + |) + |) in + let foreign_table_reserved_lookup_cells := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.tuple [] ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.tuple [] ] ] + (Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ] + ] + |), + [ + repeat (Value.Tuple []) 6; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ allocator ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let common_config := + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig" + [ + ("enabled_cell", M.read (| enabled_cell |)); + ("ops", M.read (| ops |)); + ("rest_mops_cell", M.read (| rest_mops_cell |)); + ("jops_cell", M.read (| jops_cell |)); + ("input_index_cell", M.read (| input_index_cell |)); + ("context_input_index_cell", M.read (| context_input_index_cell |)); + ("context_output_index_cell", M.read (| context_output_index_cell |)); + ("external_host_call_index_cell", M.read (| external_host_call_index_cell |)); + ("sp_cell", M.read (| sp_cell |)); + ("mpages_cell", M.read (| mpages_cell |)); + ("frame_id_cell", M.read (| frame_id_cell |)); + ("eid_cell", M.read (| eid_cell |)); + ("fid_cell", M.read (| fid_cell |)); + ("iid_cell", M.read (| iid_cell |)); + ("maximal_memory_pages_cell", M.read (| maximal_memory_pages_cell |)); + ("itable_lookup_cell", M.read (| itable_lookup_cell |)); + ("brtable_lookup_cell", M.read (| brtable_lookup_cell |)); + ("jtable_lookup_cell", M.read (| jtable_lookup_cell |)); + ("pow_table_lookup_modulus_cell", M.read (| pow_table_lookup_modulus_cell |)); + ("pow_table_lookup_power_cell", M.read (| pow_table_lookup_power_cell |)); + ("bit_table_lookup_cells", M.read (| bit_table_lookup_cells |)); + ("external_foreign_call_lookup_cell", + M.read (| external_foreign_call_lookup_cell |)) + ] + |) in + let op_bitmaps := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let op_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let profiler := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "new", + [ F ] + |), + [ allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 11 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 9 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 17 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 16 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 15 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_br::BrConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 20 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_call::CallConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 21 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_call_host_foreign_circuit::ExternalCallHostCircuitConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 5 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_const::ConstConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 27 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 6 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_drop::DropConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 3 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_global_get::GlobalGetConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 4 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_global_set::GlobalSetConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 0 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_local_get::LocalGetConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 1 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_local_set::LocalSetConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 2 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_local_tee::LocalTeeConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 14 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 8 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_return::ReturnConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 7 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_select::SelectConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 13 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_test::TestConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 10 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 23 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 24 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 12 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_bit::BinBitConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 25 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_memory_size::MemorySizeConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 26 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_memory_grow::MemoryGrowConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 18 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let op := + M.alloc (| + Value.StructTuple + "specs::itable::OpcodeClassPlain" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 22 + |)) + ] + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); foreign_table_configs ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder", + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_call_indirect::CallIndirectConfigBuilder", + [ F ], + "configure", + [] + |), + [ common_config; allocator; constraint_builder ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let builder := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::foreign::InternalHostPluginBuilder", + Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfigBuilder", + [], + "new", + [] + |), + [ Value.Integer 0 ] + |) + |) in + let op := + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 28 + |)), + Value.Integer 0 + |) + |) in + let op := + M.alloc (| + Value.StructTuple "specs::itable::OpcodeClassPlain" [ M.read (| op |) ] + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); M.read (| foreign_table_configs |) ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::foreign::EventTableForeignCallConfigBuilder", + Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfigBuilder", + [ F ], + "configure", + [ + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ] + ] + ] + |), + [ + M.read (| builder |); + common_config; + allocator; + constraint_builder; + foreign_table_reserved_lookup_cells + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let builder := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::foreign::InternalHostPluginBuilder", + Ty.path + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfigBuilder", + [], + "new", + [] + |), + [ Value.Integer 1 ] + |) + |) in + let op := + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 28 + |)), + Value.Integer 1 + |) + |) in + let op := + M.alloc (| + Value.StructTuple "specs::itable::OpcodeClassPlain" [ M.read (| op |) ] + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); M.read (| foreign_table_configs |) ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::foreign::EventTableForeignCallConfigBuilder", + Ty.path + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfigBuilder", + [ F ], + "configure", + [ + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ] + ] + ] + |), + [ + M.read (| builder |); + common_config; + allocator; + constraint_builder; + foreign_table_reserved_lookup_cells + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let builder := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::foreign::InternalHostPluginBuilder", + Ty.path + "delphinus_zkwasm::foreign::require_helper::etable_op_configure::ETableRequireHelperTableConfigBuilder", + [], + "new", + [] + |), + [ Value.Integer 2 ] + |) + |) in + let op := + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| "specs::itable::OpcodeClass::LocalGet_discriminant" |), + Value.Integer 28 + |)), + Value.Integer 2 + |) + |) in + let op := + M.alloc (| + Value.StructTuple "specs::itable::OpcodeClassPlain" [ M.read (| op |) ] + |) in + let constraint_builder := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "new", + [] + |), + [ M.read (| meta |); M.read (| foreign_table_configs |) ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + [], + "clone", + [] + |), + [ allocator ] + |) + |) in + let config := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::foreign::EventTableForeignCallConfigBuilder", + Ty.path + "delphinus_zkwasm::foreign::require_helper::etable_op_configure::ETableRequireHelperTableConfigBuilder", + [ F ], + "configure", + [ + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ] + ] + ] + |), + [ + M.read (| builder |); + common_config; + allocator; + constraint_builder; + foreign_table_reserved_lookup_cells + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "finalize", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + |) + |); + M.read (| meta |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_bitmaps; + M.read (| op |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::OpcodeClassPlain", + "index", + [] + |), + [ M.read (| op |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + op_configs; + M.read (| op |); + Value.StructTuple + "delphinus_zkwasm::circuits::etable::OpcodeConfig" + [ (* Unsize *) M.pointer_coercion (M.read (| config |)) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "update", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatorFreeCellsProfiler", + "assert_no_free_cells", + [ F ] + |), + [ profiler; allocator ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c1. enable seq" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ enabled_cell; M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + enabled_cell; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c4. opcode_bit lvl sum equals to 1" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::array::iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + [], + "reduce", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "array") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ] + ], + "map", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ + F + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ]); + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + |), + [ + M.read (| + ops + |); + M.closure + (fun γ => + ltac:(M.monadic + match + γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + x := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ + F + ], + [ + F + ], + "curr_expr", + [] + |), + [ + x; + M.read (| + meta + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + acc := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + x := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "add", + [] + |), + [ + M.read (| + acc + |); + M.read (| + x + |) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + enabled_cell; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let expr := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| expr |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let sum_ops_expr_with_init := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2; α3 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let init := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α2 |), + [ + fun γ => + ltac:(M.monadic + (let get_expr := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α3 |), + [ + fun γ => + ltac:(M.monadic + (let enable := M.copy (| γ |) in + M.read (| + let expr := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::Iter") + [ + Ty.path + "specs::itable::OpcodeClassPlain"; + Ty.path "usize" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "specs::itable::OpcodeClassPlain" + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.path + "usize" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]) + ], + [], + "fold", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::collections::btree::map::Iter") + [ + Ty.path + "specs::itable::OpcodeClassPlain"; + Ty.path "usize" + ], + [], + "filter_map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "specs::itable::OpcodeClassPlain" + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.path + "usize" + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path + "alloc::alloc::Global" + ], + "iter", + [] + |), + [ op_bitmaps ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let + γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + op := + M.copy (| + γ0_0 + |) in + let + op_index := + M.copy (| + γ0_1 + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ], + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ] + ]; + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ + F + ] + ] + ] + ], + "call", + [] + |), + [ + M.read (| + get_expr + |); + Value.Tuple + [ + M.read (| + meta + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ + F + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ + F + ]; + Ty.path + "alloc::alloc::Global" + ], + "get", + [ + Ty.path + "specs::itable::OpcodeClassPlain" + ] + |), + [ + op_configs; + M.read (| + op + |) + ] + |) + ] + |) + ] + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + expr := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "mul", + [] + |), + [ + M.read (| + expr + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ + F + ], + [ + F + ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.read (| + op_index + |) + |); + M.read (| + meta + |) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |); + M.read (| init |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (let + x := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "add", + [] + |), + [ + M.read (| + acc + |); + M.read (| + x + |) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ], + "map_or", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| enable |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ expr ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let + enable_expr := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| + expr + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ], + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ + F + ] + ] + ] + ], + "call", + [] + |), + [ + M.read (| + enable_expr + |); + Value.Tuple + [ + M.read (| + meta + |) + ] + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) + |))) + ] + |))) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let sum_ops_expr := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let get_expr := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path + "alloc::collections::btree::map::Iter") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "specs::itable::OpcodeClassPlain" + ]; + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]) + ], + [], + "reduce", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::collections::btree::map::Iter") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.path "usize" + ], + [], + "filter_map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "specs::itable::OpcodeClassPlain" + ]; + Ty.apply + (Ty.path "&") + [ Ty.path "usize" ] + ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "specs::itable::OpcodeClassPlain"; + Ty.path "usize"; + Ty.path "alloc::alloc::Global" + ], + "iter", + [] + |), + [ op_bitmaps ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let op := M.copy (| γ0_0 |) in + let op_index := + M.copy (| γ0_1 |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ], + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + M.read (| get_expr |); + Value.Tuple + [ + M.read (| meta |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F + ]; + Ty.path + "alloc::alloc::Global" + ], + "get", + [ + Ty.path + "specs::itable::OpcodeClassPlain" + ] + |), + [ + op_configs; + M.read (| + op + |) + ] + |) + ] + |) + ] + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let + expr := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "mul", + [] + |), + [ + M.read (| + expr + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ + F + ], + [ + F + ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + ops, + M.read (| + op_index + |) + |); + M.read (| + meta + |) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let x := + M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.read (| acc |); + M.read (| x |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c5a. rest_mops change" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ], + "call", + [] + |), + [ + sum_ops_expr_with_init; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + rest_mops_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + rest_mops_cell; + M.read (| meta |) + ] + |) + ] + |); + M.read (| meta |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (let + config := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ F + ], + "mops", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| + config + |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |); + M.read (| + meta + |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)); + Value.StructTuple + "core::option::Option::None" + [] + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c5b. jops change(increase if continuation)" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ], + "call", + [] + |), + [ + sum_ops_expr_with_init; + Value.Tuple + [ + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + Value.Bool false + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + jops_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + jops_cell; + M.read (| + meta + |) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + jops_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + jops_cell; + M.read (| + meta + |) + ] + |) + ] + |) + |))) + ] + |) + |); + M.read (| meta |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (let + config := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ F + ], + "jops_expr", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| + config + |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |); + M.read (| + meta + |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)); + Value.StructTuple + "core::option::Option::None" + [] + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c5c. input_index change" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ], + "call", + [] + |), + [ + sum_ops_expr_with_init; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + input_index_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + input_index_cell; + M.read (| meta |) + ] + |) + ] + |); + M.read (| meta |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (let + config := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ F + ], + "input_index_increase", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| + config + |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |); + M.read (| + meta + |); + common_config + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)); + Value.StructTuple + "core::option::Option::None" + [] + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c5d. external_host_call_index change" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ], + "call", + [] + |), + [ + sum_ops_expr_with_init; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + external_host_call_index_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + external_host_call_index_cell; + M.read (| meta |) + ] + |) + ] + |); + M.read (| meta |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (let + config := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ F + ], + "external_host_call_index_increase", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| + config + |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |); + M.read (| + meta + |); + common_config + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)); + Value.StructTuple + "core::option::Option::None" + [] + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c5e. sp change" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ], + "call", + [] + |), + [ + sum_ops_expr_with_init; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ sp_cell; M.read (| meta |) ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ sp_cell; M.read (| meta |) ] + |) + ] + |); + M.read (| meta |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (let + config := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ F + ], + "sp_diff", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| + config + |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |); + M.read (| + meta + |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)); + Value.StructTuple + "core::option::Option::None" + [] + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c5f. mpages change" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ], + "call", + [] + |), + [ + sum_ops_expr_with_init; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + mpages_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + mpages_cell; + M.read (| meta |) + ] + |) + ] + |); + M.read (| meta |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (let + config := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ F + ], + "allocated_memory_pages_diff", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| + config + |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |); + M.read (| + meta + |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)); + Value.StructTuple + "core::option::Option::None" + [] + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c5g. context_input_index change" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ], + "call", + [] + |), + [ + sum_ops_expr_with_init; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + context_input_index_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + context_input_index_cell; + M.read (| meta |) + ] + |) + ] + |); + M.read (| meta |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (let + config := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ F + ], + "context_input_index_increase", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| + config + |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |); + M.read (| + meta + |); + common_config + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)); + Value.StructTuple + "core::option::Option::None" + [] + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c5h. context_output_index change" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ], + "call", + [] + |), + [ + sum_ops_expr_with_init; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + context_output_index_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + context_output_index_cell; + M.read (| meta |) + ] + |) + ] + |); + M.read (| meta |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (let + config := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ F + ], + "context_output_index_increase", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| + config + |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |); + M.read (| + meta + |); + common_config + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)); + Value.StructTuple + "core::option::Option::None" + [] + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c6a. eid change" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ eid_cell; M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ eid_cell; M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ enabled_cell; M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c6b. fid change" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ], + "call", + [] + |), + [ + sum_ops_expr_with_init; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ fid_cell; M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ fid_cell; M.read (| meta |) + ] + |) + ] + |); + M.read (| meta |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (let + config := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ + F + ], + "next_fid", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| + config + |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |); + M.read (| + meta + |); + common_config + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + x := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "sub", + [] + |), + [ + M.read (| + x + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ + F + ], + [ + F + ], + "curr_expr", + [] + |), + [ + fid_cell; + M.read (| + meta + |) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)); + Value.StructTuple + "core::option::Option::None" + [] + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c6c. iid change" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ], + "call", + [] + |), + [ + sum_ops_expr_with_init; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + iid_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + iid_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + enabled_cell; + M.read (| meta |) + ] + |) + ] + |); + M.read (| meta |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (let + config := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ + F + ], + "next_iid", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| + config + |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |); + M.read (| + meta + |); + common_config + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + x := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ + F + ], + [ + F + ], + "curr_expr", + [] + |), + [ + iid_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ + F + ], + [ + F + ], + "curr_expr", + [] + |), + [ + enabled_cell; + M.read (| + meta + |) + ] + |) + ] + |); + M.read (| + x + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)); + Value.StructTuple + "core::option::Option::None" + [] + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c6d. frame_id change" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ]; + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + ], + "call", + [] + |), + [ + sum_ops_expr_with_init; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + frame_id_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + frame_id_cell; + M.read (| meta |) + ] + |) + ] + |); + M.read (| meta |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (let + config := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ + F + ], + "next_frame_id", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| + config + |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |); + M.read (| + meta + |); + common_config + ] + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + x := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "sub", + [] + |), + [ + M.read (| + x + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ + F + ], + [ + F + ], + "curr_expr", + [] + |), + [ + frame_id_cell; + M.read (| + meta + |) + ] + |) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)); + Value.StructTuple + "core::option::Option::None" + [] + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c7. itable_lookup_encode" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let opcode := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ] + ] + ] + ], + "call", + [] + |), + [ + sum_ops_expr; + Value.Tuple + [ + M.read (| meta |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := + M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let config := + M.copy (| γ |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.dyn + [ + ("delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig::Trait", + []) + ], + [ F ], + "opcode", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_tuple_field (| + M.read (| + config + |), + "delphinus_zkwasm::circuits::etable::OpcodeConfig", + 0 + |) + |); + M.read (| + meta + |) + ] + |) + ])) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |)) + ] + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_function (| + "specs::encode::instruction_table::encode_instruction_table_entry", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + fid_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + iid_cell; + M.read (| meta |) + ] + |); + M.read (| opcode |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + itable_lookup_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::image_table::ImageTableConfig") + [ F ], + "instruction_lookup", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]) + ] + |), + [ + M.read (| image_table |); + M.read (| meta |); + M.read (| Value.String "c8a. itable_lookup in itable" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ itable_lookup_cell; M.read (| meta |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::image_table::ImageTableConfig") + [ F ], + "br_table_lookup", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]) + ] + |), + [ + M.read (| image_table |); + M.read (| meta |); + M.read (| Value.String "c8b. brtable_lookup in brtable" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ brtable_lookup_cell; M.read (| meta |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::rtable::RangeTableConfig") + [ F ], + "configure_in_pow_set", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]) + ] + |), + [ + M.read (| rtable |); + M.read (| meta |); + M.read (| Value.String "c8d. pow_table_lookup in pow_table" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ pow_table_lookup_power_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ pow_table_lookup_modulus_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::traits::ConfigureLookupTable", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig") + [ F ], + [ F ], + "configure_in_table", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| external_host_call_table |); + M.read (| meta |); + M.read (| + Value.String "c8g. external_foreign_call_lookup in foreign table" + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + external_foreign_call_lookup_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableConfig") + [ F ], + "configure_in_table", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]) + ] + |), + [ + M.read (| bit_table |); + M.read (| meta |); + M.read (| Value.String "c8f: bit_table_lookup in bit_table" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + bit_table_lookup_cells, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells", + "op" + |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + bit_table_lookup_cells, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells", + "left" + |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + bit_table_lookup_cells, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells", + "right" + |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + bit_table_lookup_cells, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells", + "result" + |); + M.read (| meta |) + ] + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c9. maximal memory pages consistent" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + maximal_memory_pages_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + maximal_memory_pages_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| step_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::etable::EventTableConfig" + [ + ("step_sel", M.read (| step_sel |)); + ("common_config", M.read (| common_config |)); + ("op_configs", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "specs::itable::OpcodeClassPlain"; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::OpcodeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| op_configs |) ] + |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure" (configure F). + End Impl_delphinus_zkwasm_circuits_etable_EventTableConfig_F. + + (* StructRecord + { + name := "EventTableChip"; + ty_params := [ "F" ]; + fields := + [ + ("config", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::etable::EventTableConfig") [ F ]); + ("capability", Ty.path "usize") + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_EventTableChip_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::etable::EventTableChip") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::etable::EventTableChip" + [ + ("config", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::EventTableConfig") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "config" + |) + ] + |)); + ("capability", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "usize", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::EventTableChip", + "capability" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_etable_EventTableChip_F. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableChip_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::etable::EventTableChip") [ F ]. + + (* + pub(super) fn new( + config: EventTableConfig, + capability: usize, + max_available_rows: usize, + ) -> Self { + assert!(capability * EVENT_TABLE_ENTRY_ROWS as usize <= max_available_rows); + + Self { config, capability } + } + *) + Definition new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ config; capability; max_available_rows ] => + ltac:(M.monadic + (let config := M.alloc (| config |) in + let capability := M.alloc (| capability |) in + let max_available_rows := M.alloc (| max_available_rows |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.le + (BinOp.Panic.mul (| + Integer.Usize, + M.read (| capability |), + M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::etable::EVENT_TABLE_ENTRY_ROWS" + |) + |)) + |)) + (M.read (| max_available_rows |))) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "assertion failed: capability * EVENT_TABLE_ENTRY_ROWS as usize <= max_available_rows" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::etable::EventTableChip" + [ ("config", M.read (| config |)); ("capability", M.read (| capability |)) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "new" (new F). + End Impl_delphinus_zkwasm_circuits_etable_EventTableChip_F. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_bin.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_bin.v new file mode 100644 index 000000000..f2ad267d3 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_bin.v @@ -0,0 +1,13293 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_bin. + (* StructRecord + { + name := "BinConfig"; + ty_params := [ "F" ]; + fields := + [ + ("lhs", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn") + [ F ]); + ("rhs", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn") + [ F ]); + ("is_i32", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("d", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("d_flag_helper_diff", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("aux1", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("aux2", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("overflow", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_add", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_sub", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_mul", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_div_u", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_rem_u", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_div_s", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_rem_s", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_div_s_or_rem_s", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("res_flag", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("size_modulus", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("normalized_lhs", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("normalized_rhs", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("d_leading_u16", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("degree_helper1", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("degree_helper2", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("memory_table_lookup_stack_read_lhs", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_read_rhs", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_write", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "BinConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_bin_BinConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let is_i32 = allocator.alloc_bit_cell(); + let lhs = allocator + .alloc_u64_with_flag_bit_cell_dyn(constraint_builder, move |meta| is_i32.expr(meta)); + let rhs = allocator + .alloc_u64_with_flag_bit_cell_dyn(constraint_builder, move |meta| is_i32.expr(meta)); + + let d = allocator.alloc_u64_cell(); + let d_flag_helper_diff = allocator.alloc_common_range_cell(); + + let aux1 = allocator.alloc_u64_cell(); + let aux2 = allocator.alloc_u64_cell(); + + let overflow = allocator.alloc_bit_cell(); + let is_add = allocator.alloc_bit_cell(); + let is_sub = allocator.alloc_bit_cell(); + let is_mul = allocator.alloc_bit_cell(); + let is_div_u = allocator.alloc_bit_cell(); + let is_div_s = allocator.alloc_bit_cell(); + let is_rem_u = allocator.alloc_bit_cell(); + let is_rem_s = allocator.alloc_bit_cell(); + + let is_div_s_or_rem_s = allocator.alloc_bit_cell(); + + let d_leading_u16 = allocator.alloc_unlimited_cell(); + let normalized_lhs = allocator.alloc_unlimited_cell(); + let normalized_rhs = allocator.alloc_unlimited_cell(); + let res_flag = allocator.alloc_unlimited_cell(); + let size_modulus = allocator.alloc_unlimited_cell(); + let degree_helper1 = allocator.alloc_unlimited_cell(); + let degree_helper2 = allocator.alloc_unlimited_cell(); + + let eid = common_config.eid_cell; + let sp = common_config.sp_cell; + + let memory_table_lookup_stack_read_rhs = allocator.alloc_memory_table_lookup_read_cell( + "op_bin stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |meta| is_i32.expr(meta), + move |meta| rhs.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + let memory_table_lookup_stack_read_lhs = allocator.alloc_memory_table_lookup_read_cell( + "op_bin stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(2), + move |meta| is_i32.expr(meta), + move |meta| lhs.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + let memory_table_lookup_stack_write = allocator + .alloc_memory_table_lookup_write_cell_with_value( + "op_bin stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(2), + move |meta| is_i32.expr(meta), + move |____| constant_from!(1), + ); + + let res = memory_table_lookup_stack_write.value_cell; + + constraint_builder.push( + "bin: selector", + Box::new(move |meta| { + vec![ + (is_add.expr(meta) + + is_sub.expr(meta) + + is_mul.expr(meta) + + is_div_u.expr(meta) + + is_rem_u.expr(meta) + + is_div_s.expr(meta) + + is_rem_s.expr(meta) + - constant_from!(1)), + ] + }), + ); + + // cs: size_modulus = if is_i32 { 1 << 32 } else { 1 << 64 } + constraint_builder.push( + "bin: size modulus", + Box::new(move |meta| { + vec![ + size_modulus.expr(meta) - constant_from_bn!(&(BigUint::from(1u64) << 64usize)) + + is_i32.expr(meta) * constant_from!((u32::MAX as u64) << 32), + ] + }), + ); + + constraint_builder.push( + "c.bin.add", + Box::new(move |meta| { + // The range of res can be limited with is_i32 in memory table + vec![ + (lhs.u64_cell.expr(meta) + rhs.u64_cell.expr(meta) + - res.expr(meta) + - overflow.expr(meta) * size_modulus.expr(meta)) + * is_add.expr(meta), + ] + }), + ); + + constraint_builder.push( + "c.bin.sub", + Box::new(move |meta| { + // The range of res can be limited with is_i32 in memory table + vec![ + (rhs.u64_cell.expr(meta) + res.expr(meta) + - lhs.u64_cell.expr(meta) + - overflow.expr(meta) * size_modulus.expr(meta)) + * is_sub.expr(meta), + ] + }), + ); + + constraint_builder.push( + "bin: mul constraints", + Box::new(move |meta| { + // The range of res can be limited with is_i32 in memory table + vec![ + (lhs.u64_cell.expr(meta) * rhs.u64_cell.expr(meta) + - aux1.u64_cell.expr(meta) * size_modulus.expr(meta) + - res.expr(meta)) + * is_mul.expr(meta), + ] + }), + ); + + constraint_builder.push( + "bin: div_u/rem_u constraints", + Box::new(move |meta| { + vec![ + (lhs.u64_cell.expr(meta) + - rhs.u64_cell.expr(meta) * d.u64_cell.expr(meta) + - aux1.u64_cell.expr(meta)) + * (is_rem_u.expr(meta) + is_div_u.expr(meta)), + (aux1.u64_cell.expr(meta) + aux2.u64_cell.expr(meta) + constant_from!(1) + - rhs.u64_cell.expr(meta)) + * (is_rem_u.expr(meta) + is_div_u.expr(meta)), + (res.expr(meta) - d.u64_cell.expr(meta)) * is_div_u.expr(meta), + (res.expr(meta) - aux1.u64_cell.expr(meta)) * is_rem_u.expr(meta), + ] + }), + ); + + constraint_builder.push( + "bin: res flag", + Box::new(move |meta| { + vec![ + res_flag.expr(meta) + - (lhs.flag_bit_cell.expr(meta) + rhs.flag_bit_cell.expr(meta) + - constant_from!(2) + * lhs.flag_bit_cell.expr(meta) + * rhs.flag_bit_cell.expr(meta)), + ] + }), + ); + + constraint_builder.push( + "bin: div_s/rem_s constraints common", + Box::new(move |meta| { + let normalized_lhs_expr = lhs.u64_cell.expr(meta) + * (constant_from!(1) - lhs.flag_bit_cell.expr(meta)) + + (size_modulus.expr(meta) - lhs.u64_cell.expr(meta)) + * lhs.flag_bit_cell.expr(meta); + let normalized_rhs_expr = rhs.u64_cell.expr(meta) + * (constant_from!(1) - rhs.flag_bit_cell.expr(meta)) + + (size_modulus.expr(meta) - rhs.u64_cell.expr(meta)) + * rhs.flag_bit_cell.expr(meta); + + let d_leading_u16_expr = d.u16_cells_le[3].expr(meta) + + is_i32.expr(meta) + * (d.u16_cells_le[1].expr(meta) - d.u16_cells_le[3].expr(meta)); + vec![ + // d_flag must be zero if res_flag is zero + is_div_s_or_rem_s.expr(meta) - (is_div_s.expr(meta) + is_rem_s.expr(meta)), + normalized_lhs.expr(meta) - normalized_lhs_expr, + normalized_rhs.expr(meta) - normalized_rhs_expr, + (d_leading_u16.expr(meta) - d_leading_u16_expr) * is_div_s_or_rem_s.expr(meta), + (d_leading_u16.expr(meta) + d_flag_helper_diff.expr(meta) + - constant_from!(0x7fff)) + * (constant_from!(1) - res_flag.expr(meta)) + * is_div_s_or_rem_s.expr(meta), + (normalized_lhs.expr(meta) + - normalized_rhs.expr(meta) * d.u64_cell.expr(meta) + - aux1.u64_cell.expr(meta)) + * is_div_s_or_rem_s.expr(meta), + (aux1.u64_cell.expr(meta) + aux2.u64_cell.expr(meta) + constant_from!(1) + - normalized_rhs.expr(meta)) + * is_div_s_or_rem_s.expr(meta), + ] + }), + ); + + constraint_builder.push( + "bin: div_s constraints res", + Box::new(move |meta| { + vec![ + (res.expr(meta) - d.u64_cell.expr(meta)) + * (constant_from!(1) - res_flag.expr(meta)) + * is_div_s.expr(meta), + (degree_helper1.expr(meta) + - (d.u64_cell.expr(meta) + res.expr(meta)) * res_flag.expr(meta)) + * is_div_s.expr(meta), + /* + * If only one of the left and the right is negative, + * `res` must equal to `size_modulus - normalized quotient(d)`, or + * `res` and `d` are both zero. + */ + (res.expr(meta) + d.u64_cell.expr(meta) - size_modulus.expr(meta)) + * degree_helper1.expr(meta) + * is_div_s.expr(meta), + ] + }), + ); + + constraint_builder.push( + "bin: rem_s constraints res", + Box::new(move |meta| { + vec![ + (res.expr(meta) - aux1.u64_cell.expr(meta)) + * (constant_from!(1) - lhs.flag_bit_cell.expr(meta)) + * is_rem_s.expr(meta), + (degree_helper2.expr(meta) + - (aux1.u64_cell.expr(meta) + res.expr(meta)) + * lhs.flag_bit_cell.expr(meta)) // The sign of the left operator determines the flag bit of the result value. + * is_rem_s.expr(meta), + (res.expr(meta) + aux1.u64_cell.expr(meta) - size_modulus.expr(meta)) + * degree_helper2.expr(meta) + * is_rem_s.expr(meta), + ] + }), + ); + + Box::new(BinConfig { + lhs, + rhs, + is_i32, + d, + d_flag_helper_diff, + aux1, + aux2, + overflow, + is_add, + is_sub, + is_mul, + is_div_u, + is_rem_u, + is_div_s, + is_rem_s, + is_div_s_or_rem_s, + memory_table_lookup_stack_read_lhs, + memory_table_lookup_stack_read_rhs, + memory_table_lookup_stack_write, + size_modulus, + res_flag, + normalized_lhs, + normalized_rhs, + d_leading_u16, + degree_helper1, + degree_helper2, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let is_i32 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let lhs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_with_flag_bit_cell_dyn", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let rhs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_with_flag_bit_cell_dyn", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let d := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let d_flag_helper_diff := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let aux1 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let aux2 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let overflow := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_add := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_sub := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_mul := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_div_u := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_div_s := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_rem_u := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_rem_s := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_div_s_or_rem_s := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let d_leading_u16 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let normalized_lhs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let normalized_rhs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let res_flag := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let size_modulus := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let degree_helper1 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let degree_helper2 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let memory_table_lookup_stack_read_rhs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_bin stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_read_lhs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_bin stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 2 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_write := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell_with_value", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_bin stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 2 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let res := + M.copy (| + M.SubPointer.get_struct_record_field (| + memory_table_lookup_stack_write, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "value_cell" + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "bin: selector" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ + F + ], + [ + F + ], + "expr", + [] + |), + [ + is_add; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ + F + ], + [ + F + ], + "expr", + [] + |), + [ + is_sub; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ + F + ], + [ F + ], + "expr", + [] + |), + [ + is_mul; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_div_u; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_rem_u; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_div_s; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_rem_s; + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "bin: size modulus" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + size_modulus; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "usize" + ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + Value.Integer + 1 + ] + |); + Value.Integer + 64 + ] + |) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_i32; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + M.rust_cast + (M.read (| + M.get_constant (| + "core::num::MAX" + |) + |)), + Value.Integer + 32 + |) + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "c.bin.add" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + overflow; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + size_modulus; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_add; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "c.bin.sub" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + overflow; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + size_modulus; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_sub; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "bin: mul constraints" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + aux1, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + size_modulus; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_mul; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "bin: div_u/rem_u constraints" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + d, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + aux1, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_rem_u; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_div_u; + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + aux1, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + aux2, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_rem_u; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_div_u; + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + d, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_div_u; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + aux1, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_rem_u; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "bin: res flag" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_flag; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "flag_bit_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "flag_bit_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 2 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "flag_bit_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "flag_bit_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "bin: div_s/rem_s constraints common" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let normalized_lhs_expr := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer 1 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "flag_bit_cell" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + size_modulus; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "flag_bit_cell" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |) + |) in + let normalized_rhs_expr := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer 1 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "flag_bit_cell" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + size_modulus; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "flag_bit_cell" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |) + |) in + let d_leading_u16_expr := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + d, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| Value.Integer 3 |) + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + d, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| + Value.Integer 1 + |) + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + d, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| + Value.Integer 3 + |) + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_div_s_or_rem_s; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_div_s; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_rem_s; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + normalized_lhs; + M.read (| meta |) + ] + |); + M.read (| + normalized_lhs_expr + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + normalized_rhs; + M.read (| meta |) + ] + |); + M.read (| + normalized_rhs_expr + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + d_leading_u16; + M.read (| + meta + |) + ] + |); + M.read (| + d_leading_u16_expr + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_div_s_or_rem_s; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + d_leading_u16; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + d_flag_helper_diff; + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 32767 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_flag; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_div_s_or_rem_s; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + normalized_lhs; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + normalized_rhs; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + d, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + aux1, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_div_s_or_rem_s; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + aux1, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + aux2, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + normalized_rhs; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_div_s_or_rem_s; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "bin: div_s constraints res" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + d, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_flag; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_div_s; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + degree_helper1; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + d, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_flag; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_div_s; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + d, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + size_modulus; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + degree_helper1; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_div_s; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "bin: rem_s constraints res" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + aux1, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "flag_bit_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_rem_s; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + degree_helper2; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + aux1, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "flag_bit_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_rem_s; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + aux1, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + size_modulus; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + degree_helper2; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_rem_s; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig" + [ + ("lhs", M.read (| lhs |)); + ("rhs", M.read (| rhs |)); + ("is_i32", M.read (| is_i32 |)); + ("d", M.read (| d |)); + ("d_flag_helper_diff", M.read (| d_flag_helper_diff |)); + ("aux1", M.read (| aux1 |)); + ("aux2", M.read (| aux2 |)); + ("overflow", M.read (| overflow |)); + ("is_add", M.read (| is_add |)); + ("is_sub", M.read (| is_sub |)); + ("is_mul", M.read (| is_mul |)); + ("is_div_u", M.read (| is_div_u |)); + ("is_rem_u", M.read (| is_rem_u |)); + ("is_div_s", M.read (| is_div_s |)); + ("is_rem_s", M.read (| is_rem_s |)); + ("is_div_s_or_rem_s", M.read (| is_div_s_or_rem_s |)); + ("memory_table_lookup_stack_read_lhs", + M.read (| memory_table_lookup_stack_read_lhs |)); + ("memory_table_lookup_stack_read_rhs", + M.read (| memory_table_lookup_stack_read_rhs |)); + ("memory_table_lookup_stack_write", + M.read (| memory_table_lookup_stack_write |)); + ("size_modulus", M.read (| size_modulus |)); + ("res_flag", M.read (| res_flag |)); + ("normalized_lhs", M.read (| normalized_lhs |)); + ("normalized_rhs", M.read (| normalized_rhs |)); + ("d_leading_u16", M.read (| d_leading_u16 |)); + ("degree_helper1", M.read (| degree_helper1 |)); + ("degree_helper2", M.read (| degree_helper2 |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_bin_BinConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_bin_BinConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + constant!(bn_to_field( + &(BigUint::from(OpcodeClass::Bin as u64) << OPCODE_CLASS_SHIFT) + )) + self.is_add.expr(meta) + * constant!(bn_to_field( + &(BigUint::from(BinOp::Add as u64) << OPCODE_ARG0_SHIFT) + )) + + self.is_sub.expr(meta) + * constant!(bn_to_field( + &(BigUint::from(BinOp::Sub as u64) << OPCODE_ARG0_SHIFT) + )) + + self.is_mul.expr(meta) + * constant!(bn_to_field( + &(BigUint::from(BinOp::Mul as u64) << OPCODE_ARG0_SHIFT) + )) + + self.is_div_u.expr(meta) + * constant!(bn_to_field( + &(BigUint::from(BinOp::UnsignedDiv as u64) << OPCODE_ARG0_SHIFT) + )) + + self.is_rem_u.expr(meta) + * constant!(bn_to_field( + &(BigUint::from(BinOp::UnsignedRem as u64) << OPCODE_ARG0_SHIFT) + )) + + self.is_div_s.expr(meta) + * constant!(bn_to_field( + &(BigUint::from(BinOp::SignedDiv as u64) << OPCODE_ARG0_SHIFT) + )) + + self.is_rem_s.expr(meta) + * constant!(bn_to_field( + &(BigUint::from(BinOp::SignedRem as u64) << OPCODE_ARG0_SHIFT) + )) + + self.is_i32.expr(meta) + * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG1_SHIFT))) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 9 + |)) + ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_CLASS_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "is_add" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 0) + ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "is_sub" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 1) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "is_mul" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 2) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "is_div_u" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 3) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "is_rem_u" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 4) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "is_div_s" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 5) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "is_rem_s" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 6) ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_ARG0_SHIFT" |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "is_i32" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_ARG1_SHIFT" |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + let (class, var_type, shift, left, right, value) = match &entry.eentry.step_info { + StepInfo::I32BinOp { + class, + left, + right, + value, + } => { + let var_type = VarType::I32; + let left = *left as u32 as u64; + let right = *right as u32 as u64; + let value = *value as u32 as u64; + + (class, var_type, 32, left, right, value) + } + + StepInfo::I64BinOp { + class, + left, + right, + value, + } => { + let var_type = VarType::I64; + let left = *left as u64; + let right = *right as u64; + let value = *value as u64; + + (class, var_type, 64, left, right, value) + } + + _ => unreachable!(), + }; + + self.lhs + .assign(ctx, left.into(), var_type == VarType::I32)?; + self.rhs + .assign(ctx, right.into(), var_type == VarType::I32)?; + + let (normalized_lhs, normalized_rhs) = if var_type == VarType::I32 { + let normalized_lhs = if left >> 31 == 1 { + u32::MAX as u64 - left + 1 + } else { + left + }; + let normalized_rhs = if right >> 31 == 1 { + u32::MAX as u64 - right + 1 + } else { + right + }; + (normalized_lhs, normalized_rhs) + } else { + let normalized_lhs = if left >> 63 == 1 { + u64::MAX as u64 - left + 1 + } else { + left + }; + let normalized_rhs = if right >> 63 == 1 { + u64::MAX as u64 - right + 1 + } else { + right + }; + (normalized_lhs, normalized_rhs) + }; + self.normalized_lhs.assign(ctx, normalized_lhs.into())?; + self.normalized_rhs.assign(ctx, normalized_rhs.into())?; + + self.size_modulus + .assign_bn(ctx, &(BigUint::from(1u64) << shift))?; + + let (lhs_flag, res_flag) = { + let shift = if var_type == VarType::I32 { 31 } else { 63 }; + let lhs_flag = left >> shift; + let rhs_flag = right >> shift; + let res_flag = lhs_flag ^ rhs_flag; + self.res_flag.assign(ctx, res_flag.into())?; + + (lhs_flag, res_flag) + }; + + match class { + BinOp::Add => { + self.is_add.assign(ctx, F::one())?; + self.overflow.assign_bn( + ctx, + &((BigUint::from(left) + BigUint::from(right)) >> shift), + )?; + } + BinOp::Sub => { + self.is_sub.assign(ctx, F::one())?; + self.overflow.assign_bn( + ctx, + &((BigUint::from(right) + BigUint::from(value)) >> shift), + )?; + } + BinOp::Mul => { + self.is_mul.assign(ctx, F::one())?; + self.aux1 + .assign(ctx, ((left as u128 * right as u128) >> shift) as u64)?; + } + BinOp::UnsignedDiv => { + self.is_div_u.assign(ctx, F::one())?; + } + BinOp::UnsignedRem => { + self.is_rem_u.assign(ctx, F::one())?; + } + BinOp::SignedDiv => { + self.is_div_s.assign(ctx, F::one())?; + self.is_div_s_or_rem_s.assign(ctx, F::one())?; + } + BinOp::SignedRem => { + self.is_rem_s.assign(ctx, F::one())?; + self.is_div_s_or_rem_s.assign(ctx, F::one())?; + } + }; + + match class { + BinOp::UnsignedDiv | BinOp::UnsignedRem => { + self.d.assign(ctx, left / right)?; + self.aux1.assign(ctx, left % right)?; + self.aux2.assign(ctx, right - left % right - 1)?; + } + BinOp::SignedDiv | BinOp::SignedRem => { + let left_flag = left >> (shift - 1) != 0; + let right_flag = right >> (shift - 1) != 0; + + let mask = if shift == 32 { + u32::MAX as u64 + } else { + u64::MAX + }; + let normalized_lhs = if left_flag { (1 + !left) & mask } else { left }; + let normalized_rhs = if right_flag { + (1 + !right) & mask + } else { + right + }; + let d = normalized_lhs / normalized_rhs; + let rem = normalized_lhs % normalized_rhs; + let d_leading_u16 = d >> (shift - 16); + + self.degree_helper1 + .assign(ctx, (F::from(d) + F::from(value)) * F::from(res_flag))?; + + self.degree_helper2.assign_bn( + ctx, + &((BigUint::from(rem) + BigUint::from(value)) * lhs_flag), + )?; + self.d_leading_u16.assign(ctx, d_leading_u16.into())?; + self.d_flag_helper_diff.assign( + ctx, + if d_leading_u16 >= 0x7fff { + F::from(0) + } else { + F::from(0x7fff - d_leading_u16) + }, + )?; + self.d.assign(ctx, d)?; + self.aux1.assign(ctx, rem)?; + self.aux2.assign(ctx, normalized_rhs - rem - 1)?; + } + _ => {} + } + + match var_type { + VarType::I32 => { + self.is_i32.assign(ctx, F::one())?; + } + _ => {} + }; + + self.memory_table_lookup_stack_read_rhs.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + var_type == VarType::I32, + right, + )?; + + self.memory_table_lookup_stack_read_lhs.assign( + ctx, + entry.memory_rw_entires[1].start_eid, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + step.current.sp + 2, + LocationType::Stack, + var_type == VarType::I32, + left, + )?; + + self.memory_table_lookup_stack_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[2].end_eid, + step.current.sp + 2, + LocationType::Stack, + var_type == VarType::I32, + value, + )?; + + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinOp", + "class" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinOp", + "left" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinOp", + "right" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinOp", + "value" + |) in + let class := M.alloc (| γ1_0 |) in + let left := M.alloc (| γ1_1 |) in + let right := M.alloc (| γ1_2 |) in + let value := M.alloc (| γ1_3 |) in + let var_type := + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) in + let left := + M.alloc (| + M.rust_cast (M.rust_cast (M.read (| M.read (| left |) |))) + |) in + let right := + M.alloc (| + M.rust_cast (M.rust_cast (M.read (| M.read (| right |) |))) + |) in + let value := + M.alloc (| + M.rust_cast (M.rust_cast (M.read (| M.read (| value |) |))) + |) in + M.alloc (| + Value.Tuple + [ + M.read (| class |); + M.read (| var_type |); + Value.Integer 32; + M.read (| left |); + M.read (| right |); + M.read (| value |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinOp", + "class" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinOp", + "left" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinOp", + "right" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinOp", + "value" + |) in + let class := M.alloc (| γ1_0 |) in + let left := M.alloc (| γ1_1 |) in + let right := M.alloc (| γ1_2 |) in + let value := M.alloc (| γ1_3 |) in + let var_type := + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I64" [] + |) in + let left := + M.alloc (| M.rust_cast (M.read (| M.read (| left |) |)) |) in + let right := + M.alloc (| M.rust_cast (M.read (| M.read (| right |) |)) |) in + let value := + M.alloc (| M.rust_cast (M.read (| M.read (| value |) |)) |) in + M.alloc (| + Value.Tuple + [ + M.read (| class |); + M.read (| var_type |); + Value.Integer 64; + M.read (| left |); + M.read (| right |); + M.read (| value |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_2 := M.SubPointer.get_tuple_field (| γ, 2 |) in + let γ0_3 := M.SubPointer.get_tuple_field (| γ, 3 |) in + let γ0_4 := M.SubPointer.get_tuple_field (| γ, 4 |) in + let γ0_5 := M.SubPointer.get_tuple_field (| γ, 5 |) in + let class := M.copy (| γ0_0 |) in + let var_type := M.copy (| γ0_1 |) in + let shift := M.copy (| γ0_2 |) in + let left := M.copy (| γ0_3 |) in + let right := M.copy (| γ0_4 |) in + let value := M.copy (| γ0_5 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "lhs" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ Ty.path "u64" ], + "into", + [] + |), + [ M.read (| left |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + var_type; + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "rhs" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ Ty.path "u64" ], + "into", + [] + |), + [ M.read (| right |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + var_type; + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.match_operator (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + var_type; + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let normalized_lhs := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (BinOp.Panic.shr (| + M.read (| left |), + Value.Integer 31 + |)) + (Value.Integer 1) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + BinOp.Panic.add (| + Integer.U64, + BinOp.Panic.sub (| + Integer.U64, + M.rust_cast + (M.read (| + M.get_constant (| "core::num::MAX" |) + |)), + M.read (| left |) + |), + Value.Integer 1 + |) + |))); + fun γ => ltac:(M.monadic left) + ] + |) + |) in + let normalized_rhs := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (BinOp.Panic.shr (| + M.read (| right |), + Value.Integer 31 + |)) + (Value.Integer 1) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + BinOp.Panic.add (| + Integer.U64, + BinOp.Panic.sub (| + Integer.U64, + M.rust_cast + (M.read (| + M.get_constant (| "core::num::MAX" |) + |)), + M.read (| right |) + |), + Value.Integer 1 + |) + |))); + fun γ => ltac:(M.monadic right) + ] + |) + |) in + M.alloc (| + Value.Tuple + [ + M.read (| normalized_lhs |); + M.read (| normalized_rhs |) + ] + |))); + fun γ => + ltac:(M.monadic + (let normalized_lhs := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (BinOp.Panic.shr (| + M.read (| left |), + Value.Integer 63 + |)) + (Value.Integer 1) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + BinOp.Panic.add (| + Integer.U64, + BinOp.Panic.sub (| + Integer.U64, + M.read (| + M.use + (M.get_constant (| + "core::num::MAX" + |)) + |), + M.read (| left |) + |), + Value.Integer 1 + |) + |))); + fun γ => ltac:(M.monadic left) + ] + |) + |) in + let normalized_rhs := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (BinOp.Panic.shr (| + M.read (| right |), + Value.Integer 63 + |)) + (Value.Integer 1) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + BinOp.Panic.add (| + Integer.U64, + BinOp.Panic.sub (| + Integer.U64, + M.read (| + M.use + (M.get_constant (| + "core::num::MAX" + |)) + |), + M.read (| right |) + |), + Value.Integer 1 + |) + |))); + fun γ => ltac:(M.monadic right) + ] + |) + |) in + M.alloc (| + Value.Tuple + [ + M.read (| normalized_lhs |); + M.read (| normalized_rhs |) + ] + |))) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let normalized_lhs := M.copy (| γ0_0 |) in + let normalized_rhs := M.copy (| γ0_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "normalized_lhs" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| normalized_lhs |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "normalized_rhs" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| normalized_rhs |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_bn", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "size_modulus" + |); + M.read (| ctx |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "i32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| shift |) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.match_operator (| + let shift := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + var_type; + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| Value.Integer 31 |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Integer 63 |))) + ] + |) + |) in + let lhs_flag := + M.alloc (| + BinOp.Panic.shr (| + M.read (| left |), + M.read (| shift |) + |) + |) in + let rhs_flag := + M.alloc (| + BinOp.Panic.shr (| + M.read (| right |), + M.read (| shift |) + |) + |) in + let res_flag := + M.alloc (| + BinOp.Pure.bit_xor + (M.read (| lhs_flag |)) + (M.read (| rhs_flag |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "res_flag" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| res_flag |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple + [ M.read (| lhs_flag |); M.read (| res_flag |) ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let lhs_flag := M.copy (| γ0_0 |) in + let res_flag := M.copy (| γ0_1 |) in + let _ := + M.match_operator (| + class, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "is_add" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bn", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "overflow" + |); + M.read (| ctx |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shr", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "i32" ], + "shr", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + left + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + right + |) + ] + |) + ] + |); + M.read (| shift |) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "is_sub" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bn", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "overflow" + |); + M.read (| ctx |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shr", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "i32" ], + "shr", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + right + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + value + |) + ] + |) + ] + |); + M.read (| shift |) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "is_mul" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "aux1" + |); + M.read (| ctx |); + M.rust_cast + (BinOp.Panic.shr (| + BinOp.Panic.mul (| + Integer.U128, + M.rust_cast + (M.read (| left |)), + M.rust_cast + (M.read (| right |)) + |), + M.read (| shift |) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "is_div_u" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "is_rem_u" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "is_div_s" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "is_div_s_or_rem_s" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "is_rem_s" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "is_div_s_or_rem_s" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + class, + [ + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + Value.Tuple [])); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + Value.Tuple [])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [] => + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "d" + |); + M.read (| ctx |); + BinOp.Panic.div (| + Integer.U64, + M.read (| left |), + M.read (| right |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "aux1" + |); + M.read (| ctx |); + BinOp.Panic.rem (| + Integer.U64, + M.read (| left |), + M.read (| right |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "aux2" + |); + M.read (| ctx |); + BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.sub (| + Integer.U64, + M.read (| + right + |), + BinOp.Panic.rem (| + Integer.U64, + M.read (| + left + |), + M.read (| + right + |) + |) + |), + Value.Integer 1 + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + Value.Tuple [])); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + Value.Tuple [])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [] => + let left_flag := + M.alloc (| + BinOp.Pure.ne + (BinOp.Panic.shr (| + M.read (| left |), + BinOp.Panic.sub (| + Integer.I32, + M.read (| shift |), + Value.Integer 1 + |) + |)) + (Value.Integer 0) + |) in + let right_flag := + M.alloc (| + BinOp.Pure.ne + (BinOp.Panic.shr (| + M.read (| right |), + BinOp.Panic.sub (| + Integer.I32, + M.read (| shift |), + Value.Integer 1 + |) + |)) + (Value.Integer 0) + |) in + let mask := + M.copy (| + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| + shift + |)) + (Value.Integer + 32) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.rust_cast + (M.read (| + M.get_constant (| + "core::num::MAX" + |) + |)) + |))); + fun γ => + ltac:(M.monadic + (M.get_constant (| + "core::num::MAX" + |))) + ] + |) + |) in + let normalized_lhs := + M.copy (| + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use left_flag in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + BinOp.Pure.bit_and + (BinOp.Panic.add (| + Integer.U64, + Value.Integer 1, + UnOp.Pure.not + (M.read (| + left + |)) + |)) + (M.read (| + mask + |)) + |))); + fun γ => + ltac:(M.monadic left) + ] + |) + |) in + let normalized_rhs := + M.copy (| + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use right_flag in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + BinOp.Pure.bit_and + (BinOp.Panic.add (| + Integer.U64, + Value.Integer 1, + UnOp.Pure.not + (M.read (| + right + |)) + |)) + (M.read (| + mask + |)) + |))); + fun γ => + ltac:(M.monadic right) + ] + |) + |) in + let d := + M.alloc (| + BinOp.Panic.div (| + Integer.U64, + M.read (| normalized_lhs |), + M.read (| normalized_rhs |) + |) + |) in + let rem := + M.alloc (| + BinOp.Panic.rem (| + Integer.U64, + M.read (| normalized_lhs |), + M.read (| normalized_rhs |) + |) + |) in + let d_leading_u16 := + M.alloc (| + BinOp.Panic.shr (| + M.read (| d |), + BinOp.Panic.sub (| + Integer.I32, + M.read (| shift |), + Value.Integer 16 + |) + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "degree_helper1" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ F ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + F, + [ F ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + d + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + value + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + res_flag + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_bn", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "degree_helper2" + |); + M.read (| ctx |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "u64" + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + rem + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + value + |) + ] + |) + ] + |); + M.read (| + lhs_flag + |) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "d_leading_u16" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ + M.read (| + d_leading_u16 + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "d_flag_helper_diff" + |); + M.read (| ctx |); + M.read (| + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ge + (M.read (| + d_leading_u16 + |)) + (Value.Integer + 32767) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + Value.Integer + 0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + BinOp.Panic.sub (| + Integer.U64, + Value.Integer + 32767, + M.read (| + d_leading_u16 + |) + |) + ] + |) + |))) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "d" + |); + M.read (| ctx |); + M.read (| d |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "aux1" + |); + M.read (| ctx |); + M.read (| rem |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "aux2" + |); + M.read (| ctx |); + BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.sub (| + Integer.U64, + M.read (| + normalized_rhs + |), + M.read (| rem |) + |), + Value.Integer 1 + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + var_type, + [ + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "is_i32" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "memory_table_lookup_stack_read_rhs" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" + ], + "eq", + [] + |), + [ + var_type; + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |); + M.read (| right |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "memory_table_lookup_stack_read_lhs" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 2 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" + ], + "eq", + [] + |), + [ + var_type; + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |); + M.read (| left |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin::BinConfig", + "memory_table_lookup_stack_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 2 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 2 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" + ], + "eq", + [] + |), + [ + var_type; + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |); + M.read (| value |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ] + |))) + ] + |))) + ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn mops(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, _: &EventTableEntry) -> u32 { + 1 + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Integer 1)) ] |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant!(F::one())) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "one", [] |), + [] + |) + ] + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)); + ("sp_diff", InstanceField.Method (sp_diff F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_bin_BinConfig_F. + End op_bin. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_bin_bit.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_bin_bit.v new file mode 100644 index 000000000..ae5a605cc --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_bin_bit.v @@ -0,0 +1,3015 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_bin_bit. + (* StructRecord + { + name := "BinBitConfig"; + ty_params := [ "F" ]; + fields := + [ + ("is_i32", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("op_class", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("bit_table_lookup", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells") + [ F ]); + ("memory_table_lookup_stack_read_lhs", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_read_rhs", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_write", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "BinBitConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_bin_bit_BinBitConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_bit::BinBitConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let is_i32 = allocator.alloc_bit_cell(); + let op_class = allocator.alloc_common_range_cell(); + + let eid = common_config.eid_cell; + let sp = common_config.sp_cell; + let bit_table_lookup = common_config.bit_table_lookup_cells; + + let memory_table_lookup_stack_read_rhs = allocator + .alloc_memory_table_lookup_read_cell_with_value( + "op_bin stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |meta| is_i32.expr(meta), + move |____| constant_from!(1), + ); + let rhs = memory_table_lookup_stack_read_rhs.value_cell; + + let memory_table_lookup_stack_read_lhs = allocator + .alloc_memory_table_lookup_read_cell_with_value( + "op_bin stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(2), + move |meta| is_i32.expr(meta), + move |____| constant_from!(1), + ); + let lhs = memory_table_lookup_stack_read_lhs.value_cell; + + let memory_table_lookup_stack_write = allocator + .alloc_memory_table_lookup_write_cell_with_value( + "op_bin stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(2), + move |meta| is_i32.expr(meta), + move |____| constant_from!(1), + ); + let res = memory_table_lookup_stack_write.value_cell; + + constraint_builder.push( + "op_bin_bit: lookup", + Box::new(move |meta| { + vec![ + bit_table_lookup.op.expr(meta) - op_class.expr(meta), + bit_table_lookup.left.expr(meta) - lhs.expr(meta), + bit_table_lookup.right.expr(meta) - rhs.expr(meta), + bit_table_lookup.result.expr(meta) - res.expr(meta), + ] + }), + ); + + Box::new(BinBitConfig { + op_class, + is_i32, + bit_table_lookup, + memory_table_lookup_stack_read_lhs, + memory_table_lookup_stack_read_rhs, + memory_table_lookup_stack_write, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let is_i32 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let op_class := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let bit_table_lookup := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "bit_table_lookup_cells" + |) + |) in + let memory_table_lookup_stack_read_rhs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell_with_value", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_bin stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let rhs := + M.copy (| + M.SubPointer.get_struct_record_field (| + memory_table_lookup_stack_read_rhs, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "value_cell" + |) + |) in + let memory_table_lookup_stack_read_lhs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell_with_value", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_bin stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 2 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let lhs := + M.copy (| + M.SubPointer.get_struct_record_field (| + memory_table_lookup_stack_read_lhs, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "value_cell" + |) + |) in + let memory_table_lookup_stack_write := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell_with_value", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_bin stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 2 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let res := + M.copy (| + M.SubPointer.get_struct_record_field (| + memory_table_lookup_stack_write, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "value_cell" + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_bin_bit: lookup" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + bit_table_lookup, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells", + "op" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + op_class; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + bit_table_lookup, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells", + "left" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ lhs; M.read (| meta |) ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + bit_table_lookup, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells", + "right" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ rhs; M.read (| meta |) ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + bit_table_lookup, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells", + "result" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ res; M.read (| meta |) ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_bit::BinBitConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_bit::BinBitConfig" + [ + ("op_class", M.read (| op_class |)); + ("is_i32", M.read (| is_i32 |)); + ("bit_table_lookup", M.read (| bit_table_lookup |)); + ("memory_table_lookup_stack_read_lhs", + M.read (| memory_table_lookup_stack_read_lhs |)); + ("memory_table_lookup_stack_read_rhs", + M.read (| memory_table_lookup_stack_read_rhs |)); + ("memory_table_lookup_stack_write", + M.read (| memory_table_lookup_stack_write |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_bin_bit_BinBitConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_bin_bit_BinBitConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_bin_bit::BinBitConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + constant!(bn_to_field( + &(BigUint::from(OpcodeClass::BinBit as u64) << OPCODE_CLASS_SHIFT) + )) + self.op_class.expr(meta) + * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG0_SHIFT))) + + self.is_i32.expr(meta) + * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG1_SHIFT))) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 12 + |)) + ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_CLASS_SHIFT" |) + |) + ] + |) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_bit::BinBitConfig", + "op_class" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_ARG0_SHIFT" |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_bit::BinBitConfig", + "is_i32" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_ARG1_SHIFT" |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + let (class, vtype, left, right, value) = match entry.eentry.step_info { + StepInfo::I32BinBitOp { + class, + left, + right, + value, + } => { + let vtype = VarType::I32; + let left = left as u32 as u64; + let right = right as u32 as u64; + let value = value as u32 as u64; + (class, vtype, left, right, value) + } + StepInfo::I64BinBitOp { + class, + left, + right, + value, + } => { + let vtype = VarType::I64; + let left = left as u64; + let right = right as u64; + let value = value as u64; + (class, vtype, left, right, value) + } + _ => unreachable!(), + }; + + self.is_i32.assign_bool(ctx, vtype == VarType::I32)?; + + self.bit_table_lookup + .assign(ctx, BitTableOp::BinaryBit(class), left, right, value)?; + + match class { + specs::itable::BitOp::And => { + self.op_class.assign_u32(ctx, BitOp::And as u32)?; + } + specs::itable::BitOp::Or => { + self.op_class.assign_u32(ctx, BitOp::Or as u32)?; + } + specs::itable::BitOp::Xor => { + self.op_class.assign_u32(ctx, BitOp::Xor as u32)?; + } + }; + + self.memory_table_lookup_stack_read_rhs.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + vtype == VarType::I32, + right, + )?; + + self.memory_table_lookup_stack_read_lhs.assign( + ctx, + entry.memory_rw_entires[1].start_eid, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + step.current.sp + 2, + LocationType::Stack, + vtype == VarType::I32, + left, + )?; + + self.memory_table_lookup_stack_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[2].end_eid, + step.current.sp + 2, + LocationType::Stack, + vtype == VarType::I32, + value, + )?; + + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.match_operator (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinBitOp", + "class" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinBitOp", + "left" + |) in + let γ0_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinBitOp", + "right" + |) in + let γ0_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinBitOp", + "value" + |) in + let class := M.copy (| γ0_0 |) in + let left := M.copy (| γ0_1 |) in + let right := M.copy (| γ0_2 |) in + let value := M.copy (| γ0_3 |) in + let vtype := + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) in + let left := + M.alloc (| M.rust_cast (M.rust_cast (M.read (| left |))) |) in + let right := + M.alloc (| M.rust_cast (M.rust_cast (M.read (| right |))) |) in + let value := + M.alloc (| M.rust_cast (M.rust_cast (M.read (| value |))) |) in + M.alloc (| + Value.Tuple + [ + M.read (| class |); + M.read (| vtype |); + M.read (| left |); + M.read (| right |); + M.read (| value |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinBitOp", + "class" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinBitOp", + "left" + |) in + let γ0_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinBitOp", + "right" + |) in + let γ0_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinBitOp", + "value" + |) in + let class := M.copy (| γ0_0 |) in + let left := M.copy (| γ0_1 |) in + let right := M.copy (| γ0_2 |) in + let value := M.copy (| γ0_3 |) in + let vtype := + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I64" [] + |) in + let left := M.alloc (| M.rust_cast (M.read (| left |)) |) in + let right := M.alloc (| M.rust_cast (M.read (| right |)) |) in + let value := M.alloc (| M.rust_cast (M.read (| value |)) |) in + M.alloc (| + Value.Tuple + [ + M.read (| class |); + M.read (| vtype |); + M.read (| left |); + M.read (| right |); + M.read (| value |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_2 := M.SubPointer.get_tuple_field (| γ, 2 |) in + let γ0_3 := M.SubPointer.get_tuple_field (| γ, 3 |) in + let γ0_4 := M.SubPointer.get_tuple_field (| γ, 4 |) in + let class := M.copy (| γ0_0 |) in + let vtype := M.copy (| γ0_1 |) in + let left := M.copy (| γ0_2 |) in + let right := M.copy (| γ0_3 |) in + let value := M.copy (| γ0_4 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_bit::BinBitConfig", + "is_i32" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + vtype; + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_bit::BinBitConfig", + "bit_table_lookup" + |); + M.read (| ctx |); + Value.StructTuple + "delphinus_zkwasm::circuits::bit_table::BitTableOp::BinaryBit" + [ M.read (| class |) ]; + M.read (| left |); + M.read (| right |); + M.read (| value |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + class, + [ + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_bit::BinBitConfig", + "op_class" + |); + M.read (| ctx |); + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::BitOp::And_discriminant" + |), + Value.Integer 0 + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_bit::BinBitConfig", + "op_class" + |); + M.read (| ctx |); + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::BitOp::Or_discriminant" + |), + Value.Integer 0 + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_bit::BinBitConfig", + "op_class" + |); + M.read (| ctx |); + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::BitOp::Xor_discriminant" + |), + Value.Integer 0 + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_bit::BinBitConfig", + "memory_table_lookup_stack_read_rhs" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + vtype; + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| right |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_bit::BinBitConfig", + "memory_table_lookup_stack_read_lhs" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 2 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + vtype; + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| left |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_bit::BinBitConfig", + "memory_table_lookup_stack_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 2 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 2 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + vtype; + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| value |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn mops(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, _: &EventTableEntry) -> u32 { + 1 + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Integer 1)) ] |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant!(F::one())) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "one", [] |), + [] + |) + ] + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)); + ("sp_diff", InstanceField.Method (sp_diff F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_bin_bit_BinBitConfig_F. + End op_bin_bit. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_bin_shift.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_bin_shift.v new file mode 100644 index 000000000..345aee53d --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_bin_shift.v @@ -0,0 +1,11650 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_bin_shift. + (* StructRecord + { + name := "BinShiftConfig"; + ty_params := [ "F" ]; + fields := + [ + ("lhs", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn") + [ F ]); + ("rhs", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("round", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("rem", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("diff", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("pad", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("res", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("rhs_modulus", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("size_modulus", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("rhs_round", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("rhs_rem", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("rhs_rem_diff", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("is_i32", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_shl", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_shr_u", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_shr_s", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_rotl", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_rotr", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_l", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_r", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("degree_helper", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("lookup_pow_modulus", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("lookup_pow_power", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("memory_table_lookup_stack_read_lhs", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_read_rhs", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_write", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "BinShiftConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_bin_shift_BinShiftConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let is_i32 = allocator.alloc_bit_cell(); + let lhs = allocator + .alloc_u64_with_flag_bit_cell_dyn(constraint_builder, move |meta| is_i32.expr(meta)); + let rhs = allocator.alloc_u64_cell(); + let round = allocator.alloc_u64_cell(); + let rem = allocator.alloc_u64_cell(); + let diff = allocator.alloc_u64_cell(); + let pad = allocator.alloc_unlimited_cell(); + let rhs_modulus = allocator.alloc_unlimited_cell(); + let size_modulus = allocator.alloc_unlimited_cell(); + + let rhs_round = allocator.alloc_common_range_cell(); + let rhs_rem = allocator.alloc_common_range_cell(); + let rhs_rem_diff = allocator.alloc_common_range_cell(); + + let is_shl = allocator.alloc_bit_cell(); + let is_shr_u = allocator.alloc_bit_cell(); + let is_shr_s = allocator.alloc_bit_cell(); + let is_rotl = allocator.alloc_bit_cell(); + let is_rotr = allocator.alloc_bit_cell(); + + let is_l = allocator.alloc_bit_cell(); + let is_r = allocator.alloc_bit_cell(); + + let degree_helper = allocator.alloc_unlimited_cell(); + + let lookup_pow_modulus = common_config.pow_table_lookup_modulus_cell; + let lookup_pow_power = common_config.pow_table_lookup_power_cell; + + let eid = common_config.eid_cell; + let sp = common_config.sp_cell; + + let memory_table_lookup_stack_read_rhs = allocator.alloc_memory_table_lookup_read_cell( + "op_bin_shift stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |meta| is_i32.expr(meta), + move |meta| rhs.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + let memory_table_lookup_stack_read_lhs = allocator.alloc_memory_table_lookup_read_cell( + "op_bin_shift stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(2), + move |meta| is_i32.expr(meta), + move |meta| lhs.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + let memory_table_lookup_stack_write = allocator + .alloc_memory_table_lookup_write_cell_with_value( + "op_bin_shift stack write", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(2), + move |meta| is_i32.expr(meta), + move |____| constant_from!(1), + ); + let res = memory_table_lookup_stack_write.value_cell; + + constraint_builder.push( + "bin_shift op select", + Box::new(move |meta| { + vec![ + is_shr_u.expr(meta) + is_shr_s.expr(meta) + is_rotr.expr(meta) + - is_r.expr(meta), + is_shl.expr(meta) + is_rotl.expr(meta) - is_l.expr(meta), + is_l.expr(meta) + is_r.expr(meta) - constant_from!(1), + ] + }), + ); + + // cs 1: rhs_modulus = if is_i32 { 32 } else { 64 } + // cs 2: size_modulus = 1 << rhs_modulus + constraint_builder.push( + "bin_shift modulus", + Box::new(move |meta| { + vec![ + rhs_modulus.expr(meta) - constant_from!(64) + + is_i32.expr(meta) * constant_from!(32), + size_modulus.expr(meta) - constant_from_bn!(&(BigUint::from(1u64) << 64usize)) + + is_i32.expr(meta) * constant_from!((u32::MAX as u64) << 32), + ] + }), + ); + + // cs 3: (rhs_round, rhs_rem) = (rhs & 0xffff) div rhs_modulus + // cs 3.helper: rhs_rem < rhs_modulus + constraint_builder.push( + "bin_shift rhs rem", + Box::new(move |meta| { + vec![ + rhs_round.expr(meta) * rhs_modulus.expr(meta) + rhs_rem.expr(meta) + - rhs.u16_cells_le[0].expr(meta), + rhs_rem.expr(meta) + rhs_rem_diff.expr(meta) + constant_from!(1) + - rhs_modulus.expr(meta), + ] + }), + ); + + // cs 4: lookup_pow_modulus = 1 << rhs_rem + constraint_builder.push( + "bin_shift modulus pow lookup", + Box::new(move |meta| { + vec![lookup_pow_power.expr(meta) - pow_table_power_encode(rhs_rem.expr(meta))] + }), + ); + + // cs is_r: + // 1: (round, rem) = lhs div lookup_pow_modulus + // 1.helper: rem < lookup_pow_modulus + constraint_builder.push( + "bin_shift is_r", + Box::new(move |meta| { + vec![ + is_r.expr(meta) + * (rem.u64_cell.expr(meta) + + round.u64_cell.expr(meta) * lookup_pow_modulus.expr(meta) + - lhs.u64_cell.expr(meta)), + is_r.expr(meta) + * (rem.u64_cell.expr(meta) + diff.u64_cell.expr(meta) + constant_from!(1) + - lookup_pow_modulus.expr(meta)), + ] + }), + ); + + // cs is_shr_u: + // 2: res = round + constraint_builder.push( + "bin_shift shr_u", + Box::new(move |meta| { + vec![is_shr_u.expr(meta) * (res.expr(meta) - round.u64_cell.expr(meta))] + }), + ); + + // cs is_shr_s: + // let size = if is_i32 { 32 } else { 64 } + // 1. pad = flag * ((1 << rhs_rem) - 1)) << (size - rhs_rem) + // 2: res = pad + round + constraint_builder.push( + "bin_shift shr_s", + Box::new(move |meta| { + vec![ + degree_helper.expr(meta) + - (lookup_pow_modulus.expr(meta) - constant_from!(1)) + * size_modulus.expr(meta), + is_shr_s.expr(meta) + * (pad.expr(meta) * lookup_pow_modulus.expr(meta) + - lhs.flag_bit_cell.expr(meta) * degree_helper.expr(meta)), + is_shr_s.expr(meta) + * (res.expr(meta) - round.u64_cell.expr(meta) - pad.expr(meta)), + ] + }), + ); + + // cs is_rotr: + // 1: res = round + rem * size_modulus / lookup_pow_modulus + constraint_builder.push( + "bin_shift rotr", + Box::new(move |meta| { + vec![ + is_rotr.expr(meta) + * (res.expr(meta) * lookup_pow_modulus.expr(meta) + - round.u64_cell.expr(meta) * lookup_pow_modulus.expr(meta) + - rem.u64_cell.expr(meta) * size_modulus.expr(meta)), + ] + }), + ); + + // cs is_l: + // 1: (round, rem) = (lhs << rhs_rem) div size_modulus + // 1.helper: rem < size_modulus + constraint_builder.push( + "bin_shift shl", + Box::new(move |meta| { + vec![ + is_l.expr(meta) + * (lhs.u64_cell.expr(meta) * lookup_pow_modulus.expr(meta) + - round.u64_cell.expr(meta) * size_modulus.expr(meta) + - rem.u64_cell.expr(meta)), + is_l.expr(meta) + * (rem.u64_cell.expr(meta) + diff.u64_cell.expr(meta) + constant_from!(1) + - size_modulus.expr(meta)), + ] + }), + ); + + // cs is_shl: + // 1: res = rem + constraint_builder.push( + "bin_shift shl", + Box::new(move |meta| { + vec![is_shl.expr(meta) * (res.expr(meta) - rem.u64_cell.expr(meta))] + }), + ); + + // cs is_rotl: + // 2: res = rem + round + constraint_builder.push( + "bin_shift rotl", + Box::new(move |meta| { + vec![ + is_rotl.expr(meta) + * (res.expr(meta) - rem.u64_cell.expr(meta) - round.u64_cell.expr(meta)), + ] + }), + ); + + Box::new(BinShiftConfig { + lhs, + rhs, + round, + rem, + diff, + pad, + res, + rhs_round, + rhs_rem, + rhs_rem_diff, + is_i32, + is_shl, + is_shr_u, + is_shr_s, + is_rotl, + is_rotr, + is_l, + is_r, + lookup_pow_modulus, + lookup_pow_power, + memory_table_lookup_stack_read_lhs, + memory_table_lookup_stack_read_rhs, + memory_table_lookup_stack_write, + rhs_modulus, + size_modulus, + degree_helper, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let is_i32 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let lhs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_with_flag_bit_cell_dyn", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let rhs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let round := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let rem := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let diff := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let pad := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let rhs_modulus := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let size_modulus := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let rhs_round := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let rhs_rem := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let rhs_rem_diff := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_shl := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_shr_u := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_shr_s := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_rotl := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_rotr := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_l := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_r := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let degree_helper := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let lookup_pow_modulus := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "pow_table_lookup_modulus_cell" + |) + |) in + let lookup_pow_power := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "pow_table_lookup_power_cell" + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let memory_table_lookup_stack_read_rhs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_bin_shift stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_read_lhs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_bin_shift stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 2 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_write := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell_with_value", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_bin_shift stack write" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 2 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let res := + M.copy (| + M.SubPointer.get_struct_record_field (| + memory_table_lookup_stack_write, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "value_cell" + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "bin_shift op select" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_shr_u; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_shr_s; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_rotr; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_r; M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_shl; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_rotl; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_l; M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_l; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_r; + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "bin_shift modulus" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + rhs_modulus; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 64 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_i32; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 32 + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + size_modulus; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "usize" + ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + Value.Integer + 1 + ] + |); + Value.Integer + 64 + ] + |) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_i32; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + M.rust_cast + (M.read (| + M.get_constant (| + "core::num::MAX" + |) + |)), + Value.Integer + 32 + |) + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "bin_shift rhs rem" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + rhs_round; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + rhs_modulus; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + rhs_rem; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + rhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| + Value.Integer 0 + |) + |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + rhs_rem; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + rhs_rem_diff; + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + rhs_modulus; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "bin_shift modulus pow lookup" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + lookup_pow_power; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::rtable::pow_table_power_encode", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + rhs_rem; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "bin_shift is_r" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_r; M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rem, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + round, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + lookup_pow_modulus; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_r; M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rem, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + diff, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + lookup_pow_modulus; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "bin_shift shr_u" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_shr_u; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + round, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "bin_shift shr_s" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + degree_helper; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + lookup_pow_modulus; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + size_modulus; + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_shr_s; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + pad; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + lookup_pow_modulus; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "flag_bit_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + degree_helper; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_shr_s; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + round, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + pad; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "bin_shift rotr" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_rotr; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + lookup_pow_modulus; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + round, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + lookup_pow_modulus; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rem, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + size_modulus; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "bin_shift shl" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_l; M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + lookup_pow_modulus; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + round, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + size_modulus; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rem, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_l; M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rem, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + diff, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + size_modulus; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "bin_shift shl" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_shl; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rem, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "bin_shift rotl" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_rotl; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rem, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + round, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig" + [ + ("lhs", M.read (| lhs |)); + ("rhs", M.read (| rhs |)); + ("round", M.read (| round |)); + ("rem", M.read (| rem |)); + ("diff", M.read (| diff |)); + ("pad", M.read (| pad |)); + ("res", M.read (| res |)); + ("rhs_round", M.read (| rhs_round |)); + ("rhs_rem", M.read (| rhs_rem |)); + ("rhs_rem_diff", M.read (| rhs_rem_diff |)); + ("is_i32", M.read (| is_i32 |)); + ("is_shl", M.read (| is_shl |)); + ("is_shr_u", M.read (| is_shr_u |)); + ("is_shr_s", M.read (| is_shr_s |)); + ("is_rotl", M.read (| is_rotl |)); + ("is_rotr", M.read (| is_rotr |)); + ("is_l", M.read (| is_l |)); + ("is_r", M.read (| is_r |)); + ("lookup_pow_modulus", M.read (| lookup_pow_modulus |)); + ("lookup_pow_power", M.read (| lookup_pow_power |)); + ("memory_table_lookup_stack_read_lhs", + M.read (| memory_table_lookup_stack_read_lhs |)); + ("memory_table_lookup_stack_read_rhs", + M.read (| memory_table_lookup_stack_read_rhs |)); + ("memory_table_lookup_stack_write", + M.read (| memory_table_lookup_stack_write |)); + ("rhs_modulus", M.read (| rhs_modulus |)); + ("size_modulus", M.read (| size_modulus |)); + ("degree_helper", M.read (| degree_helper |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_bin_shift_BinShiftConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_bin_shift_BinShiftConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + constant!(bn_to_field( + &(BigUint::from(OpcodeClass::BinShift as u64) << OPCODE_CLASS_SHIFT) + )) + self.is_shl.expr(meta) + * constant!(bn_to_field( + &(BigUint::from(ShiftOp::Shl as u64) << OPCODE_ARG0_SHIFT) + )) + + self.is_shr_u.expr(meta) + * constant!(bn_to_field( + &(BigUint::from(ShiftOp::UnsignedShr as u64) << OPCODE_ARG0_SHIFT) + )) + + self.is_shr_s.expr(meta) + * constant!(bn_to_field( + &(BigUint::from(ShiftOp::SignedShr as u64) << OPCODE_ARG0_SHIFT) + )) + + self.is_rotl.expr(meta) + * constant!(bn_to_field( + &(BigUint::from(ShiftOp::Rotl as u64) << OPCODE_ARG0_SHIFT) + )) + + self.is_rotr.expr(meta) + * constant!(bn_to_field( + &(BigUint::from(ShiftOp::Rotr as u64) << OPCODE_ARG0_SHIFT) + )) + + self.is_i32.expr(meta) + * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG1_SHIFT))) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 11 + |)) + ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_CLASS_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "is_shl" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 0) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "is_shr_u" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 1) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "is_shr_s" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 2) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "is_rotl" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 3) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "is_rotr" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 4) ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_ARG0_SHIFT" |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "is_i32" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_ARG1_SHIFT" |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + let (class, left, right, value, power, is_eight_bytes, _is_sign) = + match entry.eentry.step_info { + StepInfo::I32BinShiftOp { + class, + left, + right, + value, + } => { + let left = left as u32 as u64; + let right = right as u32 as u64; + let value = value as u32 as u64; + let power = right % 32; + let is_eight_bytes = false; + let is_sign = true; + (class, left, right, value, power, is_eight_bytes, is_sign) + } + + StepInfo::I64BinShiftOp { + class, + left, + right, + value, + } => { + let left = left as u64; + let right = right as u64; + let value = value as u64; + let power = right % 64; + let is_eight_bytes = true; + let is_sign = true; + (class, left, right, value, power, is_eight_bytes, is_sign) + } + + _ => { + unreachable!(); + } + }; + + let size = if is_eight_bytes { 64 } else { 32 }; + let size_mask = if is_eight_bytes { + u64::MAX + } else { + u32::MAX as u64 + }; + + let modulus = 1u64 << power; + let size_modulus = if is_eight_bytes { + BigUint::from(1u64) << 64usize + } else { + BigUint::from(1u64) << 32usize + }; + + self.lhs.assign(ctx, left.into(), !is_eight_bytes)?; + self.rhs.assign(ctx, right)?; + self.rhs_round + .assign(ctx, F::from((right & 0xffff) / size))?; + self.rhs_rem.assign(ctx, F::from(power))?; + self.rhs_rem_diff.assign(ctx, F::from(size - 1 - power))?; + self.lookup_pow_modulus.assign(ctx, modulus.into())?; + self.lookup_pow_power + .assign_bn(ctx, &pow_table_power_encode(BigUint::from(power)))?; + self.is_i32 + .assign(ctx, if is_eight_bytes { F::zero() } else { F::one() })?; + self.res.assign(ctx, F::from(value))?; + self.rhs_modulus + .assign_u32(ctx, if is_eight_bytes { 64 } else { 32 })?; + self.size_modulus.assign_bn(ctx, &size_modulus)?; + self.degree_helper + .assign_bn(ctx, &(size_modulus * (modulus - 1)))?; + + match class { + ShiftOp::Shl => { + self.is_l.assign(ctx, 1.into())?; + self.is_shl.assign(ctx, 1.into())?; + if power != 0 { + self.round.assign(ctx, left >> (size - power))?; + } else { + self.round.assign(ctx, 0)?; + } + let rem = (left << power) & size_mask; + self.rem.assign(ctx, rem)?; + self.diff.assign(ctx, size_mask - rem)?; + } + ShiftOp::UnsignedShr => { + self.is_r.assign(ctx, 1.into())?; + self.is_shr_u.assign(ctx, 1.into())?; + self.round.assign(ctx, left >> power)?; + let rem = left & ((1 << power) - 1); + self.rem.assign(ctx, rem)?; + self.diff.assign(ctx, (1u64 << power) - rem - 1)?; + } + ShiftOp::SignedShr => { + self.is_r.assign(ctx, 1.into())?; + self.is_shr_s.assign(ctx, 1.into())?; + self.round.assign(ctx, left >> power)?; + let rem = left & ((1 << power) - 1); + self.rem.assign(ctx, rem)?; + self.diff.assign(ctx, (1u64 << power) - 1 - rem)?; + + let flag_bit = if is_eight_bytes { + left >> 63 + } else { + left >> 31 + }; + if flag_bit == 1 && power != 0 { + self.pad + .assign(ctx, (((1 << power) - 1) << (size - power)).into())?; + } + } + ShiftOp::Rotl => { + // same as shl + self.is_l.assign(ctx, 1.into())?; + self.is_rotl.assign(ctx, 1.into())?; + if power != 0 { + self.round.assign(ctx, left >> (size - power))?; + } else { + self.round.assign(ctx, 0)?; + } + let rem = (left << power) & size_mask; + self.rem.assign(ctx, rem)?; + self.diff.assign(ctx, size_mask - rem)?; + } + ShiftOp::Rotr => { + // same as shr_u + self.is_r.assign(ctx, 1.into())?; + self.is_rotr.assign(ctx, 1.into())?; + self.round.assign(ctx, left >> power)?; + let rem = left & ((1 << power) - 1); + self.rem.assign(ctx, rem)?; + self.diff.assign(ctx, (1u64 << power) - rem - 1)?; + } + } + + self.memory_table_lookup_stack_read_rhs.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + !is_eight_bytes, + right, + )?; + + self.memory_table_lookup_stack_read_lhs.assign( + ctx, + entry.memory_rw_entires[1].start_eid, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + step.current.sp + 2, + LocationType::Stack, + !is_eight_bytes, + left, + )?; + + self.memory_table_lookup_stack_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[2].end_eid, + step.current.sp + 2, + LocationType::Stack, + !is_eight_bytes, + value, + )?; + + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.match_operator (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinShiftOp", + "class" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinShiftOp", + "left" + |) in + let γ0_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinShiftOp", + "right" + |) in + let γ0_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinShiftOp", + "value" + |) in + let class := M.copy (| γ0_0 |) in + let left := M.copy (| γ0_1 |) in + let right := M.copy (| γ0_2 |) in + let value := M.copy (| γ0_3 |) in + let left := + M.alloc (| M.rust_cast (M.rust_cast (M.read (| left |))) |) in + let right := + M.alloc (| M.rust_cast (M.rust_cast (M.read (| right |))) |) in + let value := + M.alloc (| M.rust_cast (M.rust_cast (M.read (| value |))) |) in + let power := + M.alloc (| + BinOp.Panic.rem (| + Integer.U64, + M.read (| right |), + Value.Integer 32 + |) + |) in + let is_eight_bytes := M.alloc (| Value.Bool false |) in + let is_sign := M.alloc (| Value.Bool true |) in + M.alloc (| + Value.Tuple + [ + M.read (| class |); + M.read (| left |); + M.read (| right |); + M.read (| value |); + M.read (| power |); + M.read (| is_eight_bytes |); + M.read (| is_sign |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinShiftOp", + "class" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinShiftOp", + "left" + |) in + let γ0_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinShiftOp", + "right" + |) in + let γ0_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinShiftOp", + "value" + |) in + let class := M.copy (| γ0_0 |) in + let left := M.copy (| γ0_1 |) in + let right := M.copy (| γ0_2 |) in + let value := M.copy (| γ0_3 |) in + let left := M.alloc (| M.rust_cast (M.read (| left |)) |) in + let right := M.alloc (| M.rust_cast (M.read (| right |)) |) in + let value := M.alloc (| M.rust_cast (M.read (| value |)) |) in + let power := + M.alloc (| + BinOp.Panic.rem (| + Integer.U64, + M.read (| right |), + Value.Integer 64 + |) + |) in + let is_eight_bytes := M.alloc (| Value.Bool true |) in + let is_sign := M.alloc (| Value.Bool true |) in + M.alloc (| + Value.Tuple + [ + M.read (| class |); + M.read (| left |); + M.read (| right |); + M.read (| value |); + M.read (| power |); + M.read (| is_eight_bytes |); + M.read (| is_sign |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_2 := M.SubPointer.get_tuple_field (| γ, 2 |) in + let γ0_3 := M.SubPointer.get_tuple_field (| γ, 3 |) in + let γ0_4 := M.SubPointer.get_tuple_field (| γ, 4 |) in + let γ0_5 := M.SubPointer.get_tuple_field (| γ, 5 |) in + let γ0_6 := M.SubPointer.get_tuple_field (| γ, 6 |) in + let class := M.copy (| γ0_0 |) in + let left := M.copy (| γ0_1 |) in + let right := M.copy (| γ0_2 |) in + let value := M.copy (| γ0_3 |) in + let power := M.copy (| γ0_4 |) in + let is_eight_bytes := M.copy (| γ0_5 |) in + let _is_sign := M.copy (| γ0_6 |) in + let size := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use is_eight_bytes in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| Value.Integer 64 |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Integer 32 |))) + ] + |) + |) in + let size_mask := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use is_eight_bytes in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.get_constant (| "core::num::MAX" |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.rust_cast + (M.read (| M.get_constant (| "core::num::MAX" |) |)) + |))) + ] + |) + |) in + let modulus := + M.alloc (| + BinOp.Panic.shl (| Value.Integer 1, M.read (| power |) |) + |) in + let size_modulus := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use is_eight_bytes in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "usize" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + Value.Integer 64 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "usize" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + Value.Integer 32 + ] + |) + |))) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDyn") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "lhs" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ Ty.path "u64" ], + "into", + [] + |), + [ M.read (| left |) ] + |); + UnOp.Pure.not (M.read (| is_eight_bytes |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "rhs" + |); + M.read (| ctx |); + M.read (| right |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "rhs_round" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + BinOp.Panic.div (| + Integer.U64, + BinOp.Pure.bit_and + (M.read (| right |)) + (Value.Integer 65535), + M.read (| size |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "rhs_rem" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| power |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "rhs_rem_diff" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.sub (| + Integer.U64, + M.read (| size |), + Value.Integer 1 + |), + M.read (| power |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "lookup_pow_modulus" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| modulus |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_bn", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "lookup_pow_power" + |); + M.read (| ctx |); + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::rtable::pow_table_power_encode", + [ Ty.path "num_bigint::biguint::BigUint" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| power |) ] + |) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "is_i32" + |); + M.read (| ctx |); + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use is_eight_bytes in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + |))) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "res" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| value |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "rhs_modulus" + |); + M.read (| ctx |); + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use is_eight_bytes in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| Value.Integer 64 |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Integer 32 |))) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_bn", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "size_modulus" + |); + M.read (| ctx |); + size_modulus + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_bn", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "degree_helper" + |); + M.read (| ctx |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "mul", + [] + |), + [ + M.read (| size_modulus |); + BinOp.Panic.sub (| + Integer.U64, + M.read (| modulus |), + Value.Integer 1 + |) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + class, + [ + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "is_l" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ Value.Integer 1 ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "is_shl" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ Value.Integer 1 ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.read (| power |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "round" + |); + M.read (| ctx |); + BinOp.Panic.shr (| + M.read (| left |), + BinOp.Panic.sub (| + Integer.U64, + M.read (| size |), + M.read (| power |) + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "round" + |); + M.read (| ctx |); + Value.Integer 0 + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + let rem := + M.alloc (| + BinOp.Pure.bit_and + (BinOp.Panic.shl (| + M.read (| left |), + M.read (| power |) + |)) + (M.read (| size_mask |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "rem" + |); + M.read (| ctx |); + M.read (| rem |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "diff" + |); + M.read (| ctx |); + BinOp.Panic.sub (| + Integer.U64, + M.read (| size_mask |), + M.read (| rem |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "is_r" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ Value.Integer 1 ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "is_shr_u" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ Value.Integer 1 ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "round" + |); + M.read (| ctx |); + BinOp.Panic.shr (| + M.read (| left |), + M.read (| power |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let rem := + M.alloc (| + BinOp.Pure.bit_and + (M.read (| left |)) + (BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.shl (| + Value.Integer 1, + M.read (| power |) + |), + Value.Integer 1 + |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "rem" + |); + M.read (| ctx |); + M.read (| rem |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "diff" + |); + M.read (| ctx |); + BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.shl (| + Value.Integer 1, + M.read (| power |) + |), + M.read (| rem |) + |), + Value.Integer 1 + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "is_r" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ Value.Integer 1 ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "is_shr_s" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ Value.Integer 1 ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "round" + |); + M.read (| ctx |); + BinOp.Panic.shr (| + M.read (| left |), + M.read (| power |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let rem := + M.alloc (| + BinOp.Pure.bit_and + (M.read (| left |)) + (BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.shl (| + Value.Integer 1, + M.read (| power |) + |), + Value.Integer 1 + |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "rem" + |); + M.read (| ctx |); + M.read (| rem |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "diff" + |); + M.read (| ctx |); + BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.shl (| + Value.Integer 1, + M.read (| power |) + |), + Value.Integer 1 + |), + M.read (| rem |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let flag_bit := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use is_eight_bytes in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + BinOp.Panic.shr (| + M.read (| left |), + Value.Integer 63 + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + BinOp.Panic.shr (| + M.read (| left |), + Value.Integer 31 + |) + |))) + ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + BinOp.Pure.eq + (M.read (| flag_bit |)) + (Value.Integer 1), + ltac:(M.monadic + (BinOp.Pure.ne + (M.read (| power |)) + (Value.Integer 0))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "pad" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ + BinOp.Panic.shl (| + BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.shl (| + Value.Integer 1, + M.read (| power |) + |), + Value.Integer 1 + |), + BinOp.Panic.sub (| + Integer.U64, + M.read (| size |), + M.read (| power |) + |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "is_l" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ Value.Integer 1 ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "is_rotl" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ Value.Integer 1 ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.read (| power |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "round" + |); + M.read (| ctx |); + BinOp.Panic.shr (| + M.read (| left |), + BinOp.Panic.sub (| + Integer.U64, + M.read (| size |), + M.read (| power |) + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "round" + |); + M.read (| ctx |); + Value.Integer 0 + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + let rem := + M.alloc (| + BinOp.Pure.bit_and + (BinOp.Panic.shl (| + M.read (| left |), + M.read (| power |) + |)) + (M.read (| size_mask |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "rem" + |); + M.read (| ctx |); + M.read (| rem |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "diff" + |); + M.read (| ctx |); + BinOp.Panic.sub (| + Integer.U64, + M.read (| size_mask |), + M.read (| rem |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "is_r" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ Value.Integer 1 ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "is_rotr" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ Value.Integer 1 ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "round" + |); + M.read (| ctx |); + BinOp.Panic.shr (| + M.read (| left |), + M.read (| power |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let rem := + M.alloc (| + BinOp.Pure.bit_and + (M.read (| left |)) + (BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.shl (| + Value.Integer 1, + M.read (| power |) + |), + Value.Integer 1 + |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "rem" + |); + M.read (| ctx |); + M.read (| rem |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "diff" + |); + M.read (| ctx |); + BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.shl (| + Value.Integer 1, + M.read (| power |) + |), + M.read (| rem |) + |), + Value.Integer 1 + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "memory_table_lookup_stack_read_rhs" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + UnOp.Pure.not (M.read (| is_eight_bytes |)); + M.read (| right |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "memory_table_lookup_stack_read_lhs" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 2 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + UnOp.Pure.not (M.read (| is_eight_bytes |)); + M.read (| left |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_bin_shift::BinShiftConfig", + "memory_table_lookup_stack_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 2 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 2 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + UnOp.Pure.not (M.read (| is_eight_bytes |)); + M.read (| value |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn mops(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, _: &EventTableEntry) -> u32 { + 1 + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Integer 1)) ] |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant!(F::one())) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "one", [] |), + [] + |) + ] + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)); + ("sp_diff", InstanceField.Method (sp_diff F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_bin_shift_BinShiftConfig_F. + End op_bin_shift. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_br.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_br.v new file mode 100644 index 000000000..d50aa3b01 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_br.v @@ -0,0 +1,2461 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_br. + (* StructRecord + { + name := "BrConfig"; + ty_params := [ "F" ]; + fields := + [ + ("keep_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_i32_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("drop_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("dst_pc_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("value_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("memory_table_lookup_stack_read", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_write", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "BrConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_br_BrConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_br::BrConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let keep_cell = allocator.alloc_bit_cell(); + let is_i32_cell = allocator.alloc_bit_cell(); + let drop_cell = allocator.alloc_common_range_cell(); + let dst_pc_cell = allocator.alloc_common_range_cell(); + let value_cell = allocator.alloc_u64_cell(); + + let eid = common_config.eid_cell; + let sp = common_config.sp_cell; + + let memory_table_lookup_stack_read = allocator.alloc_memory_table_lookup_read_cell( + "op_br stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |meta| is_i32_cell.expr(meta), + move |meta| value_cell.u64_cell.expr(meta), + move |meta| keep_cell.expr(meta), + ); + let memory_table_lookup_stack_write = allocator.alloc_memory_table_lookup_write_cell( + "op_br stack write", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + drop_cell.expr(meta) + constant_from!(1), + move |meta| is_i32_cell.expr(meta), + move |meta| value_cell.u64_cell.expr(meta), + move |meta| keep_cell.expr(meta), + ); + + Box::new(BrConfig { + keep_cell, + is_i32_cell, + drop_cell, + dst_pc_cell, + value_cell, + memory_table_lookup_stack_read, + memory_table_lookup_stack_write, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let keep_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_i32_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let drop_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let dst_pc_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let value_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let memory_table_lookup_stack_read := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_br stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value_cell, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ keep_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_write := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_br stack write" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ drop_cell; M.read (| meta |) ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value_cell, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ keep_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_br::BrConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_br::BrConfig" + [ + ("keep_cell", M.read (| keep_cell |)); + ("is_i32_cell", M.read (| is_i32_cell |)); + ("drop_cell", M.read (| drop_cell |)); + ("dst_pc_cell", M.read (| dst_pc_cell |)); + ("value_cell", M.read (| value_cell |)); + ("memory_table_lookup_stack_read", + M.read (| memory_table_lookup_stack_read |)); + ("memory_table_lookup_stack_write", + M.read (| memory_table_lookup_stack_write |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_br_BrConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_br_BrConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_br::BrConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + encode_br( + self.drop_cell.expr(meta), + self.keep_cell.expr(meta), + self.dst_pc_cell.expr(meta), + ) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_function (| + "specs::encode::opcode::encode_br", + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br::BrConfig", + "drop_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br::BrConfig", + "keep_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br::BrConfig", + "dst_pc_cell" + |); + M.read (| meta |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::Br { + drop, + keep, + keep_values, + dst_pc, + .. + } => { + assert!(keep.len() <= 1); + + self.drop_cell.assign(ctx, F::from( *drop as u64))?; + + if keep.len() > 0 { + let keep_type: VarType = keep[0].into(); + + self.keep_cell.assign(ctx, F::one())?; + self.value_cell.assign(ctx, keep_values[0])?; + self.is_i32_cell.assign(ctx, F::from(keep_type as u64))?; + + self.memory_table_lookup_stack_read.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + VarType::from(keep[0]) == VarType::I32, + keep_values[0], + )?; + + self.memory_table_lookup_stack_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + step.current.sp + *drop + 1, + LocationType::Stack, + VarType::from(keep[0]) == VarType::I32, + keep_values[0], + )?; + } + + self.dst_pc_cell.assign(ctx, F::from(( *dst_pc) as u64))?; + } + _ => unreachable!(), + } + + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Br", + "drop" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Br", + "keep" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Br", + "keep_values" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Br", + "dst_pc" + |) in + let drop := M.alloc (| γ1_0 |) in + let keep := M.alloc (| γ1_1 |) in + let keep_values := M.alloc (| γ1_2 |) in + let dst_pc := M.alloc (| γ1_3 |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.le + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + (Value.Integer 1)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "assertion failed: keep.len() <= 1" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br::BrConfig", + "drop_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| drop |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let keep_type := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ M.read (| keep |); Value.Integer 0 ] + |) + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br::BrConfig", + "keep_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br::BrConfig", + "value_cell" + |); + M.read (| ctx |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + Value.Integer 0 + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br::BrConfig", + "is_i32_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| keep_type |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br::BrConfig", + "memory_table_lookup_stack_read" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "specs::mtable::VarType", + [ + Ty.path + "specs::types::ValueType" + ], + "from", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + Value.Integer 0 + ] + |) + |) + ] + |) + |); + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + Value.Integer 0 + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br::BrConfig", + "memory_table_lookup_stack_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + M.read (| M.read (| drop |) |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "specs::mtable::VarType", + [ + Ty.path + "specs::types::ValueType" + ], + "from", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + Value.Integer 0 + ] + |) + |) + ] + |) + |); + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + Value.Integer 0 + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br::BrConfig", + "dst_pc_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| dst_pc |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, meta: &mut VirtualCells<'_, F>) -> Option> { + Some(self.drop_cell.expr(meta)) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br::BrConfig", + "drop_cell" + |); + M.read (| meta |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn mops(&self, meta: &mut VirtualCells<'_, F>) -> Option> { + Some(self.keep_cell.expr(meta)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br::BrConfig", + "keep_cell" + |); + M.read (| meta |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, entry: &EventTableEntry) -> u32 { + match &entry.step_info { + StepInfo::Br { keep, .. } => keep.len() as u32, + _ => unreachable!(), + } + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let entry := M.alloc (| entry |) in + M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Br", + "keep" + |) in + let keep := M.alloc (| γ1_0 |) in + M.alloc (| + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + fn next_iid( + &self, + meta: &mut VirtualCells<'_, F>, + _: &EventTableCommonConfig, + ) -> Option> { + Some(self.dst_pc_cell.expr(meta)) + } + *) + Definition next_iid (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta; β2 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let β2 := M.alloc (| β2 |) in + M.match_operator (| + β2, + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br::BrConfig", + "dst_pc_cell" + |); + M.read (| meta |) + ] + |) + ])) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("sp_diff", InstanceField.Method (sp_diff F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)); + ("next_iid", InstanceField.Method (next_iid F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_br_BrConfig_F. + End op_br. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_br_if.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_br_if.v new file mode 100644 index 000000000..dea30ba74 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_br_if.v @@ -0,0 +1,4573 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_br_if. + (* StructRecord + { + name := "BrIfConfig"; + ty_params := [ "F" ]; + fields := + [ + ("cond_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("cond_inv_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("cond_is_zero_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("cond_is_not_zero_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("keep_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_i32_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("drop_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("dst_pc_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("value_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("memory_table_lookup_stack_read_cond", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_read_return_value", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_write_return_value", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "BrIfConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_br_if_BrIfConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let cond_cell = allocator.alloc_u64_cell(); + let cond_inv_cell = allocator.alloc_unlimited_cell(); + let cond_is_zero_cell = allocator.alloc_bit_cell(); + let cond_is_not_zero_cell = allocator.alloc_bit_cell(); + + constraint_builder.constraints.push(( + "op_br_if cond bit", + Box::new(move |meta| { + vec![ + cond_is_zero_cell.expr(meta) * cond_cell.u64_cell.expr(meta), + cond_is_zero_cell.expr(meta) + + cond_cell.u64_cell.expr(meta) * cond_inv_cell.expr(meta) + - constant_from!(1), + cond_is_zero_cell.expr(meta) + cond_is_not_zero_cell.expr(meta) + - constant_from!(1), + ] + }), + )); + + let keep_cell = allocator.alloc_bit_cell(); + let is_i32_cell = allocator.alloc_bit_cell(); + let drop_cell = allocator.alloc_common_range_cell(); + let dst_pc_cell = allocator.alloc_common_range_cell(); + let value_cell = allocator.alloc_u64_cell(); + + let eid = common_config.eid_cell; + let sp = common_config.sp_cell; + + let memory_table_lookup_stack_read_cond = allocator.alloc_memory_table_lookup_read_cell( + "op_br_if stack read cond", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |____| constant_from!(1), + move |meta| cond_cell.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + let memory_table_lookup_stack_read_return_value = allocator + .alloc_memory_table_lookup_read_cell( + "op_br_if stack read return value", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(2), + move |meta| is_i32_cell.expr(meta), + move |meta| value_cell.u64_cell.expr(meta), + move |meta| keep_cell.expr(meta) * cond_is_not_zero_cell.expr(meta), + ); + let memory_table_lookup_stack_write_return_value = allocator + .alloc_memory_table_lookup_write_cell( + "op_br_if stack write return value", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + drop_cell.expr(meta) + constant_from!(2), + move |meta| is_i32_cell.expr(meta), + move |meta| value_cell.u64_cell.expr(meta), + move |meta| keep_cell.expr(meta) * cond_is_not_zero_cell.expr(meta), + ); + + Box::new(BrIfConfig { + cond_cell, + cond_inv_cell, + cond_is_zero_cell, + cond_is_not_zero_cell, + keep_cell, + is_i32_cell, + drop_cell, + dst_pc_cell, + value_cell, + memory_table_lookup_stack_read_cond, + memory_table_lookup_stack_read_return_value, + memory_table_lookup_stack_write_return_value, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let cond_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let cond_inv_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let cond_is_zero_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let cond_is_not_zero_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| constraint_builder |), + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder", + "constraints" + |); + Value.Tuple + [ + M.read (| Value.String "op_br_if cond bit" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + cond_is_zero_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cond_cell, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + cond_is_zero_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cond_cell, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + cond_inv_cell; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + cond_is_zero_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + cond_is_not_zero_cell; + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + ] + |) + |) in + let keep_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_i32_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let drop_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let dst_pc_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let value_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let memory_table_lookup_stack_read_cond := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_br_if stack read cond" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cond_cell, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_read_return_value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_br_if stack read return value" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 2 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value_cell, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ keep_cell; M.read (| meta |) ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ cond_is_not_zero_cell; M.read (| meta |) ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_write_return_value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_br_if stack write return value" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ drop_cell; M.read (| meta |) ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 2 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value_cell, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ keep_cell; M.read (| meta |) ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ cond_is_not_zero_cell; M.read (| meta |) ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig" + [ + ("cond_cell", M.read (| cond_cell |)); + ("cond_inv_cell", M.read (| cond_inv_cell |)); + ("cond_is_zero_cell", M.read (| cond_is_zero_cell |)); + ("cond_is_not_zero_cell", M.read (| cond_is_not_zero_cell |)); + ("keep_cell", M.read (| keep_cell |)); + ("is_i32_cell", M.read (| is_i32_cell |)); + ("drop_cell", M.read (| drop_cell |)); + ("dst_pc_cell", M.read (| dst_pc_cell |)); + ("value_cell", M.read (| value_cell |)); + ("memory_table_lookup_stack_read_cond", + M.read (| memory_table_lookup_stack_read_cond |)); + ("memory_table_lookup_stack_read_return_value", + M.read (| memory_table_lookup_stack_read_return_value |)); + ("memory_table_lookup_stack_write_return_value", + M.read (| memory_table_lookup_stack_write_return_value |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_br_if_BrIfConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_br_if_BrIfConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + constant!(bn_to_field( + &(BigUint::from(OpcodeClass::BrIf as u64) << OPCODE_CLASS_SHIFT) + )) + self.drop_cell.expr(meta) + * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG0_SHIFT))) + + self.keep_cell.expr(meta) + * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG1_SHIFT))) + + self.dst_pc_cell.expr(meta) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 16 + |)) + ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_CLASS_SHIFT" |) + |) + ] + |) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "drop_cell" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "keep_cell" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_ARG1_SHIFT" |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "dst_pc_cell" + |); + M.read (| meta |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::BrIfNez { + condition, + dst_pc, + drop, + keep, + keep_values, + } => { + assert!(keep.len() <= 1); + + let cond = *condition as u32 as u64; + + self.memory_table_lookup_stack_read_cond.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + true, + cond, + )?; + + self.drop_cell.assign(ctx, F::from( *drop as u64))?; + + if keep.len() > 0 { + let keep_type: VarType = keep[0].into(); + + self.keep_cell.assign(ctx, F::one())?; + self.value_cell.assign(ctx, keep_values[0])?; + self.is_i32_cell.assign(ctx, F::from(keep_type as u64))?; + if *condition != 0 { + self.memory_table_lookup_stack_read_return_value.assign( + ctx, + entry.memory_rw_entires[1].start_eid, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + step.current.sp + 2, + LocationType::Stack, + VarType::from(keep[0]) == VarType::I32, + keep_values[0], + )?; + + self.memory_table_lookup_stack_write_return_value.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[2].end_eid, + step.current.sp + *drop + 2, + LocationType::Stack, + VarType::from(keep[0]) == VarType::I32, + keep_values[0], + )?; + } + } + + self.cond_cell.assign(ctx, cond)?; + self.cond_inv_cell + .assign(ctx, F::from(cond).invert().unwrap_or(F::zero()))?; + self.cond_is_zero_cell + .assign(ctx, if cond == 0 { F::one() } else { F::zero() })?; + self.cond_is_not_zero_cell + .assign(ctx, if cond == 0 { F::zero() } else { F::one() })?; + self.dst_pc_cell.assign(ctx, F::from(( *dst_pc) as u64))?; + } + _ => unreachable!(), + } + + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfNez", + "condition" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfNez", + "dst_pc" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfNez", + "drop" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfNez", + "keep" + |) in + let γ1_4 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfNez", + "keep_values" + |) in + let condition := M.alloc (| γ1_0 |) in + let dst_pc := M.alloc (| γ1_1 |) in + let drop := M.alloc (| γ1_2 |) in + let keep := M.alloc (| γ1_3 |) in + let keep_values := M.alloc (| γ1_4 |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.le + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + (Value.Integer 1)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "assertion failed: keep.len() <= 1" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let cond := + M.alloc (| + M.rust_cast (M.rust_cast (M.read (| M.read (| condition |) |))) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "memory_table_lookup_stack_read_cond" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool true; + M.read (| cond |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "drop_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| drop |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let keep_type := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ M.read (| keep |); Value.Integer 0 ] + |) + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "keep_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "value_cell" + |); + M.read (| ctx |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + Value.Integer 0 + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "is_i32_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| keep_type |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.read (| M.read (| condition |) |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "memory_table_lookup_stack_read_return_value" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 2 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "specs::mtable::VarType", + [ + Ty.path + "specs::mtable::VarType" + ], + "eq", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "specs::mtable::VarType", + [ + Ty.path + "specs::types::ValueType" + ], + "from", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + Value.Integer 0 + ] + |) + |) + ] + |) + |); + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + Value.Integer 0 + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "memory_table_lookup_stack_write_return_value" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 2 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + M.read (| M.read (| drop |) |) + |), + Value.Integer 2 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "specs::mtable::VarType", + [ + Ty.path + "specs::mtable::VarType" + ], + "eq", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "specs::mtable::VarType", + [ + Ty.path + "specs::types::ValueType" + ], + "from", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + Value.Integer 0 + ] + |) + |) + ] + |) + |); + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + Value.Integer 0 + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "cond_cell" + |); + M.read (| ctx |); + M.read (| cond |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "cond_inv_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "subtle::CtOption") [ F ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "invert", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| cond |) ] + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "cond_is_zero_cell" + |); + M.read (| ctx |); + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| cond |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + |))) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "cond_is_not_zero_cell" + |); + M.read (| ctx |); + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| cond |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + |))) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "dst_pc_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| dst_pc |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1) + self.cond_is_not_zero_cell.expr(meta) * self.drop_cell.expr(meta)) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "cond_is_not_zero_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "drop_cell" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn mops(&self, meta: &mut VirtualCells<'_, F>) -> Option> { + Some(self.cond_is_not_zero_cell.expr(meta) * self.keep_cell.expr(meta)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "cond_is_not_zero_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "keep_cell" + |); + M.read (| meta |) + ] + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, entry: &EventTableEntry) -> u32 { + match &entry.step_info { + StepInfo::BrIfNez { + keep, condition, .. + } => { + if *condition == 0 { + 0 + } else { + keep.len() as u32 + } + } + _ => unreachable!(), + } + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let entry := M.alloc (| entry |) in + M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfNez", + "keep" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfNez", + "condition" + |) in + let keep := M.alloc (| γ1_0 |) in + let condition := M.alloc (| γ1_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| M.read (| condition |) |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| Value.Integer 0 |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + fn next_iid( + &self, + meta: &mut VirtualCells<'_, F>, + common_config: &EventTableCommonConfig, + ) -> Option> { + Some( + self.cond_is_not_zero_cell.expr(meta) * self.dst_pc_cell.expr(meta) + + self.cond_is_zero_cell.expr(meta) + * (common_config.iid_cell.curr_expr(meta) + constant_from!(1)), + ) + } + *) + Definition next_iid (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta; common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let common_config := M.alloc (| common_config |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "cond_is_not_zero_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "dst_pc_cell" + |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if::BrIfConfig", + "cond_is_zero_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "iid_cell" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ] + |) + ] + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("sp_diff", InstanceField.Method (sp_diff F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)); + ("next_iid", InstanceField.Method (next_iid F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_br_if_BrIfConfig_F. + End op_br_if. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_br_if_eqz.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_br_if_eqz.v new file mode 100644 index 000000000..3f1876557 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_br_if_eqz.v @@ -0,0 +1,4230 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_br_if_eqz. + (* StructRecord + { + name := "BrIfEqzConfig"; + ty_params := [ "F" ]; + fields := + [ + ("cond_inv_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("cond_is_zero_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("cond_is_not_zero_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("keep_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_i32_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("drop_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("dst_pc_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("memory_table_lookup_stack_read_cond", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_read_return_value", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_write_return_value", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "BrIfEqzConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_br_if_eqz_BrIfEqzConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let cond_inv_cell = allocator.alloc_unlimited_cell(); + let cond_is_zero_cell = allocator.alloc_bit_cell(); + let cond_is_not_zero_cell = allocator.alloc_bit_cell(); + + let keep_cell = allocator.alloc_bit_cell(); + let is_i32_cell = allocator.alloc_bit_cell(); + let drop_cell = allocator.alloc_common_range_cell(); + let dst_pc_cell = allocator.alloc_common_range_cell(); + + let eid = common_config.eid_cell; + let sp = common_config.sp_cell; + + let memory_table_lookup_stack_read_cond = allocator + .alloc_memory_table_lookup_read_cell_with_value( + "op_br_if stack read cond", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |____| constant_from!(1), + move |____| constant_from!(1), + ); + let cond_cell = memory_table_lookup_stack_read_cond.value_cell; + + let memory_table_lookup_stack_read_return_value = allocator + .alloc_memory_table_lookup_read_cell_with_value( + "op_br_if_eqz stack read return value", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(2), + move |meta| is_i32_cell.expr(meta), + move |meta| keep_cell.expr(meta) * cond_is_zero_cell.expr(meta), + ); + let value_cell = memory_table_lookup_stack_read_return_value.value_cell; + + let memory_table_lookup_stack_write_return_value = allocator + .alloc_memory_table_lookup_write_cell( + "op_br_if_eqz stack write return value", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + drop_cell.expr(meta) + constant_from!(2), + move |meta| is_i32_cell.expr(meta), + move |meta| value_cell.expr(meta), + move |meta| keep_cell.expr(meta) * cond_is_zero_cell.expr(meta), + ); + + constraint_builder.constraints.push(( + "op_br_if cond bit", + Box::new(move |meta| { + vec![ + cond_is_zero_cell.expr(meta) * cond_cell.expr(meta), + cond_is_zero_cell.expr(meta) + cond_cell.expr(meta) * cond_inv_cell.expr(meta) + - constant_from!(1), + cond_is_zero_cell.expr(meta) + cond_is_not_zero_cell.expr(meta) + - constant_from!(1), + ] + }), + )); + + Box::new(BrIfEqzConfig { + cond_inv_cell, + cond_is_zero_cell, + cond_is_not_zero_cell, + keep_cell, + is_i32_cell, + drop_cell, + dst_pc_cell, + memory_table_lookup_stack_read_cond, + memory_table_lookup_stack_read_return_value, + memory_table_lookup_stack_write_return_value, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let cond_inv_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let cond_is_zero_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let cond_is_not_zero_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let keep_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_i32_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let drop_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let dst_pc_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let memory_table_lookup_stack_read_cond := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell_with_value", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_br_if stack read cond" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let cond_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + memory_table_lookup_stack_read_cond, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "value_cell" + |) + |) in + let memory_table_lookup_stack_read_return_value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell_with_value", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_br_if_eqz stack read return value" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 2 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ keep_cell; M.read (| meta |) ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ cond_is_zero_cell; M.read (| meta |) ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let value_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + memory_table_lookup_stack_read_return_value, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "value_cell" + |) + |) in + let memory_table_lookup_stack_write_return_value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_br_if_eqz stack write return value" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ drop_cell; M.read (| meta |) ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 2 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ value_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ keep_cell; M.read (| meta |) ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ cond_is_zero_cell; M.read (| meta |) ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| constraint_builder |), + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder", + "constraints" + |); + Value.Tuple + [ + M.read (| Value.String "op_br_if cond bit" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + cond_is_zero_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + cond_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + cond_is_zero_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + cond_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + cond_inv_cell; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + cond_is_zero_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + cond_is_not_zero_cell; + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig" + [ + ("cond_inv_cell", M.read (| cond_inv_cell |)); + ("cond_is_zero_cell", M.read (| cond_is_zero_cell |)); + ("cond_is_not_zero_cell", M.read (| cond_is_not_zero_cell |)); + ("keep_cell", M.read (| keep_cell |)); + ("is_i32_cell", M.read (| is_i32_cell |)); + ("drop_cell", M.read (| drop_cell |)); + ("dst_pc_cell", M.read (| dst_pc_cell |)); + ("memory_table_lookup_stack_read_cond", + M.read (| memory_table_lookup_stack_read_cond |)); + ("memory_table_lookup_stack_read_return_value", + M.read (| memory_table_lookup_stack_read_return_value |)); + ("memory_table_lookup_stack_write_return_value", + M.read (| memory_table_lookup_stack_write_return_value |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_br_if_eqz_BrIfEqzConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_br_if_eqz_BrIfEqzConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + constant!(bn_to_field( + &(BigUint::from(OpcodeClass::BrIfEqz as u64) << OPCODE_CLASS_SHIFT) + )) + self.drop_cell.expr(meta) + * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG0_SHIFT))) + + self.keep_cell.expr(meta) + * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG1_SHIFT))) + + self.dst_pc_cell.expr(meta) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 17 + |)) + ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_CLASS_SHIFT" |) + |) + ] + |) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig", + "drop_cell" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig", + "keep_cell" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_ARG1_SHIFT" |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig", + "dst_pc_cell" + |); + M.read (| meta |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::BrIfEqz { + condition, + dst_pc, + drop, + keep, + keep_values, + } => { + assert!(keep.len() <= 1); + + let cond = *condition as u32 as u64; + + self.memory_table_lookup_stack_read_cond.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + true, + cond, + )?; + + self.drop_cell.assign(ctx, F::from( *drop as u64))?; + + if keep.len() > 0 { + let keep_type: VarType = keep[0].into(); + + self.keep_cell.assign(ctx, F::one())?; + self.is_i32_cell.assign(ctx, F::from(keep_type as u64))?; + if *condition == 0 { + self.memory_table_lookup_stack_read_return_value.assign( + ctx, + entry.memory_rw_entires[1].start_eid, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + step.current.sp + 2, + LocationType::Stack, + VarType::from(keep[0]) == VarType::I32, + keep_values[0], + )?; + + self.memory_table_lookup_stack_write_return_value.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[2].end_eid, + step.current.sp + *drop + 2, + LocationType::Stack, + VarType::from(keep[0]) == VarType::I32, + keep_values[0], + )?; + } + } + + self.cond_inv_cell + .assign(ctx, F::from(cond).invert().unwrap_or(F::zero()))?; + self.cond_is_zero_cell + .assign(ctx, if cond == 0 { F::one() } else { F::zero() })?; + self.cond_is_not_zero_cell + .assign(ctx, if cond == 0 { F::zero() } else { F::one() })?; + self.dst_pc_cell.assign(ctx, F::from(( *dst_pc) as u64))?; + } + _ => unreachable!(), + } + + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfEqz", + "condition" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfEqz", + "dst_pc" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfEqz", + "drop" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfEqz", + "keep" + |) in + let γ1_4 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfEqz", + "keep_values" + |) in + let condition := M.alloc (| γ1_0 |) in + let dst_pc := M.alloc (| γ1_1 |) in + let drop := M.alloc (| γ1_2 |) in + let keep := M.alloc (| γ1_3 |) in + let keep_values := M.alloc (| γ1_4 |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.le + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + (Value.Integer 1)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "assertion failed: keep.len() <= 1" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let cond := + M.alloc (| + M.rust_cast (M.rust_cast (M.read (| M.read (| condition |) |))) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig", + "memory_table_lookup_stack_read_cond" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool true; + M.read (| cond |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig", + "drop_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| drop |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let keep_type := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ M.read (| keep |); Value.Integer 0 ] + |) + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig", + "keep_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig", + "is_i32_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| keep_type |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| M.read (| condition |) |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig", + "memory_table_lookup_stack_read_return_value" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 2 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "specs::mtable::VarType", + [ + Ty.path + "specs::mtable::VarType" + ], + "eq", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "specs::mtable::VarType", + [ + Ty.path + "specs::types::ValueType" + ], + "from", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + Value.Integer 0 + ] + |) + |) + ] + |) + |); + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + Value.Integer 0 + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig", + "memory_table_lookup_stack_write_return_value" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 2 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + M.read (| M.read (| drop |) |) + |), + Value.Integer 2 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "specs::mtable::VarType", + [ + Ty.path + "specs::mtable::VarType" + ], + "eq", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "specs::mtable::VarType", + [ + Ty.path + "specs::types::ValueType" + ], + "from", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + Value.Integer 0 + ] + |) + |) + ] + |) + |); + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + Value.Integer 0 + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig", + "cond_inv_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "subtle::CtOption") [ F ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "invert", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| cond |) ] + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig", + "cond_is_zero_cell" + |); + M.read (| ctx |); + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| cond |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + |))) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig", + "cond_is_not_zero_cell" + |); + M.read (| ctx |); + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| cond |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + |))) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig", + "dst_pc_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| dst_pc |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1) + self.cond_is_zero_cell.expr(meta) * self.drop_cell.expr(meta)) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig", + "cond_is_zero_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig", + "drop_cell" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn mops(&self, meta: &mut VirtualCells<'_, F>) -> Option> { + Some(self.cond_is_zero_cell.expr(meta) * self.keep_cell.expr(meta)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig", + "cond_is_zero_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig", + "keep_cell" + |); + M.read (| meta |) + ] + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, entry: &EventTableEntry) -> u32 { + match &entry.step_info { + StepInfo::BrIfEqz { + keep, condition, .. + } => { + if *condition != 0 { + 0 + } else { + keep.len() as u32 + } + } + _ => unreachable!(), + } + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let entry := M.alloc (| entry |) in + M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfEqz", + "keep" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfEqz", + "condition" + |) in + let keep := M.alloc (| γ1_0 |) in + let condition := M.alloc (| γ1_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.read (| M.read (| condition |) |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| Value.Integer 0 |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + fn next_iid( + &self, + meta: &mut VirtualCells<'_, F>, + common_config: &EventTableCommonConfig, + ) -> Option> { + Some( + self.cond_is_zero_cell.expr(meta) * self.dst_pc_cell.expr(meta) + + self.cond_is_not_zero_cell.expr(meta) + * (common_config.iid_cell.curr_expr(meta) + constant_from!(1)), + ) + } + *) + Definition next_iid (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta; common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let common_config := M.alloc (| common_config |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig", + "cond_is_zero_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig", + "dst_pc_cell" + |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_if_eqz::BrIfEqzConfig", + "cond_is_not_zero_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "iid_cell" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ] + |) + ] + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("sp_diff", InstanceField.Method (sp_diff F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)); + ("next_iid", InstanceField.Method (next_iid F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_br_if_eqz_BrIfEqzConfig_F. + End op_br_if_eqz. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_br_table.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_br_table.v new file mode 100644 index 000000000..d05c5c512 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_br_table.v @@ -0,0 +1,5277 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_br_table. + (* StructRecord + { + name := "BrTableConfig"; + ty_params := [ "F" ]; + fields := + [ + ("keep", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("keep_is_i32", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("keep_value", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("drop", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("dst_iid", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("expected_index", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("effective_index", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("targets_len", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("is_out_of_bound", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_not_out_of_bound", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("diff", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("br_table_lookup", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("memory_table_lookup_stack_read_index", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_read_return_value", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_write_return_value", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "BrTableConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_br_table_BrTableConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let keep = allocator.alloc_bit_cell(); + let keep_is_i32 = allocator.alloc_bit_cell(); + let keep_value = allocator.alloc_u64_cell(); + let drop = allocator.alloc_common_range_cell(); + let dst_iid = allocator.alloc_common_range_cell(); + let expected_index = allocator.alloc_u64_cell(); + let effective_index = allocator.alloc_common_range_cell(); + let targets_len = allocator.alloc_common_range_cell(); + let is_out_of_bound = allocator.alloc_bit_cell(); + let is_not_out_of_bound = allocator.alloc_bit_cell(); + let diff = allocator.alloc_u64_cell(); + + constraint_builder.push( + "op_br_table oob", + Box::new(move |meta| { + vec![ + /* is_out_of_bound \/ is_not_out_of_bound */ + is_not_out_of_bound.expr(meta) + is_out_of_bound.expr(meta) - constant_from!(1), + /* is_out_of_bound -> expected >= targets_len */ + is_out_of_bound.expr(meta) + * (targets_len.expr(meta) + diff.expr(meta) - expected_index.expr(meta)), + /* !is_out_of_bound -> expected_index < targets_len */ + is_not_out_of_bound.expr(meta) + * (expected_index.expr(meta) + diff.expr(meta) + constant_from!(1) + - targets_len.expr(meta)), + ] + }), + ); + + constraint_builder.push( + "op_br_table effective_index", + Box::new(move |meta| { + vec![ + is_out_of_bound.expr(meta) + * (targets_len.expr(meta) - constant_from!(1) - effective_index.expr(meta)), + is_not_out_of_bound.expr(meta) + * (expected_index.expr(meta) - effective_index.expr(meta)), + ] + }), + ); + + let br_table_lookup = common_config.brtable_lookup_cell; + let fid = common_config.fid_cell; + let iid = common_config.iid_cell; + + constraint_builder.push( + "op_br_table br_table_lookup", + Box::new(move |meta| { + vec![ + br_table_lookup.expr(meta) + - encode_br_table_entry( + fid.expr(meta), + iid.expr(meta), + effective_index.expr(meta), + drop.expr(meta), + keep.expr(meta), + dst_iid.expr(meta), + ), + ] + }), + ); + + let eid = common_config.eid_cell; + let sp = common_config.sp_cell; + + let memory_table_lookup_stack_read_index = allocator.alloc_memory_table_lookup_read_cell( + "op_br_table stack read index", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |____| constant_from!(1), + move |meta| expected_index.expr(meta), + move |____| constant_from!(1), + ); + + let memory_table_lookup_stack_read_return_value = allocator + .alloc_memory_table_lookup_read_cell( + "op_br_table stack read index", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(2), + move |meta| keep_is_i32.expr(meta), + move |meta| keep_value.expr(meta), + move |meta| keep.expr(meta), + ); + + let memory_table_lookup_stack_write_return_value = allocator + .alloc_memory_table_lookup_write_cell( + "op_br stack write", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + drop.expr(meta) + constant_from!(2), + move |meta| keep_is_i32.expr(meta), + move |meta| keep_value.expr(meta), + move |meta| keep.expr(meta), + ); + + Box::new(BrTableConfig { + keep, + keep_is_i32, + keep_value, + drop, + dst_iid, + expected_index, + effective_index, + targets_len, + is_out_of_bound, + is_not_out_of_bound, + diff, + br_table_lookup, + memory_table_lookup_stack_read_index, + memory_table_lookup_stack_read_return_value, + memory_table_lookup_stack_write_return_value, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let keep := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let keep_is_i32 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let keep_value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let drop := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let dst_iid := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let expected_index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let effective_index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let targets_len := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_out_of_bound := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_not_out_of_bound := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let diff := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_br_table oob" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_not_out_of_bound; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_out_of_bound; + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_out_of_bound; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + targets_len; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + diff; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + expected_index; + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_not_out_of_bound; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + expected_index; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + diff; + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + targets_len; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_br_table effective_index" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_out_of_bound; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + targets_len; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + effective_index; + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_not_out_of_bound; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + expected_index; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + effective_index; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let br_table_lookup := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "brtable_lookup_cell" + |) + |) in + let fid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "fid_cell" + |) + |) in + let iid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "iid_cell" + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_br_table br_table_lookup" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + br_table_lookup; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_function (| + "specs::encode::br_table::encode_br_table_entry", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + fid; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + iid; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + effective_index; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + drop; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + keep; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + dst_iid; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let memory_table_lookup_stack_read_index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_br_table stack read index" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ expected_index; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_read_return_value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_br_table stack read index" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 2 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ keep_is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ keep_value; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ keep; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_write_return_value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_br stack write" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ drop; M.read (| meta |) ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 2 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ keep_is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ keep_value; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ keep; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig" + [ + ("keep", M.read (| keep |)); + ("keep_is_i32", M.read (| keep_is_i32 |)); + ("keep_value", M.read (| keep_value |)); + ("drop", M.read (| drop |)); + ("dst_iid", M.read (| dst_iid |)); + ("expected_index", M.read (| expected_index |)); + ("effective_index", M.read (| effective_index |)); + ("targets_len", M.read (| targets_len |)); + ("is_out_of_bound", M.read (| is_out_of_bound |)); + ("is_not_out_of_bound", M.read (| is_not_out_of_bound |)); + ("diff", M.read (| diff |)); + ("br_table_lookup", M.read (| br_table_lookup |)); + ("memory_table_lookup_stack_read_index", + M.read (| memory_table_lookup_stack_read_index |)); + ("memory_table_lookup_stack_read_return_value", + M.read (| memory_table_lookup_stack_read_return_value |)); + ("memory_table_lookup_stack_write_return_value", + M.read (| memory_table_lookup_stack_write_return_value |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_br_table_BrTableConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_br_table_BrTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + encode_br_table(self.targets_len.expr(meta)) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_function (| + "specs::encode::opcode::encode_br_table", + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig", + "targets_len" + |); + M.read (| meta |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::BrTable { + index, + dst_pc, + drop, + keep, + keep_values, + } => { + assert!(keep.len() <= 1); + + let index = *index as u32 as u64; + let targets = match &entry.eentry.get_instruction(step.current.itable).opcode { + specs::itable::Opcode::BrTable { targets } => targets.clone(), + _ => unreachable!(), + }; + let targets_len = targets.len() as u64; + + self.drop.assign(ctx, F::from( *drop as u64))?; + self.dst_iid.assign(ctx, F::from( *dst_pc as u64))?; + + self.memory_table_lookup_stack_read_index.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + true, + index, + )?; + + if keep.len() > 0 { + let keep_type: VarType = keep[0].into(); + + self.keep.assign(ctx, F::one())?; + self.keep_value.assign(ctx, keep_values[0])?; + self.keep_is_i32 + .assign_bool(ctx, keep_type == VarType::I32)?; + + self.memory_table_lookup_stack_read_return_value.assign( + ctx, + entry.memory_rw_entires[1].start_eid, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + step.current.sp + 2, + LocationType::Stack, + VarType::from(keep[0]) == VarType::I32, + keep_values[0], + )?; + + self.memory_table_lookup_stack_write_return_value.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[2].end_eid, + step.current.sp + drop + 2, + LocationType::Stack, + VarType::from(keep[0]) == VarType::I32, + keep_values[0], + )?; + } + + self.targets_len.assign(ctx, F::from(targets_len))?; + + let effective_index = if index < targets_len { + index + } else { + targets_len - 1 + }; + self.expected_index.assign(ctx, index)?; + self.effective_index.assign(ctx, F::from(effective_index))?; + self.is_out_of_bound + .assign_bool(ctx, index != effective_index)?; + self.is_not_out_of_bound + .assign_bool(ctx, index == effective_index)?; + self.diff.assign( + ctx, + if index < targets_len { + targets_len - index - 1 + } else { + index - targets_len + } + .into(), + )?; + + self.br_table_lookup.assign_bn( + ctx, + &encode_br_table_entry( + BigUint::from(step.current.fid), + BigUint::from(step.current.iid), + BigUint::from(effective_index), + BigUint::from( *drop), + BigUint::from(keep.len()), + BigUint::from( *dst_pc), + ), + )?; + } + _ => unreachable!(), + } + + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrTable", + "index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrTable", + "dst_pc" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrTable", + "drop" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrTable", + "keep" + |) in + let γ1_4 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrTable", + "keep_values" + |) in + let index := M.alloc (| γ1_0 |) in + let dst_pc := M.alloc (| γ1_1 |) in + let drop := M.alloc (| γ1_2 |) in + let keep := M.alloc (| γ1_3 |) in + let keep_values := M.alloc (| γ1_4 |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.le + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + (Value.Integer 1)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "assertion failed: keep.len() <= 1" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let index := + M.alloc (| + M.rust_cast (M.rust_cast (M.read (| M.read (| index |) |))) + |) in + let targets := + M.copy (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::etable::EventTableEntry", + "get_instruction", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "itable" + |) + |) + ] + |), + "specs::itable::InstructionTableEntry", + "opcode" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::itable::Opcode::BrTable", + "targets" + |) in + let targets := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::itable::BrTarget"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ M.read (| targets |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |) in + let targets_len := + M.alloc (| + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::itable::BrTarget"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ targets ] + |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig", + "drop" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| drop |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig", + "dst_iid" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| dst_pc |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig", + "memory_table_lookup_stack_read_index" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool true; + M.read (| index |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let keep_type := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ M.read (| keep |); Value.Integer 0 ] + |) + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig", + "keep" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig", + "keep_value" + |); + M.read (| ctx |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + Value.Integer 0 + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig", + "keep_is_i32" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + keep_type; + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig", + "memory_table_lookup_stack_read_return_value" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 2 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "specs::mtable::VarType", + [ + Ty.path + "specs::types::ValueType" + ], + "from", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + Value.Integer 0 + ] + |) + |) + ] + |) + |); + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + Value.Integer 0 + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig", + "memory_table_lookup_stack_write_return_value" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 2 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.path "u32", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "u32" ] + ], + "add", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |); + M.read (| drop |) + ] + |), + Value.Integer 2 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "specs::mtable::VarType", + [ + Ty.path + "specs::types::ValueType" + ], + "from", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + Value.Integer 0 + ] + |) + |) + ] + |) + |); + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + Value.Integer 0 + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig", + "targets_len" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| targets_len |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let effective_index := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (M.read (| index |)) + (M.read (| targets_len |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + index)); + fun γ => + ltac:(M.monadic + (M.alloc (| + BinOp.Panic.sub (| + Integer.U64, + M.read (| targets_len |), + Value.Integer 1 + |) + |))) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig", + "expected_index" + |); + M.read (| ctx |); + M.read (| index |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig", + "effective_index" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| effective_index |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig", + "is_out_of_bound" + |); + M.read (| ctx |); + BinOp.Pure.ne + (M.read (| index |)) + (M.read (| effective_index |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig", + "is_not_out_of_bound" + |); + M.read (| ctx |); + BinOp.Pure.eq + (M.read (| index |)) + (M.read (| effective_index |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig", + "diff" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ Ty.path "u64" ], + "into", + [] + |), + [ + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (M.read (| index |)) + (M.read (| targets_len |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.sub (| + Integer.U64, + M.read (| targets_len |), + M.read (| index |) + |), + Value.Integer 1 + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + BinOp.Panic.sub (| + Integer.U64, + M.read (| index |), + M.read (| targets_len |) + |) + |))) + ] + |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_bn", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig", + "br_table_lookup" + |); + M.read (| ctx |); + M.alloc (| + M.call_closure (| + M.get_function (| + "specs::encode::br_table::encode_br_table_entry", + [ Ty.path "num_bigint::biguint::BigUint" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "from", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "fid" + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "from", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "iid" + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| effective_index |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "from", + [] + |), + [ M.read (| M.read (| drop |) |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "usize" ], + "from", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "from", + [] + |), + [ M.read (| M.read (| dst_pc |) |) ] + |) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, meta: &mut VirtualCells<'_, F>) -> Option> { + Some(self.drop.expr(meta) + constant_from!(1)) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig", + "drop" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn next_iid( + &self, + meta: &mut VirtualCells<'_, F>, + _common_config: &EventTableCommonConfig, + ) -> Option> { + Some(self.dst_iid.expr(meta)) + } + *) + Definition next_iid (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta; _common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let _common_config := M.alloc (| _common_config |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig", + "dst_iid" + |); + M.read (| meta |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn mops(&self, meta: &mut VirtualCells<'_, F>) -> Option> { + Some(self.keep.expr(meta)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_br_table::BrTableConfig", + "keep" + |); + M.read (| meta |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, entry: &EventTableEntry) -> u32 { + match &entry.step_info { + StepInfo::BrTable { keep, .. } => keep.len() as u32, + _ => unreachable!(), + } + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let entry := M.alloc (| entry |) in + M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrTable", + "keep" + |) in + let keep := M.alloc (| γ1_0 |) in + M.alloc (| + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("sp_diff", InstanceField.Method (sp_diff F)); + ("next_iid", InstanceField.Method (next_iid F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_br_table_BrTableConfig_F. + End op_br_table. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_call.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_call.v new file mode 100644 index 000000000..a353e6f7a --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_call.v @@ -0,0 +1,1182 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_call. + (* StructRecord + { + name := "CallConfig"; + ty_params := [ "F" ]; + fields := + [ + ("index_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("frame_table_lookup", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "CallConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_call_CallConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_call::CallConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let index_cell = allocator.alloc_common_range_cell(); + let frame_table_lookup = common_config.jtable_lookup_cell; + + let fid_cell = common_config.fid_cell; + let iid_cell = common_config.iid_cell; + let frame_id_cell = common_config.frame_id_cell; + let eid = common_config.eid_cell; + + constraint_builder.constraints.push(( + "return frame table lookups", + Box::new(move |meta| { + vec![ + frame_table_lookup.cell.expr(meta) + - JumpTableConfig::encode_lookup( + eid.expr(meta), + frame_id_cell.expr(meta), + index_cell.expr(meta), + fid_cell.expr(meta), + iid_cell.expr(meta) + constant_from!(1), + ), + ] + }), + )); + + Box::new(CallConfig { + index_cell, + frame_table_lookup, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let index_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let frame_table_lookup := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "jtable_lookup_cell" + |) + |) in + let fid_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "fid_cell" + |) + |) in + let iid_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "iid_cell" + |) + |) in + let frame_id_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "frame_id_cell" + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| constraint_builder |), + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder", + "constraints" + |); + Value.Tuple + [ + M.read (| Value.String "return frame table lookups" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + frame_table_lookup, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell", + "cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::jtable::expression::JtableLookupEntryEncode", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + [ F ], + "encode_lookup", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + eid; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + frame_id_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + index_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + fid_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + iid_cell; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_call::CallConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_call::CallConfig" + [ + ("index_cell", M.read (| index_cell |)); + ("frame_table_lookup", M.read (| frame_table_lookup |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_call_CallConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_call_CallConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_call::CallConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + encode_call(self.index_cell.expr(meta)) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_function (| + "specs::encode::opcode::encode_call", + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call::CallConfig", + "index_cell" + |); + M.read (| meta |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::Call { index } => { + self.index_cell.assign(ctx, F::from( *index as u64))?; + self.frame_table_lookup.cell.assign( + ctx, + bn_to_field(&encode_frame_table_entry( + step.current.eid.into(), + step.current.last_jump_eid.into(), + ( *index).into(), + step.current.fid.into(), + (step.current.iid + 1).into(), + )), + )?; + Ok(()) + } + + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Call", + "index" + |) in + let index := M.alloc (| γ1_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call::CallConfig", + "index_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| index |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call::CallConfig", + "frame_table_lookup" + |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell", + "cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_function (| + "specs::encode::frame_table::encode_frame_table_entry", + [ Ty.path "num_bigint::biguint::BigUint" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u32", + [ Ty.path "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u32", + [ Ty.path "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "last_jump_eid" + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u32", + [ Ty.path "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ M.read (| M.read (| index |) |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u32", + [ Ty.path "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "fid" + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u32", + [ Ty.path "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "iid" + |) + |), + Value.Integer 1 + |) + ] + |) + ] + |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn jops_expr(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from_bn!(&self.jops())) + } + *) + Definition jops_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_call::CallConfig") + [ F ], + [ F ], + "jops", + [] + |), + [ M.read (| self |) ] + |) + |) + ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn jops(&self) -> BigUint { + encode_jops(0, 1) + } + *) + Definition jops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_function (| "delphinus_zkwasm::circuits::jtable::encode_jops", [] |), + [ Value.Integer 0; Value.Integer 1 ] + |))) + | _, _ => M.impossible + end. + + (* + fn next_frame_id( + &self, + meta: &mut VirtualCells<'_, F>, + common_config: &EventTableCommonConfig, + ) -> Option> { + Some(common_config.eid_cell.curr_expr(meta)) + } + *) + Definition next_frame_id (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta; common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let common_config := M.alloc (| common_config |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |); + M.read (| meta |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn next_fid( + &self, + meta: &mut VirtualCells<'_, F>, + _common_config: &EventTableCommonConfig, + ) -> Option> { + Some(self.index_cell.expr(meta)) + } + *) + Definition next_fid (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta; _common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let _common_config := M.alloc (| _common_config |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call::CallConfig", + "index_cell" + |); + M.read (| meta |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn next_iid( + &self, + _meta: &mut VirtualCells<'_, F>, + _common_config: &EventTableCommonConfig, + ) -> Option> { + Some(constant_from!(0)) + } + *) + Definition next_iid (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta; _common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + let _common_config := M.alloc (| _common_config |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 0 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("jops_expr", InstanceField.Method (jops_expr F)); + ("jops", InstanceField.Method (jops F)); + ("next_frame_id", InstanceField.Method (next_frame_id F)); + ("next_fid", InstanceField.Method (next_fid F)); + ("next_iid", InstanceField.Method (next_iid F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_call_CallConfig_F. + End op_call. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_call_host_foreign_circuit.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_call_host_foreign_circuit.v new file mode 100644 index 000000000..5ba978949 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_call_host_foreign_circuit.v @@ -0,0 +1,2780 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_call_host_foreign_circuit. + (* StructRecord + { + name := "ExternalCallHostCircuitConfig"; + ty_params := [ "F" ]; + fields := + [ + ("op", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("value_is_ret", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("value_is_not_ret", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("external_foreign_call_lookup_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("memory_table_lookup_stack_read", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_write", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "ExternalCallHostCircuitConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_call_host_foreign_circuit_ExternalCallHostCircuitConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_call_host_foreign_circuit::ExternalCallHostCircuitConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let op = allocator.alloc_common_range_cell(); + let value_is_ret = allocator.alloc_bit_cell(); + let value_is_not_ret = allocator.alloc_bit_cell(); + + let index = common_config.external_host_call_index_cell; + let external_foreign_call_lookup_cell = common_config.external_foreign_call_lookup_cell; + + constraint_builder.push( + "op_call_host is_ret or not", + Box::new(move |meta| { + vec![value_is_ret.expr(meta) + value_is_not_ret.expr(meta) - constant_from!(1)] + }), + ); + + constraint_builder.push( + "external host call index change", + Box::new(move |meta| { + vec![index.next_expr(meta) - index.curr_expr(meta) - constant_from!(1)] + }), + ); + + let eid = common_config.eid_cell; + let sp = common_config.sp_cell; + + let memory_table_lookup_stack_read = allocator + .alloc_memory_table_lookup_read_cell_with_value( + "op_call_host read value", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack), + move |meta| sp.expr(meta) + constant_from!(1), + move |____| constant_from!(0), + move |meta| value_is_not_ret.expr(meta), + ); + + let memory_table_lookup_stack_write = allocator + .alloc_memory_table_lookup_write_cell_with_value( + "op_call_host return value", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack), + move |meta| sp.expr(meta), + move |____| constant_from!(0), + move |meta| value_is_ret.expr(meta), + ); + + constraint_builder.push( + "external host call lookup", + Box::new(move |meta| { + let operand = value_is_not_ret.expr(meta) + * memory_table_lookup_stack_read.value_cell.expr(meta) + + value_is_ret.expr(meta) + * memory_table_lookup_stack_write.value_cell.expr(meta); + + vec![ + external_foreign_call_lookup_cell.expr(meta) + - encode_host_call_entry(index.expr(meta), op.expr(meta), operand), + ] + }), + ); + + Box::new(ExternalCallHostCircuitConfig { + op, + value_is_ret, + value_is_not_ret, + external_foreign_call_lookup_cell, + memory_table_lookup_stack_read, + memory_table_lookup_stack_write, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let op := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let value_is_ret := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let value_is_not_ret := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let index := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "external_host_call_index_cell" + |) + |) in + let external_foreign_call_lookup_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "external_foreign_call_lookup_cell" + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_call_host is_ret or not" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + value_is_ret; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + value_is_not_ret; + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "external host call index change" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + index; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + index; + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let memory_table_lookup_stack_read := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell_with_value", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_call_host read value" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 0 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ value_is_not_ret; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_write := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell_with_value", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_call_host return value" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 0 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ value_is_ret; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "external host call lookup" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let operand := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + value_is_not_ret; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + memory_table_lookup_stack_read, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "value_cell" + |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ value_is_ret; M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + memory_table_lookup_stack_write, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "value_cell" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + external_foreign_call_lookup_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_function (| + "specs::external_host_call_table::encode::encode_host_call_entry", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + index; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + op; + M.read (| + meta + |) + ] + |); + M.read (| operand |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_call_host_foreign_circuit::ExternalCallHostCircuitConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_call_host_foreign_circuit::ExternalCallHostCircuitConfig" + [ + ("op", M.read (| op |)); + ("value_is_ret", M.read (| value_is_ret |)); + ("value_is_not_ret", M.read (| value_is_not_ret |)); + ("external_foreign_call_lookup_cell", + M.read (| external_foreign_call_lookup_cell |)); + ("memory_table_lookup_stack_read", + M.read (| memory_table_lookup_stack_read |)); + ("memory_table_lookup_stack_write", + M.read (| memory_table_lookup_stack_write |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_call_host_foreign_circuit_ExternalCallHostCircuitConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_call_host_foreign_circuit_ExternalCallHostCircuitConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_call_host_foreign_circuit::ExternalCallHostCircuitConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + encode_call_host(self.op.expr(meta), self.value_is_ret.expr(meta)) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_function (| + "specs::encode::opcode::encode_call_host", + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call_host_foreign_circuit::ExternalCallHostCircuitConfig", + "op" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call_host_foreign_circuit::ExternalCallHostCircuitConfig", + "value_is_ret" + |); + M.read (| meta |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::ExternalHostCall { op, value, sig } => { + self.op.assign(ctx, F::from( *op as u64))?; + self.value_is_ret.assign_bool(ctx, sig.is_ret())?; + self.value_is_not_ret.assign_bool(ctx, !sig.is_ret())?; + self.external_foreign_call_lookup_cell.assign_bn( + ctx, + &encode_host_call_entry( + BigUint::from(step.current.external_host_call_call_index), + BigUint::from( *op as u64), + BigUint::from(value.unwrap()), + ), + )?; + + match sig { + ExternalHostCallSignature::Argument => { + self.memory_table_lookup_stack_read.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + false, + value.unwrap(), + )?; + } + ExternalHostCallSignature::Return => { + self.memory_table_lookup_stack_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp, + LocationType::Stack, + false, + value.unwrap(), + )?; + } + } + + Ok(()) + } + + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::ExternalHostCall", + "op" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::ExternalHostCall", + "value" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::ExternalHostCall", + "sig" + |) in + let op := M.alloc (| γ1_0 |) in + let value := M.alloc (| γ1_1 |) in + let sig := M.alloc (| γ1_2 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call_host_foreign_circuit::ExternalCallHostCircuitConfig", + "op" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| op |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call_host_foreign_circuit::ExternalCallHostCircuitConfig", + "value_is_ret" + |); + M.read (| ctx |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::external_host_call_table::ExternalHostCallSignature", + "is_ret", + [] + |), + [ M.read (| sig |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call_host_foreign_circuit::ExternalCallHostCircuitConfig", + "value_is_not_ret" + |); + M.read (| ctx |); + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::external_host_call_table::ExternalHostCallSignature", + "is_ret", + [] + |), + [ M.read (| sig |) ] + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_bn", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call_host_foreign_circuit::ExternalCallHostCircuitConfig", + "external_foreign_call_lookup_cell" + |); + M.read (| ctx |); + M.alloc (| + M.call_closure (| + M.get_function (| + "specs::external_host_call_table::encode::encode_host_call_entry", + [ Ty.path "num_bigint::biguint::BigUint" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "from", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "external_host_call_call_index" + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| op |) |)) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ], + "unwrap", + [] + |), + [ M.read (| M.read (| value |) |) ] + |) + ] + |) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + sig, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call_host_foreign_circuit::ExternalCallHostCircuitConfig", + "memory_table_lookup_stack_read" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool false; + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ], + "unwrap", + [] + |), + [ M.read (| M.read (| value |) |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call_host_foreign_circuit::ExternalCallHostCircuitConfig", + "memory_table_lookup_stack_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool false; + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ], + "unwrap", + [] + |), + [ M.read (| M.read (| value |) |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1) - self.value_is_ret.expr(meta) * constant_from!(2)) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call_host_foreign_circuit::ExternalCallHostCircuitConfig", + "value_is_ret" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 2 |)) |) ] + |) + ] + ] + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, entry: &specs::etable::EventTableEntry) -> u32 { + match &entry.step_info { + StepInfo::ExternalHostCall { sig, .. } => match sig { + ExternalHostCallSignature::Return => 1u32, + _ => 0, + }, + _ => unreachable!(), + } + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let entry := M.alloc (| entry |) in + M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::ExternalHostCall", + "sig" + |) in + let sig := M.alloc (| γ1_0 |) in + M.match_operator (| + sig, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| Value.Integer 1 |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Integer 0 |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + fn mops(&self, meta: &mut VirtualCells<'_, F>) -> Option> { + Some(self.value_is_ret.curr_expr(meta)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call_host_foreign_circuit::ExternalCallHostCircuitConfig", + "value_is_ret" + |); + M.read (| meta |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn is_external_host_call(&self, _entry: &specs::etable::EventTableEntry) -> bool { + true + } + *) + Definition is_external_host_call (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _entry := M.alloc (| _entry |) in + Value.Bool true)) + | _, _ => M.impossible + end. + + (* + fn external_host_call_index_increase( + &self, + _meta: &mut VirtualCells<'_, F>, + _common_config: &EventTableCommonConfig, + ) -> Option> { + Some(constant_from!(1)) + } + *) + Definition external_host_call_index_increase + (F : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta; _common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + let _common_config := M.alloc (| _common_config |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("sp_diff", InstanceField.Method (sp_diff F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)); + ("mops", InstanceField.Method (mops F)); + ("is_external_host_call", InstanceField.Method (is_external_host_call F)); + ("external_host_call_index_increase", + InstanceField.Method (external_host_call_index_increase F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_call_host_foreign_circuit_ExternalCallHostCircuitConfig_F. + End op_call_host_foreign_circuit. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_call_indirect.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_call_indirect.v new file mode 100644 index 000000000..c24b5f108 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_call_indirect.v @@ -0,0 +1,2688 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_call_indirect. + (* StructRecord + { + name := "CallIndirectConfig"; + ty_params := [ "F" ]; + fields := + [ + ("type_index", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("func_index", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("offset", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("table_index", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("memory_table_lookup_stack_read", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("elem_lookup", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("frame_table_lookup", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "CallIndirectConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_call_indirect_CallIndirectConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_call_indirect::CallIndirectConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let type_index = allocator.alloc_common_range_cell(); + let table_index = allocator.alloc_common_range_cell(); + let offset = allocator.alloc_common_range_cell(); + let func_index = allocator.alloc_common_range_cell(); + + // Wasmi only support one table. + constraint_builder.push( + "table_index", + Box::new(move |meta| vec![table_index.expr(meta)]), + ); + + let elem_lookup = common_config.brtable_lookup_cell; + + constraint_builder.push( + "op_call_indirect elem table lookup", + Box::new(move |meta| { + vec![ + elem_lookup.expr(meta) + - encode_elem_entry( + table_index.expr(meta), + type_index.expr(meta), + offset.expr(meta), + func_index.expr(meta), + ), + ] + }), + ); + + let eid = common_config.eid_cell; + let sp = common_config.sp_cell; + + let memory_table_lookup_stack_read = allocator.alloc_memory_table_lookup_read_cell( + "op_call_indirect stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack), + move |meta| sp.expr(meta) + constant_from!(1), + move |____| constant_from!(1), + move |meta| offset.expr(meta), + move |____| constant_from!(1), + ); + + let fid_cell = common_config.fid_cell; + let iid_cell = common_config.iid_cell; + let frame_id_cell = common_config.frame_id_cell; + let eid = common_config.eid_cell; + let frame_table_lookup = common_config.jtable_lookup_cell; + + constraint_builder.constraints.push(( + "return frame table lookups", + Box::new(move |meta| { + vec![ + frame_table_lookup.cell.expr(meta) + - JumpTableConfig::encode_lookup( + eid.expr(meta), + frame_id_cell.expr(meta), + func_index.expr(meta), + fid_cell.expr(meta), + iid_cell.expr(meta) + constant_from!(1), + ), + ] + }), + )); + + Box::new(CallIndirectConfig { + type_index, + func_index, + offset, + table_index, + memory_table_lookup_stack_read, + elem_lookup, + frame_table_lookup, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let type_index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let table_index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let offset := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let func_index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "table_index" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + table_index; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let elem_lookup := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "brtable_lookup_cell" + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_call_indirect elem table lookup" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + elem_lookup; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_function (| + "specs::encode::br_table::encode_elem_entry", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + table_index; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + type_index; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + offset; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + func_index; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let memory_table_lookup_stack_read := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_call_indirect stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ offset; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let fid_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "fid_cell" + |) + |) in + let iid_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "iid_cell" + |) + |) in + let frame_id_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "frame_id_cell" + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let frame_table_lookup := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "jtable_lookup_cell" + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| constraint_builder |), + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder", + "constraints" + |); + Value.Tuple + [ + M.read (| Value.String "return frame table lookups" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + frame_table_lookup, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell", + "cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::jtable::expression::JtableLookupEntryEncode", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + [ F ], + "encode_lookup", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + eid; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + frame_id_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + func_index; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + fid_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + iid_cell; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_call_indirect::CallIndirectConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_call_indirect::CallIndirectConfig" + [ + ("type_index", M.read (| type_index |)); + ("func_index", M.read (| func_index |)); + ("offset", M.read (| offset |)); + ("table_index", M.read (| table_index |)); + ("memory_table_lookup_stack_read", + M.read (| memory_table_lookup_stack_read |)); + ("elem_lookup", M.read (| elem_lookup |)); + ("frame_table_lookup", M.read (| frame_table_lookup |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_call_indirect_CallIndirectConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_call_indirect_CallIndirectConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_call_indirect::CallIndirectConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + encode_call_indirect(self.type_index.expr(meta)) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_function (| + "specs::encode::opcode::encode_call_indirect", + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call_indirect::CallIndirectConfig", + "type_index" + |); + M.read (| meta |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::CallIndirect { + table_index, + type_index, + offset, + func_index, + .. + } => { + self.table_index.assign(ctx, F::from( *table_index as u64))?; + self.type_index.assign(ctx, F::from( *type_index as u64))?; + self.offset.assign(ctx, F::from( *offset as u64))?; + self.func_index.assign(ctx, F::from( *func_index as u64))?; + + self.elem_lookup.assign_bn( + ctx, + &encode_elem_entry( + BigUint::from( *table_index), + BigUint::from( *type_index), + BigUint::from( *offset), + BigUint::from( *func_index), + ), + )?; + + self.memory_table_lookup_stack_read.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + true, + *offset as u64, + )?; + + self.frame_table_lookup.cell.assign_bn( + ctx, + &encode_frame_table_entry( + step.current.eid.into(), + step.current.last_jump_eid.into(), + ( *func_index).into(), + step.current.fid.into(), + (step.current.iid + 1).into(), + ), + )?; + + Ok(()) + } + + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallIndirect", + "table_index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallIndirect", + "type_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallIndirect", + "offset" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallIndirect", + "func_index" + |) in + let table_index := M.alloc (| γ1_0 |) in + let type_index := M.alloc (| γ1_1 |) in + let offset := M.alloc (| γ1_2 |) in + let func_index := M.alloc (| γ1_3 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call_indirect::CallIndirectConfig", + "table_index" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| table_index |) |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call_indirect::CallIndirectConfig", + "type_index" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| type_index |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call_indirect::CallIndirectConfig", + "offset" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| offset |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call_indirect::CallIndirectConfig", + "func_index" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| func_index |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_bn", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call_indirect::CallIndirectConfig", + "elem_lookup" + |); + M.read (| ctx |); + M.alloc (| + M.call_closure (| + M.get_function (| + "specs::encode::br_table::encode_elem_entry", + [ Ty.path "num_bigint::biguint::BigUint" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "from", + [] + |), + [ M.read (| M.read (| table_index |) |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "from", + [] + |), + [ M.read (| M.read (| type_index |) |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "from", + [] + |), + [ M.read (| M.read (| offset |) |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "from", + [] + |), + [ M.read (| M.read (| func_index |) |) ] + |) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call_indirect::CallIndirectConfig", + "memory_table_lookup_stack_read" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool true; + M.rust_cast (M.read (| M.read (| offset |) |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ], + [ F ], + "assign_bn", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call_indirect::CallIndirectConfig", + "frame_table_lookup" + |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell", + "cell" + |); + M.read (| ctx |); + M.alloc (| + M.call_closure (| + M.get_function (| + "specs::encode::frame_table::encode_frame_table_entry", + [ Ty.path "num_bigint::biguint::BigUint" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u32", + [ Ty.path "num_bigint::biguint::BigUint" ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u32", + [ Ty.path "num_bigint::biguint::BigUint" ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "last_jump_eid" + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u32", + [ Ty.path "num_bigint::biguint::BigUint" ], + "into", + [] + |), + [ M.read (| M.read (| func_index |) |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u32", + [ Ty.path "num_bigint::biguint::BigUint" ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "fid" + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u32", + [ Ty.path "num_bigint::biguint::BigUint" ], + "into", + [] + |), + [ + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "iid" + |) + |), + Value.Integer 1 + |) + ] + |) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant!(F::one())) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "one", [] |), + [] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn jops_expr(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from_bn!(&self.jops())) + } + *) + Definition jops_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_call_indirect::CallIndirectConfig") + [ F ], + [ F ], + "jops", + [] + |), + [ M.read (| self |) ] + |) + |) + ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn jops(&self) -> BigUint { + encode_jops(0, 1) + } + *) + Definition jops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_function (| "delphinus_zkwasm::circuits::jtable::encode_jops", [] |), + [ Value.Integer 0; Value.Integer 1 ] + |))) + | _, _ => M.impossible + end. + + (* + fn next_frame_id( + &self, + meta: &mut VirtualCells<'_, F>, + common_config: &EventTableCommonConfig, + ) -> Option> { + Some(common_config.eid_cell.curr_expr(meta)) + } + *) + Definition next_frame_id (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta; common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let common_config := M.alloc (| common_config |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |); + M.read (| meta |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn next_fid( + &self, + meta: &mut VirtualCells<'_, F>, + _common_config: &EventTableCommonConfig, + ) -> Option> { + Some(self.func_index.expr(meta)) + } + *) + Definition next_fid (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta; _common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let _common_config := M.alloc (| _common_config |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_call_indirect::CallIndirectConfig", + "func_index" + |); + M.read (| meta |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn next_iid( + &self, + _meta: &mut VirtualCells<'_, F>, + _common_config: &EventTableCommonConfig, + ) -> Option> { + Some(constant_from!(0)) + } + *) + Definition next_iid (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta; _common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + let _common_config := M.alloc (| _common_config |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 0 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("sp_diff", InstanceField.Method (sp_diff F)); + ("jops_expr", InstanceField.Method (jops_expr F)); + ("jops", InstanceField.Method (jops F)); + ("next_frame_id", InstanceField.Method (next_frame_id F)); + ("next_fid", InstanceField.Method (next_fid F)); + ("next_iid", InstanceField.Method (next_iid F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_call_indirect_CallIndirectConfig_F. + End op_call_indirect. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_const.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_const.v new file mode 100644 index 000000000..06128fc7f --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_const.v @@ -0,0 +1,1520 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_const. + (* StructRecord + { + name := "ConstConfig"; + ty_params := [ "F" ]; + fields := + [ + ("is_i32", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("value", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("memory_table_lookup_stack_write", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "ConstConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_const_ConstConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_const::ConstConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let is_i32 = allocator.alloc_bit_cell(); + let value = allocator.alloc_u64_cell(); + + let sp_cell = common_config.sp_cell; + let eid_cell = common_config.eid_cell; + + let memory_table_lookup_stack_write = allocator.alloc_memory_table_lookup_write_cell( + "op_const stack write", + constraint_builder, + eid_cell, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp_cell.expr(meta), + move |meta| is_i32.expr(meta), + move |meta| value.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + Box::new(ConstConfig { + is_i32, + value, + memory_table_lookup_stack_write, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let is_i32 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let sp_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let eid_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let memory_table_lookup_stack_write := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_const stack write" |); + M.read (| constraint_builder |); + M.read (| eid_cell |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_const::ConstConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_const::ConstConfig" + [ + ("is_i32", M.read (| is_i32 |)); + ("value", M.read (| value |)); + ("memory_table_lookup_stack_write", + M.read (| memory_table_lookup_stack_write |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_const_ConstConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_const_ConstConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_const::ConstConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + constant!(bn_to_field( + &(BigUint::from(OpcodeClass::Const as u64) << OPCODE_CLASS_SHIFT) + )) + self.is_i32.expr(meta) + * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG0_SHIFT))) + + self.value.u64_cell.expr(meta) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 5 + |)) + ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_CLASS_SHIFT" |) + |) + ] + |) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_const::ConstConfig", + "is_i32" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_ARG0_SHIFT" |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_const::ConstConfig", + "value" + |), + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::I32Const { value } => { + self.value.assign(ctx, *value as u32 as u64)?; + self.is_i32.assign(ctx, F::one())?; + self.memory_table_lookup_stack_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp, + LocationType::Stack, + true, + *value as u32 as u64, + )?; + + Ok(()) + } + StepInfo::I64Const { value } => { + self.value.assign(ctx, *value as u64)?; + self.is_i32.assign(ctx, F::zero())?; + self.memory_table_lookup_stack_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp, + LocationType::Stack, + false, + *value as u64, + )?; + + Ok(()) + } + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32Const", + "value" + |) in + let value := M.alloc (| γ1_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_const::ConstConfig", + "value" + |); + M.read (| ctx |); + M.rust_cast + (M.rust_cast (M.read (| M.read (| value |) |))) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_const::ConstConfig", + "is_i32" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_const::ConstConfig", + "memory_table_lookup_stack_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool true; + M.rust_cast + (M.rust_cast (M.read (| M.read (| value |) |))) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64Const", + "value" + |) in + let value := M.alloc (| γ1_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_const::ConstConfig", + "value" + |); + M.read (| ctx |); + M.rust_cast (M.read (| M.read (| value |) |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_const::ConstConfig", + "is_i32" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_const::ConstConfig", + "memory_table_lookup_stack_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool false; + M.rust_cast (M.read (| M.read (| value |) |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant!(-F::one())) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Neg", F, [], "neg", [] |), + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "one", [] |), + [] + |) + ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn mops(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, _: &EventTableEntry) -> u32 { + 1 + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Integer 1)) ] |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("sp_diff", InstanceField.Method (sp_diff F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_const_ConstConfig_F. + End op_const. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_conversion.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_conversion.v new file mode 100644 index 000000000..f21c2fec1 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_conversion.v @@ -0,0 +1,6807 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_conversion. + (* StructRecord + { + name := "ConversionConfig"; + ty_params := [ "F" ]; + fields := + [ + ("value", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("value_is_i8", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("value_is_i16", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("value_is_i32", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("value_is_i64", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("value_type_is_i32", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("res_is_i32", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("res_is_i64", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("sign_op", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_i32_wrap_i64", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("flag_bit", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("rem", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("rem_helper", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("d", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("modulus", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("shift", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("padding", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("memory_table_lookup_stack_read", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_write", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "ConversionConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_conversion_ConversionConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let value = allocator.alloc_u64_cell(); + + let value_is_i8 = allocator.alloc_bit_cell(); + let value_is_i16 = allocator.alloc_bit_cell(); + let value_is_i32 = allocator.alloc_bit_cell(); + let value_is_i64 = allocator.alloc_bit_cell(); + + let value_type_is_i32 = allocator.alloc_bit_cell(); + + let res_is_i32 = allocator.alloc_bit_cell(); + let res_is_i64 = allocator.alloc_bit_cell(); + + let sign_op = allocator.alloc_bit_cell(); + let is_i32_wrap_i64 = allocator.alloc_bit_cell(); + + let flag_bit = allocator.alloc_bit_cell(); + let shift = allocator.alloc_unlimited_cell(); + let padding = allocator.alloc_unlimited_cell(); + + let d = allocator.alloc_u64_cell(); + let rem = allocator.alloc_u64_cell(); + let rem_helper = allocator.alloc_u64_cell(); + let modulus = allocator.alloc_unlimited_cell(); + + let eid = common_config.eid_cell; + let sp = common_config.sp_cell; + + let memory_table_lookup_stack_read = allocator.alloc_memory_table_lookup_read_cell( + "op_conversion stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |meta| value_type_is_i32.expr(meta), + move |meta| value.expr(meta), + move |____| constant_from!(1), + ); + + let memory_table_lookup_stack_write = allocator + .alloc_memory_table_lookup_write_cell_with_value( + "op_conversion stack write", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |meta| res_is_i32.expr(meta), + move |____| constant_from!(1), + ); + + let res = memory_table_lookup_stack_write.value_cell; + + /* + * Implicit Constraint: + * + * value_is_i8 || value_is_i16 || value_is_i32 || value_is_i64 can be constrained by opcode. + * res_is_i32 || res_is_i64 can be constrained by opcode. + */ + + constraint_builder.push( + "op_conversion i32_wrap_i64", + Box::new(move |meta| { + vec![ + is_i32_wrap_i64.expr(meta) + * (value_is_i64.expr(meta) + res_is_i32.expr(meta) - constant_from!(2)), + is_i32_wrap_i64.expr(meta) + * (value.u16_cells_le[1].expr(meta) * constant_from!(1 << 16) + + value.u16_cells_le[0].expr(meta) + - res.expr(meta)), + ] + }), + ); + + constraint_builder.push( + "op_conversion helper", + Box::new(move |meta| { + vec![ + // In order to make i32.wrap_i64 satisfies the "op_conversion: sign extension" + // constraint, setting the shift value to `1<<31` when value_is_i64. + shift.expr(meta) + - (value_is_i8.expr(meta) * constant_from!(1u64 << 7) + + value_is_i16.expr(meta) * constant_from!(1u64 << 15) + + (value_is_i32.expr(meta) + value_is_i64.expr(meta)) + * constant_from!(1u64 << 31)), + padding.expr(meta) + - (value_is_i8.expr(meta) * constant_from!((u32::MAX << 8) as u64) + + value_is_i16.expr(meta) * constant_from!((u32::MAX << 16) as u64) + + res_is_i64.expr(meta) * constant_from!(u64::MAX << 32)), + modulus.expr(meta) - shift.expr(meta) * constant_from!(2), + ] + }), + ); + + constraint_builder.push( + "op_conversion: split operand", + Box::new(move |meta| { + vec![ + /* + * split value into (out of range part, sign flag, rem) + * e.g. supports i32.extend_i8s but operand is 0x100 + */ + value.expr(meta) + - d.expr(meta) * modulus.expr(meta) + - flag_bit.expr(meta) * shift.expr(meta) + - rem.expr(meta), + // rem must less than shift + rem.expr(meta) + constant_from!(1) + rem_helper.expr(meta) - shift.expr(meta), + ] + }), + ); + + constraint_builder.push( + "op_conversion: sign extension", + Box::new(move |meta| { + vec![ + // Compose Result for all extend instructions + flag_bit.expr(meta) * padding.expr(meta) * sign_op.expr(meta) + + flag_bit.expr(meta) * shift.expr(meta) + + rem.expr(meta) + - res.expr(meta), + ] + }), + ); + + Box::new(ConversionConfig { + value, + value_is_i8, + value_is_i16, + value_is_i32, + value_is_i64, + value_type_is_i32, + res_is_i32, + res_is_i64, + sign_op, + is_i32_wrap_i64, + flag_bit, + d, + rem, + rem_helper, + modulus, + shift, + padding, + memory_table_lookup_stack_read, + memory_table_lookup_stack_write, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let value_is_i8 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let value_is_i16 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let value_is_i32 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let value_is_i64 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let value_type_is_i32 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let res_is_i32 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let res_is_i64 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let sign_op := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_i32_wrap_i64 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let flag_bit := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let shift := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let padding := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let d := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let rem := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let rem_helper := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let modulus := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let memory_table_lookup_stack_read := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_conversion stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ value_type_is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ value; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_write := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell_with_value", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_conversion stack write" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ res_is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let res := + M.copy (| + M.SubPointer.get_struct_record_field (| + memory_table_lookup_stack_write, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "value_cell" + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_conversion i32_wrap_i64" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_i32_wrap_i64; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + value_is_i64; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_i32; + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 2 + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_i32_wrap_i64; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| + Value.Integer + 1 + |) + |); + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 16 + |)) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| + Value.Integer + 0 + |) + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_conversion helper" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ shift; M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + value_is_i8; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 7 + |) + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + value_is_i16; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 15 + |) + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + value_is_i32; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + value_is_i64; + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 31 + |) + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + padding; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + value_is_i8; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.shl (| + M.read (| + M.get_constant (| + "core::num::MAX" + |) + |), + Value.Integer + 8 + |)) + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + value_is_i16; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.shl (| + M.read (| + M.get_constant (| + "core::num::MAX" + |) + |), + Value.Integer + 16 + |)) + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_i64; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + M.read (| + M.get_constant (| + "core::num::MAX" + |) + |), + Value.Integer + 32 + |) + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + modulus; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + shift; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 2 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_conversion: split operand" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + value; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + d; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + modulus; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + flag_bit; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + shift; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ rem; M.read (| meta |) ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + rem; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + rem_helper; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ shift; M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_conversion: sign extension" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + flag_bit; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + padding; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + sign_op; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + flag_bit; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + shift; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + rem; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ res; M.read (| meta |) ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig" + [ + ("value", M.read (| value |)); + ("value_is_i8", M.read (| value_is_i8 |)); + ("value_is_i16", M.read (| value_is_i16 |)); + ("value_is_i32", M.read (| value_is_i32 |)); + ("value_is_i64", M.read (| value_is_i64 |)); + ("value_type_is_i32", M.read (| value_type_is_i32 |)); + ("res_is_i32", M.read (| res_is_i32 |)); + ("res_is_i64", M.read (| res_is_i64 |)); + ("sign_op", M.read (| sign_op |)); + ("is_i32_wrap_i64", M.read (| is_i32_wrap_i64 |)); + ("flag_bit", M.read (| flag_bit |)); + ("d", M.read (| d |)); + ("rem", M.read (| rem |)); + ("rem_helper", M.read (| rem_helper |)); + ("modulus", M.read (| modulus |)); + ("shift", M.read (| shift |)); + ("padding", M.read (| padding |)); + ("memory_table_lookup_stack_read", + M.read (| memory_table_lookup_stack_read |)); + ("memory_table_lookup_stack_write", + M.read (| memory_table_lookup_stack_write |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_conversion_ConversionConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_conversion_ConversionConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + encode_conversion::>( + self.sign_op.expr(meta), + self.value_type_is_i32.expr(meta), + self.value_is_i8.expr(meta), + self.value_is_i16.expr(meta), + self.value_is_i32.expr(meta), + self.value_is_i64.expr(meta), + self.res_is_i32.expr(meta), + self.res_is_i64.expr(meta), + ) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_function (| + "specs::encode::opcode::encode_conversion", + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "sign_op" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "value_type_is_i32" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "value_is_i8" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "value_is_i16" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "value_is_i32" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "value_is_i64" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "res_is_i32" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "res_is_i64" + |); + M.read (| meta |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + let (is_sign_op, value, value_type, result, result_type, padding, shift) = + match &entry.eentry.step_info { + StepInfo::I32WrapI64 { value, result } => { + self.value_is_i64.assign_bool(ctx, true)?; + self.res_is_i32.assign_bool(ctx, true)?; + self.is_i32_wrap_i64.assign_bool(ctx, true)?; + + ( + false, + *value as u64, + VarType::I64, + *result as u32 as u64, + VarType::I32, + 0, + 1u64 << 31, // To meet `op_conversion: sign extension` constraint + ) + } + StepInfo::I64ExtendI32 { + value, + result, + sign, + } => { + self.value_is_i32.assign_bool(ctx, true)?; + self.res_is_i64.assign_bool(ctx, true)?; + + ( + *sign, + *value as u32 as u64, + VarType::I32, + *result as u64, + VarType::I64, + (u64::MAX << 32) as u64, + 1 << 31, + ) + } + StepInfo::I32SignExtendI8 { value, result } => { + self.value_is_i8.assign_bool(ctx, true)?; + self.res_is_i32.assign_bool(ctx, true)?; + + ( + true, + *value as u32 as u64, + VarType::I32, + *result as u32 as u64, + VarType::I32, + (u32::MAX << 8) as u64, + 1 << 7, + ) + } + StepInfo::I32SignExtendI16 { value, result } => { + self.value_is_i16.assign_bool(ctx, true)?; + self.res_is_i32.assign_bool(ctx, true)?; + + ( + true, + *value as u32 as u64, + VarType::I32, + *result as u32 as u64, + VarType::I32, + (u32::MAX << 16) as u64, + 1 << 15, + ) + } + StepInfo::I64SignExtendI8 { value, result } => { + self.value_is_i8.assign_bool(ctx, true)?; + self.res_is_i64.assign_bool(ctx, true)?; + + ( + true, + *value as u64, + VarType::I64, + *result as u64, + VarType::I64, + (u64::MAX << 8) as u64, + 1 << 7, + ) + } + StepInfo::I64SignExtendI16 { value, result } => { + self.value_is_i16.assign_bool(ctx, true)?; + self.res_is_i64.assign_bool(ctx, true)?; + + ( + true, + *value as u64, + VarType::I64, + *result as u64, + VarType::I64, + (u64::MAX << 16) as u64, + 1 << 15, + ) + } + StepInfo::I64SignExtendI32 { value, result } => { + self.value_is_i32.assign_bool(ctx, true)?; + self.res_is_i64.assign_bool(ctx, true)?; + + ( + true, + *value as u64, + VarType::I64, + *result as u64, + VarType::I64, + (u64::MAX << 32) as u64, + 1 << 31, + ) + } + _ => unreachable!(), + }; + + self.value.assign(ctx, value)?; + self.value_type_is_i32 + .assign(ctx, F::from(value_type as u64))?; + self.res_is_i32.assign(ctx, F::from(result_type as u64))?; + self.sign_op.assign_bool(ctx, is_sign_op)?; + + let modulus = shift << 1; + let rem = (value % modulus) & (shift - 1); + let flag_bit = ((value & shift) != 0) as u64; + + self.d.assign(ctx, value / modulus)?; + self.rem.assign(ctx, rem)?; + self.rem_helper.assign(ctx, shift - 1 - rem)?; + self.flag_bit.assign(ctx, flag_bit.into())?; + self.shift.assign(ctx, F::from(shift))?; + self.modulus + .assign(ctx, bn_to_field(&BigUint::from(modulus)))?; + self.padding.assign(ctx, F::from(padding))?; + + self.memory_table_lookup_stack_read.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + value_type == VarType::I32, + value, + )?; + + self.memory_table_lookup_stack_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + step.current.sp + 1, + LocationType::Stack, + result_type == VarType::I32, + result, + )?; + + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32WrapI64", + "value" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32WrapI64", + "result" + |) in + let value := M.alloc (| γ1_0 |) in + let result := M.alloc (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "value_is_i64" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "res_is_i32" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "is_i32_wrap_i64" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple + [ + Value.Bool false; + M.rust_cast (M.read (| M.read (| value |) |)); + Value.StructTuple "specs::mtable::VarType::I64" []; + M.rust_cast (M.rust_cast (M.read (| M.read (| result |) |))); + Value.StructTuple "specs::mtable::VarType::I32" []; + Value.Integer 0; + BinOp.Panic.shl (| Value.Integer 1, Value.Integer 31 |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64ExtendI32", + "value" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64ExtendI32", + "result" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64ExtendI32", + "sign" + |) in + let value := M.alloc (| γ1_0 |) in + let result := M.alloc (| γ1_1 |) in + let sign := M.alloc (| γ1_2 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "value_is_i32" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "res_is_i64" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple + [ + M.read (| M.read (| sign |) |); + M.rust_cast (M.rust_cast (M.read (| M.read (| value |) |))); + Value.StructTuple "specs::mtable::VarType::I32" []; + M.rust_cast (M.read (| M.read (| result |) |)); + Value.StructTuple "specs::mtable::VarType::I64" []; + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + M.read (| M.get_constant (| "core::num::MAX" |) |), + Value.Integer 32 + |) + |)) + |); + BinOp.Panic.shl (| Value.Integer 1, Value.Integer 31 |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32SignExtendI8", + "value" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32SignExtendI8", + "result" + |) in + let value := M.alloc (| γ1_0 |) in + let result := M.alloc (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "value_is_i8" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "res_is_i32" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple + [ + Value.Bool true; + M.rust_cast (M.rust_cast (M.read (| M.read (| value |) |))); + Value.StructTuple "specs::mtable::VarType::I32" []; + M.rust_cast (M.rust_cast (M.read (| M.read (| result |) |))); + Value.StructTuple "specs::mtable::VarType::I32" []; + M.rust_cast + (BinOp.Panic.shl (| + M.read (| M.get_constant (| "core::num::MAX" |) |), + Value.Integer 8 + |)); + BinOp.Panic.shl (| Value.Integer 1, Value.Integer 7 |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32SignExtendI16", + "value" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32SignExtendI16", + "result" + |) in + let value := M.alloc (| γ1_0 |) in + let result := M.alloc (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "value_is_i16" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "res_is_i32" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple + [ + Value.Bool true; + M.rust_cast (M.rust_cast (M.read (| M.read (| value |) |))); + Value.StructTuple "specs::mtable::VarType::I32" []; + M.rust_cast (M.rust_cast (M.read (| M.read (| result |) |))); + Value.StructTuple "specs::mtable::VarType::I32" []; + M.rust_cast + (BinOp.Panic.shl (| + M.read (| M.get_constant (| "core::num::MAX" |) |), + Value.Integer 16 + |)); + BinOp.Panic.shl (| Value.Integer 1, Value.Integer 15 |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64SignExtendI8", + "value" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64SignExtendI8", + "result" + |) in + let value := M.alloc (| γ1_0 |) in + let result := M.alloc (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "value_is_i8" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "res_is_i64" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple + [ + Value.Bool true; + M.rust_cast (M.read (| M.read (| value |) |)); + Value.StructTuple "specs::mtable::VarType::I64" []; + M.rust_cast (M.read (| M.read (| result |) |)); + Value.StructTuple "specs::mtable::VarType::I64" []; + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + M.read (| M.get_constant (| "core::num::MAX" |) |), + Value.Integer 8 + |) + |)) + |); + BinOp.Panic.shl (| Value.Integer 1, Value.Integer 7 |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64SignExtendI16", + "value" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64SignExtendI16", + "result" + |) in + let value := M.alloc (| γ1_0 |) in + let result := M.alloc (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "value_is_i16" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "res_is_i64" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple + [ + Value.Bool true; + M.rust_cast (M.read (| M.read (| value |) |)); + Value.StructTuple "specs::mtable::VarType::I64" []; + M.rust_cast (M.read (| M.read (| result |) |)); + Value.StructTuple "specs::mtable::VarType::I64" []; + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + M.read (| M.get_constant (| "core::num::MAX" |) |), + Value.Integer 16 + |) + |)) + |); + BinOp.Panic.shl (| Value.Integer 1, Value.Integer 15 |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64SignExtendI32", + "value" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64SignExtendI32", + "result" + |) in + let value := M.alloc (| γ1_0 |) in + let result := M.alloc (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "value_is_i32" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "res_is_i64" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple + [ + Value.Bool true; + M.rust_cast (M.read (| M.read (| value |) |)); + Value.StructTuple "specs::mtable::VarType::I64" []; + M.rust_cast (M.read (| M.read (| result |) |)); + Value.StructTuple "specs::mtable::VarType::I64" []; + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + M.read (| M.get_constant (| "core::num::MAX" |) |), + Value.Integer 32 + |) + |)) + |); + BinOp.Panic.shl (| Value.Integer 1, Value.Integer 31 |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_2 := M.SubPointer.get_tuple_field (| γ, 2 |) in + let γ0_3 := M.SubPointer.get_tuple_field (| γ, 3 |) in + let γ0_4 := M.SubPointer.get_tuple_field (| γ, 4 |) in + let γ0_5 := M.SubPointer.get_tuple_field (| γ, 5 |) in + let γ0_6 := M.SubPointer.get_tuple_field (| γ, 6 |) in + let is_sign_op := M.copy (| γ0_0 |) in + let value := M.copy (| γ0_1 |) in + let value_type := M.copy (| γ0_2 |) in + let result := M.copy (| γ0_3 |) in + let result_type := M.copy (| γ0_4 |) in + let padding := M.copy (| γ0_5 |) in + let shift := M.copy (| γ0_6 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "value" + |); + M.read (| ctx |); + M.read (| value |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "value_type_is_i32" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| value_type |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "res_is_i32" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| result_type |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "sign_op" + |); + M.read (| ctx |); + M.read (| is_sign_op |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let modulus := + M.alloc (| + BinOp.Panic.shl (| M.read (| shift |), Value.Integer 1 |) + |) in + let rem := + M.alloc (| + BinOp.Pure.bit_and + (BinOp.Panic.rem (| + Integer.U64, + M.read (| value |), + M.read (| modulus |) + |)) + (BinOp.Panic.sub (| + Integer.U64, + M.read (| shift |), + Value.Integer 1 + |)) + |) in + let flag_bit := + M.alloc (| + M.rust_cast + (BinOp.Pure.ne + (BinOp.Pure.bit_and (M.read (| value |)) (M.read (| shift |))) + (Value.Integer 0)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "d" + |); + M.read (| ctx |); + BinOp.Panic.div (| + Integer.U64, + M.read (| value |), + M.read (| modulus |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "rem" + |); + M.read (| ctx |); + M.read (| rem |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "rem_helper" + |); + M.read (| ctx |); + BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.sub (| + Integer.U64, + M.read (| shift |), + Value.Integer 1 + |), + M.read (| rem |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "flag_bit" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| flag_bit |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "shift" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| shift |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "modulus" + |); + M.read (| ctx |); + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| modulus |) ] + |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "padding" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| padding |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "memory_table_lookup_stack_read" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + value_type; + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| value |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_conversion::ConversionConfig", + "memory_table_lookup_stack_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + result_type; + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| result |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn mops(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, _: &EventTableEntry) -> u32 { + 1 + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Integer 1)) ] |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_conversion_ConversionConfig_F. + End op_conversion. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_drop.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_drop.v new file mode 100644 index 000000000..1949fac96 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_drop.v @@ -0,0 +1,306 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_drop. + (* StructTuple + { + name := "DropConfig"; + ty_params := []; + fields := []; + } *) + + (* StructTuple + { + name := "DropConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_drop_DropConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_drop::DropConfigBuilder". + + (* + fn configure( + _: &EventTableCommonConfig, + _: &mut EventTableCellAllocator, + _: &mut ConstraintBuilder, + ) -> Box> { + Box::new(DropConfig) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ β0; β1; β2 ] => + ltac:(M.monadic + (let β0 := M.alloc (| β0 |) in + let β1 := M.alloc (| β1 |) in + let β2 := M.alloc (| β2 |) in + M.match_operator (| + β0, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β2, + [ + fun γ => + ltac:(M.monadic + (* Unsize *) + (M.pointer_coercion + (* Unsize *) + (M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_drop::DropConfig"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructTuple + "delphinus_zkwasm::circuits::etable::op_configure::op_drop::DropConfig" + [] + ] + |))))) + ] + |))) + ] + |))) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_drop_DropConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_drop_DropConfig. + Definition Self (F : Ty.t) : Ty.t := + Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_drop::DropConfig". + + (* + fn opcode(&self, _: &mut VirtualCells<'_, F>) -> Expression { + constant_from_bn!(&(BigUint::from(OpcodeClass::Drop as u64) << OPCODE_CLASS_SHIFT)) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 6 + |)) + ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_CLASS_SHIFT" |) + |) + ] + |) + |) + ] + |) + ])) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + _: &mut Context<'_, F>, + _: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::Drop => Ok(()), + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1; β2; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + let β2 := M.alloc (| β2 |) in + let entry := M.alloc (| entry |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + β2, + [ + fun γ => + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + ] + |))) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, _: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1)) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ])) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("sp_diff", InstanceField.Method (sp_diff F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_drop_DropConfig. + End op_drop. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_global_get.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_global_get.v new file mode 100644 index 000000000..91822db61 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_global_get.v @@ -0,0 +1,1646 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_global_get. + (* StructRecord + { + name := "GlobalGetConfig"; + ty_params := [ "F" ]; + fields := + [ + ("idx_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("is_i32_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("value_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("memory_table_lookup_global_read", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_write", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "GlobalGetConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_global_get_GlobalGetConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_global_get::GlobalGetConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let is_i32_cell = allocator.alloc_bit_cell(); + let idx_cell = allocator.alloc_common_range_cell(); + let value_cell = allocator.alloc_u64_cell(); + + let sp_cell = common_config.sp_cell; + let eid_cell = common_config.eid_cell; + + let memory_table_lookup_global_read = allocator.alloc_memory_table_lookup_read_cell( + "op_global_get global read", + constraint_builder, + eid_cell, + move |____| constant_from!(LocationType::Global as u64), + move |meta| idx_cell.expr(meta), + move |meta| is_i32_cell.expr(meta), + move |meta| value_cell.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + let memory_table_lookup_stack_write = allocator.alloc_memory_table_lookup_write_cell( + "op_global_get stack write", + constraint_builder, + eid_cell, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp_cell.expr(meta), + move |meta| is_i32_cell.expr(meta), + move |meta| value_cell.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + Box::new(GlobalGetConfig { + idx_cell, + is_i32_cell, + value_cell, + memory_table_lookup_global_read, + memory_table_lookup_stack_write, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let is_i32_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let idx_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let value_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let sp_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let eid_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let memory_table_lookup_global_read := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_global_get global read" |); + M.read (| constraint_builder |); + M.read (| eid_cell |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Global_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ idx_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value_cell, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_write := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_global_get stack write" |); + M.read (| constraint_builder |); + M.read (| eid_cell |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value_cell, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_global_get::GlobalGetConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_global_get::GlobalGetConfig" + [ + ("idx_cell", M.read (| idx_cell |)); + ("is_i32_cell", M.read (| is_i32_cell |)); + ("value_cell", M.read (| value_cell |)); + ("memory_table_lookup_global_read", + M.read (| memory_table_lookup_global_read |)); + ("memory_table_lookup_stack_write", + M.read (| memory_table_lookup_stack_write |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_global_get_GlobalGetConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_global_get_GlobalGetConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_global_get::GlobalGetConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + encode_global_get(self.idx_cell.expr(meta)) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_function (| + "specs::encode::opcode::encode_global_get", + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_global_get::GlobalGetConfig", + "idx_cell" + |); + M.read (| meta |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::GetGlobal { + idx, vtype, value, .. + } => { + self.idx_cell.assign(ctx, F::from( *idx as u64))?; + self.is_i32_cell.assign(ctx, F::from( *vtype as u64))?; + self.value_cell.assign(ctx, *value)?; + + self.memory_table_lookup_global_read.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + *idx, + LocationType::Global, + *vtype == VarType::I32, + *value, + )?; + + self.memory_table_lookup_stack_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + step.current.sp, + LocationType::Stack, + *vtype == VarType::I32, + *value, + )?; + + Ok(()) + } + + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::GetGlobal", + "idx" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::GetGlobal", + "vtype" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::GetGlobal", + "value" + |) in + let idx := M.alloc (| γ1_0 |) in + let vtype := M.alloc (| γ1_1 |) in + let value := M.alloc (| γ1_2 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_global_get::GlobalGetConfig", + "idx_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| idx |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_global_get::GlobalGetConfig", + "is_i32_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| vtype |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_global_get::GlobalGetConfig", + "value_cell" + |); + M.read (| ctx |); + M.read (| M.read (| value |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_global_get::GlobalGetConfig", + "memory_table_lookup_global_read" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + M.read (| M.read (| idx |) |); + Value.StructTuple + "specs::mtable::LocationType::Global" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.read (| vtype |); + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| M.read (| value |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_global_get::GlobalGetConfig", + "memory_table_lookup_stack_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.read (| vtype |); + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| M.read (| value |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant!(-F::one())) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Neg", F, [], "neg", [] |), + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "one", [] |), + [] + |) + ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn mops(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, _: &EventTableEntry) -> u32 { + 1 + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Integer 1)) ] |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("sp_diff", InstanceField.Method (sp_diff F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_global_get_GlobalGetConfig_F. + End op_global_get. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_global_set.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_global_set.v new file mode 100644 index 000000000..dd3c90d1a --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_global_set.v @@ -0,0 +1,1682 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_global_set. + (* StructRecord + { + name := "GlobalSetConfig"; + ty_params := [ "F" ]; + fields := + [ + ("idx_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("is_i32_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("value_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("memory_table_lookup_stack_read", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_global_write", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "GlobalSetConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_global_set_GlobalSetConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_global_set::GlobalSetConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let is_i32_cell = allocator.alloc_bit_cell(); + let idx_cell = allocator.alloc_common_range_cell(); + let value_cell = allocator.alloc_u64_cell(); + + let sp_cell = common_config.sp_cell; + let eid_cell = common_config.eid_cell; + + let memory_table_lookup_stack_read = allocator.alloc_memory_table_lookup_read_cell( + "op_global_set stack read", + constraint_builder, + eid_cell, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp_cell.expr(meta) + constant_from!(1), + move |meta| is_i32_cell.expr(meta), + move |meta| value_cell.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + let memory_table_lookup_global_write = allocator.alloc_memory_table_lookup_write_cell( + "op_global_set global write", + constraint_builder, + eid_cell, + move |____| constant_from!(LocationType::Global as u64), + move |meta| idx_cell.expr(meta), + move |meta| is_i32_cell.expr(meta), + move |meta| value_cell.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + Box::new(GlobalSetConfig { + idx_cell, + is_i32_cell, + value_cell, + memory_table_lookup_stack_read, + memory_table_lookup_global_write, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let is_i32_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let idx_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let value_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let sp_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let eid_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let memory_table_lookup_stack_read := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_global_set stack read" |); + M.read (| constraint_builder |); + M.read (| eid_cell |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp_cell; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value_cell, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_global_write := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_global_set global write" |); + M.read (| constraint_builder |); + M.read (| eid_cell |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Global_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ idx_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value_cell, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_global_set::GlobalSetConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_global_set::GlobalSetConfig" + [ + ("idx_cell", M.read (| idx_cell |)); + ("is_i32_cell", M.read (| is_i32_cell |)); + ("value_cell", M.read (| value_cell |)); + ("memory_table_lookup_stack_read", + M.read (| memory_table_lookup_stack_read |)); + ("memory_table_lookup_global_write", + M.read (| memory_table_lookup_global_write |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_global_set_GlobalSetConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_global_set_GlobalSetConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_global_set::GlobalSetConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + encode_global_set(self.idx_cell.expr(meta)) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_function (| + "specs::encode::opcode::encode_global_set", + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_global_set::GlobalSetConfig", + "idx_cell" + |); + M.read (| meta |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::SetGlobal { + idx, vtype, value, .. + } => { + self.idx_cell.assign(ctx, F::from( *idx as u64))?; + self.is_i32_cell.assign(ctx, F::from( *vtype as u64))?; + self.value_cell.assign(ctx, *value)?; + + self.memory_table_lookup_stack_read.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + *vtype == VarType::I32, + *value, + )?; + + self.memory_table_lookup_global_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + *idx, + LocationType::Global, + *vtype == VarType::I32, + *value, + )?; + + Ok(()) + } + + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::SetGlobal", + "idx" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::SetGlobal", + "vtype" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::SetGlobal", + "value" + |) in + let idx := M.alloc (| γ1_0 |) in + let vtype := M.alloc (| γ1_1 |) in + let value := M.alloc (| γ1_2 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_global_set::GlobalSetConfig", + "idx_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| idx |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_global_set::GlobalSetConfig", + "is_i32_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| vtype |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_global_set::GlobalSetConfig", + "value_cell" + |); + M.read (| ctx |); + M.read (| M.read (| value |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_global_set::GlobalSetConfig", + "memory_table_lookup_stack_read" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.read (| vtype |); + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| M.read (| value |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_global_set::GlobalSetConfig", + "memory_table_lookup_global_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + M.read (| M.read (| idx |) |); + Value.StructTuple + "specs::mtable::LocationType::Global" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.read (| vtype |); + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| M.read (| value |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant!(F::one())) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "one", [] |), + [] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn mops(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, _: &EventTableEntry) -> u32 { + 1 + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Integer 1)) ] |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("sp_diff", InstanceField.Method (sp_diff F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_global_set_GlobalSetConfig_F. + End op_global_set. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_load.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_load.v new file mode 100644 index 000000000..0ea1fca2b --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_load.v @@ -0,0 +1,12503 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_load. + (* StructRecord + { + name := "LoadConfig"; + ty_params := [ "F" ]; + fields := + [ + ("opcode_load_offset", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") [ F ]); + ("load_block_index", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") [ F ]); + ("load_inner_pos", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") [ F ]); + ("load_inner_pos_diff", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") [ F ]); + ("is_cross_block", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("cross_block_rem", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("cross_block_rem_diff", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("load_tailing", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("load_tailing_diff", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("load_picked", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("load_leading", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("load_picked_leading_u16", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("load_picked_leading_u16_u8_high", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") [ F ]); + ("load_picked_leading_u16_u8_low", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") [ F ]); + ("load_picked_flag", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("load_picked_leading_u8_rem", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("load_picked_leading_u8_rem_diff", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("res", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("is_one_byte", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_two_bytes", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_four_bytes", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_eight_bytes", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("bytes", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("len_modulus", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("is_sign", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_i32", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("memory_table_lookup_stack_read", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_heap_read1", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_heap_read2", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_write", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]); + ("lookup_pow_modulus", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("lookup_pow_power", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("address_within_allocated_pages_helper", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("degree_helper", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]) + ]; + } *) + + (* StructTuple + { + name := "LoadConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_load_LoadConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let opcode_load_offset = allocator.alloc_u32_cell(); + + // which heap offset to load + let load_block_index = allocator.alloc_u32_cell(); + let load_inner_pos = allocator.alloc_u8_cell(); + let load_inner_pos_diff = allocator.alloc_u8_cell(); + let is_cross_block = allocator.alloc_bit_cell(); + let cross_block_rem = allocator.alloc_common_range_cell(); + let cross_block_rem_diff = allocator.alloc_common_range_cell(); + + let is_one_byte = allocator.alloc_bit_cell(); + let is_two_bytes = allocator.alloc_bit_cell(); + let is_four_bytes = allocator.alloc_bit_cell(); + let is_eight_bytes = allocator.alloc_bit_cell(); + let bytes = allocator.alloc_unlimited_cell(); + let len_modulus = allocator.alloc_unlimited_cell(); + + let load_tailing = allocator.alloc_u64_cell(); + let load_tailing_diff = allocator.alloc_u64_cell(); + let load_picked = allocator.alloc_u64_cell(); + let load_leading = allocator.alloc_u64_cell(); + + let lookup_pow_modulus = common_config.pow_table_lookup_modulus_cell; + + let load_picked_leading_u16 = allocator.alloc_unlimited_cell(); + let load_picked_leading_u16_u8_high = allocator.alloc_u8_cell(); + let load_picked_leading_u16_u8_low = allocator.alloc_u8_cell(); + + let load_picked_flag = allocator.alloc_bit_cell(); + let load_picked_leading_u8_rem = allocator.alloc_common_range_cell(); + let load_picked_leading_u8_rem_diff = allocator.alloc_common_range_cell(); + + // value after extension + let res = allocator.alloc_unlimited_cell(); + + let is_sign = allocator.alloc_bit_cell(); + let is_i32 = allocator.alloc_bit_cell(); + + let degree_helper = allocator.alloc_bit_cell(); + + let sp = common_config.sp_cell; + let eid = common_config.eid_cell; + + let memory_table_lookup_stack_read = allocator + .alloc_memory_table_lookup_read_cell_with_value( + "load read offset", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |____| constant_from!(1), + move |____| constant_from!(1), + ); + + let memory_table_lookup_heap_read1 = allocator + .alloc_memory_table_lookup_read_cell_with_value( + "load read data1", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Heap as u64), + move |meta| load_block_index.expr(meta), + move |____| constant_from!(0), + move |____| constant_from!(1), + ); + + let memory_table_lookup_heap_read2 = allocator + .alloc_memory_table_lookup_read_cell_with_value( + "load read data2", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Heap as u64), + move |meta| load_block_index.expr(meta) + constant_from!(1), + move |____| constant_from!(0), + move |meta| is_cross_block.expr(meta), + ); + + let memory_table_lookup_stack_write = allocator.alloc_memory_table_lookup_write_cell( + "load write res", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |meta| is_i32.expr(meta), + move |meta| res.expr(meta), + move |____| constant_from!(1), + ); + + let load_base = memory_table_lookup_stack_read.value_cell; + let load_value_in_heap1 = memory_table_lookup_heap_read1.value_cell; + let load_value_in_heap2 = memory_table_lookup_heap_read2.value_cell; + + constraint_builder.push( + "op_load length", + Box::new(move |meta| { + vec![ + is_one_byte.expr(meta) + + is_two_bytes.expr(meta) + + is_four_bytes.expr(meta) + + is_eight_bytes.expr(meta) + - constant_from!(1), + ] + }), + ); + + constraint_builder.push( + "op_load bytes", + Box::new(move |meta| { + vec![ + bytes.expr(meta) + - constant_from!(1) + - is_two_bytes.expr(meta) + - constant_from!(3) * is_four_bytes.expr(meta) + - constant_from!(7) * is_eight_bytes.expr(meta), + ] + }), + ); + + constraint_builder.push( + "op_load load_block_index", + Box::new(move |meta| { + vec![ + load_block_index.expr(meta) * constant_from!(WASM_BLOCK_BYTE_SIZE) + + load_inner_pos.expr(meta) + - opcode_load_offset.expr(meta) + - load_base.expr(meta), + load_inner_pos.expr(meta) + load_inner_pos_diff.expr(meta) - constant_from!(7), + ] + }), + ); + + constraint_builder.push( + "op_load cross_block", + Box::new(move |meta| { + vec![ + is_cross_block.expr(meta) * constant_from!(WASM_BLOCK_BYTE_SIZE) + + cross_block_rem.expr(meta) + - load_inner_pos.expr(meta) + - bytes.expr(meta) + + constant_from!(1), + cross_block_rem.expr(meta) + cross_block_rem_diff.expr(meta) + - constant_from!(WASM_BLOCK_BYTE_SIZE - 1), + (is_cross_block.expr(meta) - constant_from!(1)) + * load_value_in_heap2.expr(meta), + ] + }), + ); + + constraint_builder.push( + "op_load pick value", + Box::new(move |meta| { + vec![ + len_modulus.expr(meta) + - is_one_byte.expr(meta) * constant_from!(1u64 << 8) + - is_two_bytes.expr(meta) * constant_from!(1u64 << 16) + - is_four_bytes.expr(meta) * constant_from!(1u64 << 32) + - is_eight_bytes.expr(meta) + * constant_from_bn!(&(BigUint::from(1u64) << 64)), + load_tailing.expr(meta) + + load_picked.expr(meta) * lookup_pow_modulus.expr(meta) + + load_leading.expr(meta) + * lookup_pow_modulus.expr(meta) + * len_modulus.expr(meta) + - load_value_in_heap1.expr(meta) + - load_value_in_heap2.expr(meta) + * constant_from_bn!(&(BigUint::from(1u64) << 64)), + load_tailing.expr(meta) + load_tailing_diff.expr(meta) + constant_from!(1) + - lookup_pow_modulus.expr(meta), + ] + }), + ); + + constraint_builder.push( + "op_load pick value size check", + Box::new(move |meta| { + vec![ + is_four_bytes.expr(meta) + * (load_picked.u16_cells_le[2].expr(meta) + + load_picked.u16_cells_le[3].expr(meta)), + is_two_bytes.expr(meta) + * (load_picked.expr(meta) - load_picked_leading_u16.expr(meta)), + is_one_byte.expr(meta) + * (load_picked.expr(meta) - load_picked_leading_u16_u8_low.expr(meta)), + ] + }), + ); + + constraint_builder.push( + "op_load pick u16 decompose1", + Box::new(move |meta| { + vec![ + load_picked_leading_u16.expr(meta) + - (is_two_bytes.expr(meta) + is_one_byte.expr(meta)) + * load_picked.u16_cells_le[0].expr(meta) + - is_four_bytes.expr(meta) * load_picked.u16_cells_le[1].expr(meta) + - is_eight_bytes.expr(meta) * load_picked.u16_cells_le[3].expr(meta), + ] + }), + ); + + constraint_builder.push( + "op_load pick u16 decompose2", + Box::new(move |meta| { + vec![ + load_picked_leading_u16_u8_high.expr(meta) * constant_from!(1 << 8) + + load_picked_leading_u16_u8_low.expr(meta) + - load_picked_leading_u16.expr(meta), + ] + }), + ); + + constraint_builder.push( + "op_load flag", + Box::new(move |meta| { + let value_leading_u8 = is_one_byte.expr(meta) + * load_picked_leading_u16_u8_low.expr(meta) + + (constant_from!(1) - is_one_byte.expr(meta)) + * load_picked_leading_u16_u8_high.expr(meta); + + vec![ + load_picked_flag.expr(meta) * constant_from!(128) + + load_picked_leading_u8_rem.expr(meta) + - value_leading_u8, + load_picked_leading_u8_rem.expr(meta) + + load_picked_leading_u8_rem_diff.expr(meta) + - constant_from!(127), + ] + }), + ); + + constraint_builder.push( + "op_load extension", + Box::new(move |meta| { + vec![ + load_picked_flag.expr(meta) * is_sign.expr(meta) - degree_helper.expr(meta), + degree_helper.expr(meta) + * (is_one_byte.expr(meta) * constant_from!(0xffffff00) + + is_two_bytes.expr(meta) * constant_from!(0xffff0000) + + (constant_from!(1) - is_eight_bytes.expr(meta)) + * (constant_from!(1) - is_i32.expr(meta)) + * constant_from!(0xffffffff00000000)) + + load_picked.expr(meta) + - res.expr(meta), + ] + }), + ); + + let lookup_pow_power = common_config.pow_table_lookup_power_cell; + + constraint_builder.push( + "op_load pos_modulus", + Box::new(move |meta| { + vec![ + lookup_pow_power.expr(meta) + - pow_table_power_encode(load_inner_pos.expr(meta) * constant_from!(8)), + ] + }), + ); + + let current_memory_page_size = common_config.mpages_cell; + + let address_within_allocated_pages_helper = allocator.alloc_common_range_cell(); + constraint_builder.push( + "op_load allocated address", + Box::new(move |meta| { + vec![ + (load_block_index.expr(meta) + + is_cross_block.expr(meta) + + constant_from!(1) + + address_within_allocated_pages_helper.expr(meta) + - current_memory_page_size.expr(meta) + * constant_from!(WASM_BLOCKS_PER_PAGE)), + ] + }), + ); + + Box::new(LoadConfig { + opcode_load_offset, + load_block_index, + load_inner_pos, + load_inner_pos_diff, + is_cross_block, + cross_block_rem, + cross_block_rem_diff, + load_tailing, + load_picked, + load_leading, + load_picked_leading_u16, + load_picked_leading_u16_u8_high, + load_picked_leading_u16_u8_low, + load_picked_flag, + load_picked_leading_u8_rem, + load_picked_leading_u8_rem_diff, + res, + is_one_byte, + is_two_bytes, + is_four_bytes, + is_eight_bytes, + bytes, + len_modulus, + is_sign, + is_i32, + memory_table_lookup_stack_read, + memory_table_lookup_heap_read1, + memory_table_lookup_heap_read2, + memory_table_lookup_stack_write, + lookup_pow_power, + address_within_allocated_pages_helper, + lookup_pow_modulus, + load_tailing_diff, + + degree_helper, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let opcode_load_offset := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u32_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let load_block_index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u32_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let load_inner_pos := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u8_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let load_inner_pos_diff := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u8_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_cross_block := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let cross_block_rem := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let cross_block_rem_diff := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_one_byte := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_two_bytes := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_four_bytes := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_eight_bytes := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let bytes := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let len_modulus := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let load_tailing := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let load_tailing_diff := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let load_picked := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let load_leading := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let lookup_pow_modulus := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "pow_table_lookup_modulus_cell" + |) + |) in + let load_picked_leading_u16 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let load_picked_leading_u16_u8_high := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u8_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let load_picked_leading_u16_u8_low := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u8_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let load_picked_flag := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let load_picked_leading_u8_rem := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let load_picked_leading_u8_rem_diff := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let res := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_sign := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_i32 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let degree_helper := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let memory_table_lookup_stack_read := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell_with_value", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "load read offset" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_heap_read1 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell_with_value", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "load read data1" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Heap_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "expr", + [] + |), + [ load_block_index; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 0 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_heap_read2 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell_with_value", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "load read data2" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Heap_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "expr", + [] + |), + [ load_block_index; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 0 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_cross_block; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_write := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "load write res" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ res; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let load_base := + M.copy (| + M.SubPointer.get_struct_record_field (| + memory_table_lookup_stack_read, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "value_cell" + |) + |) in + let load_value_in_heap1 := + M.copy (| + M.SubPointer.get_struct_record_field (| + memory_table_lookup_heap_read1, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "value_cell" + |) + |) in + let load_value_in_heap2 := + M.copy (| + M.SubPointer.get_struct_record_field (| + memory_table_lookup_heap_read2, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "value_cell" + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_load length" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_one_byte; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_two_bytes; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_four_bytes; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_eight_bytes; + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_load bytes" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + bytes; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_two_bytes; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 3 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_four_bytes; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 7 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_eight_bytes; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_load load_block_index" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "expr", + [] + |), + [ + load_block_index; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::utils::WASM_BLOCK_BYTE_SIZE" + |) + |)) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_inner_pos; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "expr", + [] + |), + [ + opcode_load_offset; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_base; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_inner_pos; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_inner_pos_diff; + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 7 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_load cross_block" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_cross_block; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::utils::WASM_BLOCK_BYTE_SIZE" + |) + |)) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + cross_block_rem; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_inner_pos; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + bytes; + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + cross_block_rem; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + cross_block_rem_diff; + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.sub (| + Integer.U32, + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::utils::WASM_BLOCK_BYTE_SIZE" + |) + |), + Value.Integer 1 + |)) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_cross_block; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_value_in_heap2; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_load pick value" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + len_modulus; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_one_byte; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 8 + |) + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_two_bytes; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 16 + |) + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_four_bytes; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 32 + |) + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_eight_bytes; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "i32" + ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + Value.Integer + 1 + ] + |); + Value.Integer + 64 + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + load_tailing; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + load_picked; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + lookup_pow_modulus; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + load_leading; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + lookup_pow_modulus; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + len_modulus; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_value_in_heap1; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_value_in_heap2; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "i32" + ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + Value.Integer + 1 + ] + |); + Value.Integer + 64 + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + load_tailing; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + load_tailing_diff; + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + lookup_pow_modulus; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_load pick value size check" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_four_bytes; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + load_picked, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| + Value.Integer 2 + |) + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + load_picked, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| + Value.Integer 3 + |) + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_two_bytes; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + load_picked; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_picked_leading_u16; + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_one_byte; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + load_picked; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_picked_leading_u16_u8_low; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_load pick u16 decompose1" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_picked_leading_u16; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_two_bytes; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_one_byte; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + load_picked, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| + Value.Integer + 0 + |) + |); + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_four_bytes; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + load_picked, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| + Value.Integer + 1 + |) + |); + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_eight_bytes; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + load_picked, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| + Value.Integer 3 + |) + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_load pick u16 decompose2" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_picked_leading_u16_u8_high; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 8 + |)) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_picked_leading_u16_u8_low; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_picked_leading_u16; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_load flag" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let value_leading_u8 := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_one_byte; M.read (| meta |) ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_picked_leading_u16_u8_low; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer 1 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_one_byte; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_picked_leading_u16_u8_high; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_picked_flag; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 128 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_picked_leading_u8_rem; + M.read (| + meta + |) + ] + |) + ] + |); + M.read (| + value_leading_u8 + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_picked_leading_u8_rem; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_picked_leading_u8_rem_diff; + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 127 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_load extension" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_picked_flag; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_sign; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + degree_helper; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + degree_helper; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ + F + ], + [ F + ], + "expr", + [] + |), + [ + is_one_byte; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 4294967040 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ + F + ], + [ F + ], + "expr", + [] + |), + [ + is_two_bytes; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 4294901760 + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ + F + ], + [ + F + ], + "expr", + [] + |), + [ + is_eight_bytes; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ + F + ], + [ + F + ], + "expr", + [] + |), + [ + is_i32; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 18446744069414584320 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + load_picked; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ res; M.read (| meta |) ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let lookup_pow_power := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "pow_table_lookup_power_cell" + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_load pos_modulus" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + lookup_pow_power; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::rtable::pow_table_power_encode", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_inner_pos; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 8 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let current_memory_page_size := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "mpages_cell" + |) + |) in + let address_within_allocated_pages_helper := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_load allocated address" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "expr", + [] + |), + [ + load_block_index; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_cross_block; + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + address_within_allocated_pages_helper; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + current_memory_page_size; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::utils::WASM_BLOCKS_PER_PAGE" + |) + |)) + ] + |) + ] + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig" + [ + ("opcode_load_offset", M.read (| opcode_load_offset |)); + ("load_block_index", M.read (| load_block_index |)); + ("load_inner_pos", M.read (| load_inner_pos |)); + ("load_inner_pos_diff", M.read (| load_inner_pos_diff |)); + ("is_cross_block", M.read (| is_cross_block |)); + ("cross_block_rem", M.read (| cross_block_rem |)); + ("cross_block_rem_diff", M.read (| cross_block_rem_diff |)); + ("load_tailing", M.read (| load_tailing |)); + ("load_picked", M.read (| load_picked |)); + ("load_leading", M.read (| load_leading |)); + ("load_picked_leading_u16", M.read (| load_picked_leading_u16 |)); + ("load_picked_leading_u16_u8_high", + M.read (| load_picked_leading_u16_u8_high |)); + ("load_picked_leading_u16_u8_low", + M.read (| load_picked_leading_u16_u8_low |)); + ("load_picked_flag", M.read (| load_picked_flag |)); + ("load_picked_leading_u8_rem", + M.read (| load_picked_leading_u8_rem |)); + ("load_picked_leading_u8_rem_diff", + M.read (| load_picked_leading_u8_rem_diff |)); + ("res", M.read (| res |)); + ("is_one_byte", M.read (| is_one_byte |)); + ("is_two_bytes", M.read (| is_two_bytes |)); + ("is_four_bytes", M.read (| is_four_bytes |)); + ("is_eight_bytes", M.read (| is_eight_bytes |)); + ("bytes", M.read (| bytes |)); + ("len_modulus", M.read (| len_modulus |)); + ("is_sign", M.read (| is_sign |)); + ("is_i32", M.read (| is_i32 |)); + ("memory_table_lookup_stack_read", + M.read (| memory_table_lookup_stack_read |)); + ("memory_table_lookup_heap_read1", + M.read (| memory_table_lookup_heap_read1 |)); + ("memory_table_lookup_heap_read2", + M.read (| memory_table_lookup_heap_read2 |)); + ("memory_table_lookup_stack_write", + M.read (| memory_table_lookup_stack_write |)); + ("lookup_pow_power", M.read (| lookup_pow_power |)); + ("address_within_allocated_pages_helper", + M.read (| address_within_allocated_pages_helper |)); + ("lookup_pow_modulus", M.read (| lookup_pow_modulus |)); + ("load_tailing_diff", M.read (| load_tailing_diff |)); + ("degree_helper", M.read (| degree_helper |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_load_LoadConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_load_LoadConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + let load_size = self.is_eight_bytes.expr(meta) * constant_from!(6) + + self.is_four_bytes.expr(meta) * constant_from!(4) + + self.is_two_bytes.expr(meta) * constant_from!(2) + + self.is_sign.expr(meta) + + constant_from!(1); + + constant!(bn_to_field( + &(BigUint::from(OpcodeClass::Load as u64) << OPCODE_CLASS_SHIFT) + )) + self.is_i32.expr(meta) + * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG0_SHIFT))) + + load_size * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG1_SHIFT))) + + self.opcode_load_offset.expr(meta) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.read (| + let load_size := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "is_eight_bytes" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 6 |)) |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "is_four_bytes" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 4 |)) |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "is_two_bytes" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 2 |)) |) ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "is_sign" + |); + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 23 + |)) + ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_CLASS_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "is_i32" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| load_size |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG1_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "opcode_load_offset" + |); + M.read (| meta |) + ] + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match entry.eentry.step_info { + StepInfo::Load { + vtype, + load_size, + offset, + raw_address, + effective_address, + value, + block_value1, + block_value2, + } => { + let len = load_size.byte_size(); + + self.opcode_load_offset.assign(ctx, offset)?; + + let inner_byte_index = byte_offset_from_address(effective_address); + let block_start_index = block_from_address(effective_address); + + self.load_block_index.assign(ctx, block_start_index)?; + self.load_inner_pos.assign_u32(ctx, inner_byte_index)?; + self.load_inner_pos_diff + .assign_u32(ctx, WASM_BLOCK_BYTE_SIZE - 1 - inner_byte_index)?; + + let pos_modulus = 1 << (inner_byte_index * 8); + self.lookup_pow_modulus.assign(ctx, pos_modulus.into())?; + self.lookup_pow_power.assign_bn( + ctx, + &pow_table_power_encode(BigUint::from(inner_byte_index * 8)), + )?; + + let is_cross_block = inner_byte_index + len > WASM_BLOCK_BYTE_SIZE; + self.is_cross_block.assign_bool(ctx, is_cross_block)?; + let rem = (inner_byte_index + len - 1) & WASM_BLOCK_BYTE_OFFSET_MASK; + self.cross_block_rem.assign_u32(ctx, rem)?; + self.cross_block_rem_diff + .assign_u32(ctx, WASM_BLOCK_BYTE_SIZE - 1 - rem)?; + + let tailing_bits = inner_byte_index * 8; + let picked_bits = len * 8; + let load_value: BigUint = (BigUint::from(block_value2) << 64) + block_value1; + let tailing: u64 = load_value.to_u64_digits().first().unwrap_or(&0u64).clone() + & ((1 << tailing_bits) - 1); + let picked: u64 = ((&load_value >> tailing_bits) + & ((BigUint::from(1u64) << picked_bits) - 1u64)) + .to_u64_digits() + .first() + .unwrap_or(&0u64) + .clone(); + let leading: u64 = (load_value >> (picked_bits + tailing_bits)) + .to_u64_digits() + .first() + .unwrap_or(&0u64) + .clone(); + + self.load_tailing.assign(ctx, tailing)?; + self.load_tailing_diff + .assign(ctx, pos_modulus - 1 - tailing)?; + self.load_picked.assign(ctx, picked)?; + self.load_leading.assign(ctx, leading)?; + + let load_picked_leading_u16 = if len == 1 { + picked + } else { + picked >> (8 * (len - 2)) + }; + self.load_picked_leading_u16 + .assign(ctx, load_picked_leading_u16.into())?; + self.load_picked_leading_u16_u8_high + .assign(ctx, (load_picked_leading_u16 >> 8).into())?; + self.load_picked_leading_u16_u8_low + .assign(ctx, (load_picked_leading_u16 & 0xff).into())?; + + let load_picked_leading_u8 = if len == 1 { + load_picked_leading_u16 & 0xff + } else { + load_picked_leading_u16 >> 8 + }; + self.load_picked_flag + .assign(ctx, (load_picked_leading_u8 >> 7).into())?; + self.load_picked_leading_u8_rem + .assign(ctx, (load_picked_leading_u8 & 0x7f).into())?; + self.load_picked_leading_u8_rem_diff + .assign(ctx, (0x7f - (load_picked_leading_u8 & 0x7f)).into())?; + + self.res.assign(ctx, value.into())?; + + self.is_one_byte.assign_bool(ctx, len == 1)?; + self.is_two_bytes.assign_bool(ctx, len == 2)?; + self.is_four_bytes.assign_bool(ctx, len == 4)?; + self.is_eight_bytes.assign_bool(ctx, len == 8)?; + self.bytes.assign(ctx, (len as u64).into())?; + self.len_modulus + .assign_bn(ctx, &(BigUint::from(1u64) << (len * 8)))?; + + self.is_sign.assign_bool(ctx, load_size.is_sign())?; + self.is_i32.assign_bool(ctx, vtype == VarType::I32)?; + + self.degree_helper.assign( + ctx, + F::from(load_size.is_sign()) * F::from(load_picked_leading_u8 >> 7), + )?; + + self.address_within_allocated_pages_helper.assign_u32( + ctx, + step.current.allocated_memory_pages * WASM_BLOCKS_PER_PAGE + - (block_start_index + is_cross_block as u32 + 1), + )?; + + let mut i = 0; + self.memory_table_lookup_stack_read.assign( + ctx, + entry.memory_rw_entires[i].start_eid, + step.current.eid, + entry.memory_rw_entires[i].end_eid, + step.current.sp + 1, + LocationType::Stack, + true, + raw_address as u64, + )?; + i += 1; + + self.memory_table_lookup_heap_read1.assign( + ctx, + entry.memory_rw_entires[i].start_eid, + step.current.eid, + entry.memory_rw_entires[i].end_eid, + effective_address >> 3, + LocationType::Heap, + false, + block_value1, + )?; + i += 1; + + if is_cross_block { + self.memory_table_lookup_heap_read2.assign( + ctx, + entry.memory_rw_entires[i].start_eid, + step.current.eid, + entry.memory_rw_entires[i].end_eid, + (effective_address >> 3) + 1, + LocationType::Heap, + false, + block_value2, + )?; + i += 1; + } + + self.memory_table_lookup_stack_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[i].end_eid, + step.current.sp + 1, + LocationType::Stack, + vtype == VarType::I32, + value, + )?; + + Ok(()) + } + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Load", + "vtype" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Load", + "load_size" + |) in + let γ0_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Load", + "offset" + |) in + let γ0_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Load", + "raw_address" + |) in + let γ0_4 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Load", + "effective_address" + |) in + let γ0_5 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Load", + "value" + |) in + let γ0_6 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Load", + "block_value1" + |) in + let γ0_7 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Load", + "block_value2" + |) in + let vtype := M.copy (| γ0_0 |) in + let load_size := M.copy (| γ0_1 |) in + let offset := M.copy (| γ0_2 |) in + let raw_address := M.copy (| γ0_3 |) in + let effective_address := M.copy (| γ0_4 |) in + let value := M.copy (| γ0_5 |) in + let block_value1 := M.copy (| γ0_6 |) in + let block_value2 := M.copy (| γ0_7 |) in + let len := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::mtable::MemoryReadSize", + "byte_size", + [] + |), + [ load_size ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "opcode_load_offset" + |); + M.read (| ctx |); + M.read (| offset |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let inner_byte_index := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::mtable::utils::byte_offset_from_address", + [] + |), + [ M.read (| effective_address |) ] + |) + |) in + let block_start_index := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::mtable::utils::block_from_address", + [] + |), + [ M.read (| effective_address |) ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "load_block_index" + |); + M.read (| ctx |); + M.read (| block_start_index |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "load_inner_pos" + |); + M.read (| ctx |); + M.read (| inner_byte_index |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "load_inner_pos_diff" + |); + M.read (| ctx |); + BinOp.Panic.sub (| + Integer.U32, + BinOp.Panic.sub (| + Integer.U32, + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::utils::WASM_BLOCK_BYTE_SIZE" + |) + |), + Value.Integer 1 + |), + M.read (| inner_byte_index |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let pos_modulus := + M.alloc (| + BinOp.Panic.shl (| + Value.Integer 1, + BinOp.Panic.mul (| + Integer.U32, + M.read (| inner_byte_index |), + Value.Integer 8 + |) + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "lookup_pow_modulus" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| pos_modulus |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_bn", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "lookup_pow_power" + |); + M.read (| ctx |); + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::rtable::pow_table_power_encode", + [ Ty.path "num_bigint::biguint::BigUint" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "from", + [] + |), + [ + BinOp.Panic.mul (| + Integer.U32, + M.read (| inner_byte_index |), + Value.Integer 8 + |) + ] + |) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let is_cross_block := + M.alloc (| + BinOp.Pure.gt + (BinOp.Panic.add (| + Integer.U32, + M.read (| inner_byte_index |), + M.read (| len |) + |)) + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::utils::WASM_BLOCK_BYTE_SIZE" + |) + |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "is_cross_block" + |); + M.read (| ctx |); + M.read (| is_cross_block |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let rem := + M.alloc (| + BinOp.Pure.bit_and + (BinOp.Panic.sub (| + Integer.U32, + BinOp.Panic.add (| + Integer.U32, + M.read (| inner_byte_index |), + M.read (| len |) + |), + Value.Integer 1 + |)) + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::utils::WASM_BLOCK_BYTE_OFFSET_MASK" + |) + |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "cross_block_rem" + |); + M.read (| ctx |); + M.read (| rem |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "cross_block_rem_diff" + |); + M.read (| ctx |); + BinOp.Panic.sub (| + Integer.U32, + BinOp.Panic.sub (| + Integer.U32, + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::utils::WASM_BLOCK_BYTE_SIZE" + |) + |), + Value.Integer 1 + |), + M.read (| rem |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let tailing_bits := + M.alloc (| + BinOp.Panic.mul (| + Integer.U32, + M.read (| inner_byte_index |), + Value.Integer 8 + |) + |) in + let picked_bits := + M.alloc (| + BinOp.Panic.mul (| + Integer.U32, + M.read (| len |), + Value.Integer 8 + |) + |) in + let load_value := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "i32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| block_value2 |) ] + |); + Value.Integer 64 + ] + |); + M.read (| block_value1 |) + ] + |) + |) in + let tailing := + M.alloc (| + BinOp.Pure.bit_and + (M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "u64", + [], + "clone", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.path "u64" ] ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u64" ], + "first", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "num_bigint::biguint::BigUint", + "to_u64_digits", + [] + |), + [ load_value ] + |) + |) + ] + |) + ] + |); + M.alloc (| Value.Integer 0 |) + ] + |) + ] + |)) + (BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.shl (| + Value.Integer 1, + M.read (| tailing_bits |) + |), + Value.Integer 1 + |)) + |) in + let picked := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "u64", + [], + "clone", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.path "u64" ] ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u64" ], + "first", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "num_bigint::biguint::BigUint", + "to_u64_digits", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::BitAnd", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "bitand", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shr", + Ty.apply + (Ty.path "&") + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + [ Ty.path "u32" ], + "shr", + [] + |), + [ + load_value; + M.read (| tailing_bits |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| picked_bits |) + ] + |); + Value.Integer 1 + ] + |) + ] + |) + |) + ] + |) + |) + ] + |) + ] + |); + M.alloc (| Value.Integer 0 |) + ] + |) + ] + |) + |) in + let leading := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "u64", + [], + "clone", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.path "u64" ] ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u64" ], + "first", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "num_bigint::biguint::BigUint", + "to_u64_digits", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shr", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shr", + [] + |), + [ + M.read (| load_value |); + BinOp.Panic.add (| + Integer.U32, + M.read (| picked_bits |), + M.read (| tailing_bits |) + |) + ] + |) + |) + ] + |) + |) + ] + |) + ] + |); + M.alloc (| Value.Integer 0 |) + ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "load_tailing" + |); + M.read (| ctx |); + M.read (| tailing |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "load_tailing_diff" + |); + M.read (| ctx |); + BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.sub (| + Integer.U64, + M.read (| pos_modulus |), + Value.Integer 1 + |), + M.read (| tailing |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "load_picked" + |); + M.read (| ctx |); + M.read (| picked |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "load_leading" + |); + M.read (| ctx |); + M.read (| leading |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let load_picked_leading_u16 := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq (M.read (| len |)) (Value.Integer 1) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + picked)); + fun γ => + ltac:(M.monadic + (M.alloc (| + BinOp.Panic.shr (| + M.read (| picked |), + BinOp.Panic.mul (| + Integer.U32, + Value.Integer 8, + BinOp.Panic.sub (| + Integer.U32, + M.read (| len |), + Value.Integer 2 + |) + |) + |) + |))) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "load_picked_leading_u16" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| load_picked_leading_u16 |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "load_picked_leading_u16_u8_high" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ + BinOp.Panic.shr (| + M.read (| load_picked_leading_u16 |), + Value.Integer 8 + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "load_picked_leading_u16_u8_low" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ + BinOp.Pure.bit_and + (M.read (| load_picked_leading_u16 |)) + (Value.Integer 255) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let load_picked_leading_u8 := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq (M.read (| len |)) (Value.Integer 1) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + BinOp.Pure.bit_and + (M.read (| load_picked_leading_u16 |)) + (Value.Integer 255) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + BinOp.Panic.shr (| + M.read (| load_picked_leading_u16 |), + Value.Integer 8 + |) + |))) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "load_picked_flag" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ + BinOp.Panic.shr (| + M.read (| load_picked_leading_u8 |), + Value.Integer 7 + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "load_picked_leading_u8_rem" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ + BinOp.Pure.bit_and + (M.read (| load_picked_leading_u8 |)) + (Value.Integer 127) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "load_picked_leading_u8_rem_diff" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ + BinOp.Panic.sub (| + Integer.U64, + Value.Integer 127, + BinOp.Pure.bit_and + (M.read (| load_picked_leading_u8 |)) + (Value.Integer 127) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "res" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| value |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "is_one_byte" + |); + M.read (| ctx |); + BinOp.Pure.eq (M.read (| len |)) (Value.Integer 1) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "is_two_bytes" + |); + M.read (| ctx |); + BinOp.Pure.eq (M.read (| len |)) (Value.Integer 2) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "is_four_bytes" + |); + M.read (| ctx |); + BinOp.Pure.eq (M.read (| len |)) (Value.Integer 4) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "is_eight_bytes" + |); + M.read (| ctx |); + BinOp.Pure.eq (M.read (| len |)) (Value.Integer 8) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "bytes" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.rust_cast (M.read (| len |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_bn", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "len_modulus" + |); + M.read (| ctx |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + BinOp.Panic.mul (| + Integer.U32, + M.read (| len |), + Value.Integer 8 + |) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "is_sign" + |); + M.read (| ctx |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::mtable::MemoryReadSize", + "is_sign", + [] + |), + [ load_size ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "is_i32" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + vtype; + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "degree_helper" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ F ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "bool" ], + "from", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::mtable::MemoryReadSize", + "is_sign", + [] + |), + [ load_size ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + BinOp.Panic.shr (| + M.read (| load_picked_leading_u8 |), + Value.Integer 7 + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "address_within_allocated_pages_helper" + |); + M.read (| ctx |); + BinOp.Panic.sub (| + Integer.U32, + BinOp.Panic.mul (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "allocated_memory_pages" + |) + |), + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::utils::WASM_BLOCKS_PER_PAGE" + |) + |) + |), + BinOp.Panic.add (| + Integer.U32, + BinOp.Panic.add (| + Integer.U32, + M.read (| block_start_index |), + M.rust_cast (M.read (| is_cross_block |)) + |), + Value.Integer 1 + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let i := M.alloc (| Value.Integer 0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "memory_table_lookup_stack_read" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + M.read (| i |) + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + M.read (| i |) + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool true; + M.rust_cast (M.read (| raw_address |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + let β := i in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "memory_table_lookup_heap_read1" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + M.read (| i |) + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + M.read (| i |) + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.shr (| + M.read (| effective_address |), + Value.Integer 3 + |); + Value.StructTuple + "specs::mtable::LocationType::Heap" + []; + Value.Bool false; + M.read (| block_value1 |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + let β := i in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use is_cross_block in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "memory_table_lookup_heap_read2" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + M.read (| i |) + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + M.read (| i |) + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + BinOp.Panic.shr (| + M.read (| effective_address |), + Value.Integer 3 + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Heap" + []; + Value.Bool false; + M.read (| block_value2 |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + let β := i in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_load::LoadConfig", + "memory_table_lookup_stack_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + M.read (| i |) + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + vtype; + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| value |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn mops(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, _: &EventTableEntry) -> u32 { + 1 + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Integer 1)) ] |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_load_LoadConfig_F. + End op_load. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_local_get.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_local_get.v new file mode 100644 index 000000000..fadf7c460 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_local_get.v @@ -0,0 +1,1837 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_local_get. + (* StructRecord + { + name := "LocalGetConfig"; + ty_params := [ "F" ]; + fields := + [ + ("offset_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("is_i32_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("value_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("memory_table_lookup_stack_read", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_write", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "LocalGetConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_local_get_LocalGetConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_local_get::LocalGetConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let is_i32_cell = allocator.alloc_bit_cell(); + let offset_cell = allocator.alloc_common_range_cell(); + let value_cell = allocator.alloc_u64_cell(); + + let sp_cell = common_config.sp_cell; + let eid_cell = common_config.eid_cell; + + let memory_table_lookup_stack_read = allocator.alloc_memory_table_lookup_read_cell( + "op_local_get stack read", + constraint_builder, + eid_cell, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp_cell.expr(meta) + offset_cell.expr(meta), + move |meta| is_i32_cell.expr(meta), + move |meta| value_cell.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + let memory_table_lookup_stack_write = allocator.alloc_memory_table_lookup_write_cell( + "op_local_get stack write", + constraint_builder, + eid_cell, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp_cell.expr(meta), + move |meta| is_i32_cell.expr(meta), + move |meta| value_cell.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + Box::new(LocalGetConfig { + offset_cell, + is_i32_cell, + value_cell, + memory_table_lookup_stack_read, + memory_table_lookup_stack_write, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let is_i32_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let offset_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let value_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let sp_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let eid_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let memory_table_lookup_stack_read := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_local_get stack read" |); + M.read (| constraint_builder |); + M.read (| eid_cell |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp_cell; M.read (| meta |) ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ offset_cell; M.read (| meta |) ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value_cell, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_write := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_local_get stack write" |); + M.read (| constraint_builder |); + M.read (| eid_cell |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value_cell, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_local_get::LocalGetConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_local_get::LocalGetConfig" + [ + ("offset_cell", M.read (| offset_cell |)); + ("is_i32_cell", M.read (| is_i32_cell |)); + ("value_cell", M.read (| value_cell |)); + ("memory_table_lookup_stack_read", + M.read (| memory_table_lookup_stack_read |)); + ("memory_table_lookup_stack_write", + M.read (| memory_table_lookup_stack_write |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_local_get_LocalGetConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_local_get_LocalGetConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_local_get::LocalGetConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + constant!(bn_to_field( + &(BigUint::from(OpcodeClass::LocalGet as u64) << OPCODE_CLASS_SHIFT) + )) + self.is_i32_cell.expr(meta) + * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG0_SHIFT))) + + self.offset_cell.expr(meta) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 0 + |)) + ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_CLASS_SHIFT" |) + |) + ] + |) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_get::LocalGetConfig", + "is_i32_cell" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_ARG0_SHIFT" |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_get::LocalGetConfig", + "offset_cell" + |); + M.read (| meta |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::GetLocal { + vtype, + depth, + value, + } => { + self.is_i32_cell.assign(ctx, F::from( *vtype as u64))?; + self.value_cell.assign(ctx, *value)?; + self.offset_cell.assign(ctx, F::from( *depth as u64))?; + + self.memory_table_lookup_stack_read.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + depth, + LocationType::Stack, + *vtype == VarType::I32, + *value, + )?; + + self.memory_table_lookup_stack_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + step.current.sp, + LocationType::Stack, + *vtype == VarType::I32, + *value, + )?; + + Ok(()) + } + + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::GetLocal", + "vtype" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::GetLocal", + "depth" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::GetLocal", + "value" + |) in + let vtype := M.alloc (| γ1_0 |) in + let depth := M.alloc (| γ1_1 |) in + let value := M.alloc (| γ1_2 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_get::LocalGetConfig", + "is_i32_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| vtype |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_get::LocalGetConfig", + "value_cell" + |); + M.read (| ctx |); + M.read (| M.read (| value |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_get::LocalGetConfig", + "offset_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| depth |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_get::LocalGetConfig", + "memory_table_lookup_stack_read" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.path "u32", + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ], + "add", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |); + M.read (| depth |) + ] + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.read (| vtype |); + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| M.read (| value |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_get::LocalGetConfig", + "memory_table_lookup_stack_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.read (| vtype |); + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| M.read (| value |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant!(-F::one())) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Neg", F, [], "neg", [] |), + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "one", [] |), + [] + |) + ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn mops(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, _: &EventTableEntry) -> u32 { + 1 + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Integer 1)) ] |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("sp_diff", InstanceField.Method (sp_diff F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_local_get_LocalGetConfig_F. + End op_local_get. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_local_set.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_local_set.v new file mode 100644 index 000000000..d8d52a00f --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_local_set.v @@ -0,0 +1,1914 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_local_set. + (* StructRecord + { + name := "LocalSetConfig"; + ty_params := [ "F" ]; + fields := + [ + ("offset_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("is_i32_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("value_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("memory_table_lookup_stack_read", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_write", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "LocalSetConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_local_set_LocalSetConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_local_set::LocalSetConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let is_i32_cell = allocator.alloc_bit_cell(); + let offset_cell = allocator.alloc_common_range_cell(); + let value_cell = allocator.alloc_u64_cell(); + + let sp_cell = common_config.sp_cell; + let eid_cell = common_config.eid_cell; + + let memory_table_lookup_stack_read = allocator.alloc_memory_table_lookup_read_cell( + "op_local_set stack read", + constraint_builder, + eid_cell, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp_cell.expr(meta) + constant_from!(1), + move |meta| is_i32_cell.expr(meta), + move |meta| value_cell.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + let memory_table_lookup_stack_write = allocator.alloc_memory_table_lookup_write_cell( + "op_local_set stack write", + constraint_builder, + eid_cell, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp_cell.expr(meta) + constant_from!(1) + offset_cell.expr(meta), + move |meta| is_i32_cell.expr(meta), + move |meta| value_cell.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + Box::new(LocalSetConfig { + offset_cell, + is_i32_cell, + value_cell, + memory_table_lookup_stack_read, + memory_table_lookup_stack_write, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let is_i32_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let offset_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let value_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let sp_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let eid_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let memory_table_lookup_stack_read := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_local_set stack read" |); + M.read (| constraint_builder |); + M.read (| eid_cell |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp_cell; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value_cell, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_write := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_local_set stack write" |); + M.read (| constraint_builder |); + M.read (| eid_cell |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp_cell; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ offset_cell; M.read (| meta |) ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value_cell, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_local_set::LocalSetConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_local_set::LocalSetConfig" + [ + ("offset_cell", M.read (| offset_cell |)); + ("is_i32_cell", M.read (| is_i32_cell |)); + ("value_cell", M.read (| value_cell |)); + ("memory_table_lookup_stack_read", + M.read (| memory_table_lookup_stack_read |)); + ("memory_table_lookup_stack_write", + M.read (| memory_table_lookup_stack_write |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_local_set_LocalSetConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_local_set_LocalSetConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_local_set::LocalSetConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + constant!(bn_to_field( + &(BigUint::from(OpcodeClass::LocalSet as u64) << OPCODE_CLASS_SHIFT) + )) + self.is_i32_cell.expr(meta) + * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG0_SHIFT))) + + self.offset_cell.expr(meta) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 1 + |)) + ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_CLASS_SHIFT" |) + |) + ] + |) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_set::LocalSetConfig", + "is_i32_cell" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_ARG0_SHIFT" |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_set::LocalSetConfig", + "offset_cell" + |); + M.read (| meta |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::SetLocal { + vtype, + depth, + value, + } => { + self.is_i32_cell.assign(ctx, F::from( *vtype as u64))?; + self.value_cell.assign(ctx, *value)?; + self.offset_cell.assign(ctx, F::from( *depth as u64))?; + + self.memory_table_lookup_stack_read.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + *vtype == VarType::I32, + *value, + )?; + + self.memory_table_lookup_stack_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + step.current.sp + 1 + depth, + LocationType::Stack, + *vtype == VarType::I32, + *value, + )?; + + Ok(()) + } + + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::SetLocal", + "vtype" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::SetLocal", + "depth" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::SetLocal", + "value" + |) in + let vtype := M.alloc (| γ1_0 |) in + let depth := M.alloc (| γ1_1 |) in + let value := M.alloc (| γ1_2 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_set::LocalSetConfig", + "is_i32_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| vtype |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_set::LocalSetConfig", + "value_cell" + |); + M.read (| ctx |); + M.read (| M.read (| value |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_set::LocalSetConfig", + "offset_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| depth |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_set::LocalSetConfig", + "memory_table_lookup_stack_read" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.read (| vtype |); + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| M.read (| value |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_set::LocalSetConfig", + "memory_table_lookup_stack_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.path "u32", + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ], + "add", + [] + |), + [ + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + M.read (| depth |) + ] + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.read (| vtype |); + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| M.read (| value |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant!(F::one())) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "one", [] |), + [] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn mops(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, _: &EventTableEntry) -> u32 { + 1 + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Integer 1)) ] |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("sp_diff", InstanceField.Method (sp_diff F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_local_set_LocalSetConfig_F. + End op_local_set. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_local_tee.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_local_tee.v new file mode 100644 index 000000000..8a1adf074 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_local_tee.v @@ -0,0 +1,1845 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_local_tee. + (* StructRecord + { + name := "LocalTeeConfig"; + ty_params := [ "F" ]; + fields := + [ + ("offset_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("is_i32_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("value_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("memory_table_lookup_stack_read", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_write", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "LocalTeeConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_local_tee_LocalTeeConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_local_tee::LocalTeeConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let is_i32_cell = allocator.alloc_bit_cell(); + let offset_cell = allocator.alloc_common_range_cell(); + let value_cell = allocator.alloc_u64_cell(); + + let sp_cell = common_config.sp_cell; + let eid_cell = common_config.eid_cell; + + let memory_table_lookup_stack_read = allocator.alloc_memory_table_lookup_read_cell( + "op_local_tee stack read", + constraint_builder, + eid_cell, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp_cell.expr(meta) + constant_from!(1), + move |meta| is_i32_cell.expr(meta), + move |meta| value_cell.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + let memory_table_lookup_stack_write = allocator.alloc_memory_table_lookup_write_cell( + "op_local_tee stack write", + constraint_builder, + eid_cell, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp_cell.expr(meta) + offset_cell.expr(meta), + move |meta| is_i32_cell.expr(meta), + move |meta| value_cell.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + Box::new(LocalTeeConfig { + offset_cell, + is_i32_cell, + value_cell, + memory_table_lookup_stack_read, + memory_table_lookup_stack_write, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let is_i32_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let offset_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let value_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let sp_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let eid_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let memory_table_lookup_stack_read := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_local_tee stack read" |); + M.read (| constraint_builder |); + M.read (| eid_cell |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp_cell; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value_cell, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_write := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_local_tee stack write" |); + M.read (| constraint_builder |); + M.read (| eid_cell |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp_cell; M.read (| meta |) ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ offset_cell; M.read (| meta |) ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value_cell, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_local_tee::LocalTeeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_local_tee::LocalTeeConfig" + [ + ("offset_cell", M.read (| offset_cell |)); + ("is_i32_cell", M.read (| is_i32_cell |)); + ("value_cell", M.read (| value_cell |)); + ("memory_table_lookup_stack_read", + M.read (| memory_table_lookup_stack_read |)); + ("memory_table_lookup_stack_write", + M.read (| memory_table_lookup_stack_write |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_local_tee_LocalTeeConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_local_tee_LocalTeeConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_local_tee::LocalTeeConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + constant!(bn_to_field( + &(BigUint::from(OpcodeClass::LocalTee as u64) << OPCODE_CLASS_SHIFT) + )) + self.is_i32_cell.expr(meta) + * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG0_SHIFT))) + + self.offset_cell.expr(meta) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 2 + |)) + ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_CLASS_SHIFT" |) + |) + ] + |) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_tee::LocalTeeConfig", + "is_i32_cell" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_ARG0_SHIFT" |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_tee::LocalTeeConfig", + "offset_cell" + |); + M.read (| meta |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::TeeLocal { + vtype, + depth, + value, + } => { + self.is_i32_cell.assign(ctx, F::from( *vtype as u64))?; + self.value_cell.assign(ctx, *value)?; + self.offset_cell.assign(ctx, F::from( *depth as u64))?; + + self.memory_table_lookup_stack_read.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + *vtype == VarType::I32, + *value, + )?; + + self.memory_table_lookup_stack_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + step.current.sp + depth, + LocationType::Stack, + *vtype == VarType::I32, + *value, + )?; + + Ok(()) + } + + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::TeeLocal", + "vtype" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::TeeLocal", + "depth" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::TeeLocal", + "value" + |) in + let vtype := M.alloc (| γ1_0 |) in + let depth := M.alloc (| γ1_1 |) in + let value := M.alloc (| γ1_2 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_tee::LocalTeeConfig", + "is_i32_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| vtype |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_tee::LocalTeeConfig", + "value_cell" + |); + M.read (| ctx |); + M.read (| M.read (| value |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_tee::LocalTeeConfig", + "offset_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| depth |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_tee::LocalTeeConfig", + "memory_table_lookup_stack_read" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.read (| vtype |); + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| M.read (| value |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_local_tee::LocalTeeConfig", + "memory_table_lookup_stack_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.path "u32", + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ], + "add", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |); + M.read (| depth |) + ] + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.read (| vtype |); + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| M.read (| value |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn mops(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, _: &EventTableEntry) -> u32 { + 1 + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Integer 1)) ] |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_local_tee_LocalTeeConfig_F. + End op_local_tee. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_memory_grow.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_memory_grow.v new file mode 100644 index 000000000..e7c623b6e --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_memory_grow.v @@ -0,0 +1,2539 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_memory_grow. + (* StructRecord + { + name := "MemoryGrowConfig"; + ty_params := [ "F" ]; + fields := + [ + ("grow_size", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("result", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("success", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("current_maximal_diff", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("memory_table_lookup_stack_read", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_write", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "MemoryGrowConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_memory_grow_MemoryGrowConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_memory_grow::MemoryGrowConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let grow_size = allocator.alloc_u64_cell(); + let result = allocator.alloc_u64_cell(); + let current_maximal_diff = allocator.alloc_common_range_cell(); + + let success = allocator.alloc_bit_cell(); + + let current_memory_size = common_config.mpages_cell; + let maximal_memory_pages = common_config.maximal_memory_pages_cell; + + constraint_builder.push( + "memory_grow: return value", + Box::new(move |meta| { + vec![ + result.expr(meta) + - (constant_from!(u32::MAX) + + success.expr(meta) + * (current_memory_size.expr(meta) - constant_from!(u32::MAX))), + ] + }), + ); + + constraint_builder.push( + "memory_grow: updated memory size should less or equal than maximal memory size", + Box::new(move |meta| { + vec![ + (current_memory_size.expr(meta) + + grow_size.expr(meta) + + current_maximal_diff.expr(meta) + - maximal_memory_pages.expr(meta)) + * success.expr(meta), + ] + }), + ); + + let eid = common_config.eid_cell; + let sp = common_config.sp_cell; + + let memory_table_lookup_stack_read = allocator.alloc_memory_table_lookup_read_cell( + "op_memory_grow stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |____| constant_from!(1), + move |meta| grow_size.expr(meta), + move |____| constant_from!(1), + ); + + let memory_table_lookup_stack_write = allocator.alloc_memory_table_lookup_write_cell( + "op_memory_grow stack write", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |____| constant_from!(1), + move |meta| result.expr(meta), + move |____| constant_from!(1), + ); + + Box::new(MemoryGrowConfig { + grow_size, + result, + success, + current_maximal_diff, + memory_table_lookup_stack_read, + memory_table_lookup_stack_write, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let grow_size := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let result := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let current_maximal_diff := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let success := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let current_memory_size := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "mpages_cell" + |) + |) in + let maximal_memory_pages := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "maximal_memory_pages_cell" + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "memory_grow: return value" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + result; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.get_constant (| + "core::num::MAX" + |) + |)) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + success; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + current_memory_size; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.get_constant (| + "core::num::MAX" + |) + |)) + ] + |) + ] + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| + Value.String + "memory_grow: updated memory size should less or equal than maximal memory size" + |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + current_memory_size; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + grow_size; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + current_maximal_diff; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + maximal_memory_pages; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + success; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let memory_table_lookup_stack_read := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_memory_grow stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ grow_size; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_write := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_memory_grow stack write" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ result; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_memory_grow::MemoryGrowConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_memory_grow::MemoryGrowConfig" + [ + ("grow_size", M.read (| grow_size |)); + ("result", M.read (| result |)); + ("success", M.read (| success |)); + ("current_maximal_diff", M.read (| current_maximal_diff |)); + ("memory_table_lookup_stack_read", + M.read (| memory_table_lookup_stack_read |)); + ("memory_table_lookup_stack_write", + M.read (| memory_table_lookup_stack_write |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_memory_grow_MemoryGrowConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_memory_grow_MemoryGrowConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_memory_grow::MemoryGrowConfig") + [ F ]. + + (* + fn opcode(&self, _meta: &mut VirtualCells<'_, F>) -> Expression { + constant!(bn_to_field( + &(BigUint::from(OpcodeClass::MemoryGrow as u64) << OPCODE_CLASS_SHIFT) + )) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| "delphinus_zkwasm::circuits::utils::bn_to_field", [ F ] |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 26 + |)) + ] + |); + M.read (| M.get_constant (| "specs::itable::OPCODE_CLASS_SHIFT" |) |) + ] + |) + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::MemoryGrow { grow_size, result } => { + let success = *result != -1; + + self.grow_size.assign(ctx, *grow_size as u64)?; + self.result.assign(ctx, *result as u32 as u64)?; + self.success.assign_bool(ctx, success)?; + if success { + self.current_maximal_diff.assign( + ctx, + F::from( + (step.configure_table.maximal_memory_pages + - (step.current.allocated_memory_pages + *grow_size as u32)) + as u64, + ), + )?; + } + + self.memory_table_lookup_stack_read.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + true, + *grow_size as u32 as u64, + )?; + + self.memory_table_lookup_stack_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + step.current.sp + 1, + LocationType::Stack, + true, + *result as u32 as u64, + )?; + + Ok(()) + } + + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::MemoryGrow", + "grow_size" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::MemoryGrow", + "result" + |) in + let grow_size := M.alloc (| γ1_0 |) in + let result := M.alloc (| γ1_1 |) in + let success := + M.alloc (| + BinOp.Pure.ne + (M.read (| M.read (| result |) |)) + (Value.Integer (-1)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_memory_grow::MemoryGrowConfig", + "grow_size" + |); + M.read (| ctx |); + M.rust_cast (M.read (| M.read (| grow_size |) |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_memory_grow::MemoryGrowConfig", + "result" + |); + M.read (| ctx |); + M.rust_cast + (M.rust_cast (M.read (| M.read (| result |) |))) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_memory_grow::MemoryGrowConfig", + "success" + |); + M.read (| ctx |); + M.read (| success |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use success in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_memory_grow::MemoryGrowConfig", + "current_maximal_diff" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.sub (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "configure_table" + |) + |), + "specs::configure_table::ConfigureTable", + "maximal_memory_pages" + |) + |), + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "allocated_memory_pages" + |) + |), + M.rust_cast + (M.read (| + M.read (| grow_size |) + |)) + |) + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_memory_grow::MemoryGrowConfig", + "memory_table_lookup_stack_read" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool true; + M.rust_cast + (M.rust_cast (M.read (| M.read (| grow_size |) |))) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_memory_grow::MemoryGrowConfig", + "memory_table_lookup_stack_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool true; + M.rust_cast + (M.rust_cast (M.read (| M.read (| result |) |))) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn mops(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, _: &EventTableEntry) -> u32 { + 1 + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Integer 1)) ] |))) + | _, _ => M.impossible + end. + + (* + fn allocated_memory_pages_diff(&self, meta: &mut VirtualCells<'_, F>) -> Option> { + Some(self.success.expr(meta) * self.grow_size.expr(meta)) + } + *) + Definition allocated_memory_pages_diff + (F : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_memory_grow::MemoryGrowConfig", + "success" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_memory_grow::MemoryGrowConfig", + "grow_size" + |); + M.read (| meta |) + ] + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)); + ("allocated_memory_pages_diff", + InstanceField.Method (allocated_memory_pages_diff F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_memory_grow_MemoryGrowConfig_F. + End op_memory_grow. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_memory_size.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_memory_size.v new file mode 100644 index 000000000..9e182e5b4 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_memory_size.v @@ -0,0 +1,806 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_memory_size. + (* StructRecord + { + name := "MemorySizeConfig"; + ty_params := [ "F" ]; + fields := + [ + ("memory_table_lookup_stack_write", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "MemorySizeConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_memory_size_MemorySizeConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_memory_size::MemorySizeConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let allocated_memory_pages = common_config.mpages_cell; + let sp = common_config.sp_cell; + let eid = common_config.eid_cell; + + let memory_table_lookup_stack_write = allocator.alloc_memory_table_lookup_write_cell( + "op_test stack write", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta), + move |____| constant_from!(1), + move |meta| allocated_memory_pages.expr(meta), + move |____| constant_from!(1), + ); + + Box::new(MemorySizeConfig { + memory_table_lookup_stack_write, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let allocated_memory_pages := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "mpages_cell" + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let memory_table_lookup_stack_write := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_test stack write" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ allocated_memory_pages; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_memory_size::MemorySizeConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_memory_size::MemorySizeConfig" + [ + ("memory_table_lookup_stack_write", + M.read (| memory_table_lookup_stack_write |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_memory_size_MemorySizeConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_memory_size_MemorySizeConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_memory_size::MemorySizeConfig") + [ F ]. + + (* + fn opcode(&self, _meta: &mut VirtualCells<'_, F>) -> Expression { + constant!(bn_to_field( + &(BigUint::from(OpcodeClass::MemorySize as u64) << OPCODE_CLASS_SHIFT) + )) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| "delphinus_zkwasm::circuits::utils::bn_to_field", [ F ] |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 25 + |)) + ] + |); + M.read (| M.get_constant (| "specs::itable::OPCODE_CLASS_SHIFT" |) |) + ] + |) + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::MemorySize => { + self.memory_table_lookup_stack_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp, + LocationType::Stack, + true, + step.current.allocated_memory_pages as u32 as u64, + )?; + + Ok(()) + } + + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_memory_size::MemorySizeConfig", + "memory_table_lookup_stack_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool true; + M.rust_cast + (M.read (| + M.use + (M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "allocated_memory_pages" + |)) + |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant!(-F::one())) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Neg", F, [], "neg", [] |), + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "one", [] |), + [] + |) + ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn mops(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, _: &EventTableEntry) -> u32 { + 1 + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Integer 1)) ] |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("sp_diff", InstanceField.Method (sp_diff F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_memory_size_MemorySizeConfig_F. + End op_memory_size. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_rel.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_rel.v new file mode 100644 index 000000000..0480f198b --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_rel.v @@ -0,0 +1,10969 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_rel. + (* StructRecord + { + name := "RelConfig"; + ty_params := [ "F" ]; + fields := + [ + ("is_i32", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("lhs", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign") + [ F ]); + ("rhs", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign") + [ F ]); + ("diff", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("diff_inv", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("res", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("res_is_eq", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("res_is_lt", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("res_is_gt", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("op_is_eq", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("op_is_ne", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("op_is_lt", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("op_is_gt", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("op_is_le", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("op_is_ge", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("op_is_sign", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("l_pos_r_pos", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("l_pos_r_neg", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("l_neg_r_pos", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("l_neg_r_neg", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("memory_table_lookup_stack_read_lhs", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_read_rhs", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_write", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "RelConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_rel_RelConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let is_i32 = allocator.alloc_bit_cell(); + let op_is_sign = allocator.alloc_bit_cell(); + + let lhs = allocator.alloc_u64_with_flag_bit_cell_dyn_sign( + constraint_builder, + move |meta| is_i32.expr(meta), + move |meta| op_is_sign.expr(meta), + ); + let rhs = allocator.alloc_u64_with_flag_bit_cell_dyn_sign( + constraint_builder, + move |meta| is_i32.expr(meta), + move |meta| op_is_sign.expr(meta), + ); + + let diff = allocator.alloc_u64_cell(); + let diff_inv = allocator.alloc_unlimited_cell(); + let res = allocator.alloc_unlimited_cell(); + + let res_is_eq = allocator.alloc_bit_cell(); + let res_is_lt = allocator.alloc_bit_cell(); + let res_is_gt = allocator.alloc_bit_cell(); + + let op_is_eq = allocator.alloc_bit_cell(); + let op_is_ne = allocator.alloc_bit_cell(); + let op_is_lt = allocator.alloc_bit_cell(); + let op_is_gt = allocator.alloc_bit_cell(); + let op_is_le = allocator.alloc_bit_cell(); + let op_is_ge = allocator.alloc_bit_cell(); + + constraint_builder.push( + "rel: selector", + Box::new(move |meta| { + vec![ + (op_is_eq.expr(meta) + + op_is_ne.expr(meta) + + op_is_lt.expr(meta) + + op_is_gt.expr(meta) + + op_is_le.expr(meta) + + op_is_ge.expr(meta) + - constant_from!(1)), + ] + }), + ); + + constraint_builder.push( + "rel: compare diff", + Box::new(move |meta| { + vec![ + (lhs.u64_cell.expr(meta) + res_is_lt.expr(meta) * diff.u64_cell.expr(meta) + - res_is_gt.expr(meta) * diff.u64_cell.expr(meta) + - rhs.u64_cell.expr(meta)), + (res_is_gt.expr(meta) + res_is_lt.expr(meta) + res_is_eq.expr(meta) + - constant_from!(1)), + (diff.u64_cell.expr(meta) * res_is_eq.expr(meta)), + (diff.u64_cell.expr(meta) * diff_inv.expr(meta) + res_is_eq.expr(meta) + - constant_from!(1)), + ] + }), + ); + + let l_pos_r_pos = allocator.alloc_unlimited_cell(); + let l_pos_r_neg = allocator.alloc_unlimited_cell(); + let l_neg_r_pos = allocator.alloc_unlimited_cell(); + let l_neg_r_neg = allocator.alloc_unlimited_cell(); + + constraint_builder.push( + "rel: compare op res", + Box::new(move |meta| { + vec![ + l_pos_r_pos.expr(meta) + - ((constant_from!(1) - lhs.flag_bit_cell.expr(meta)) + * (constant_from!(1) - rhs.flag_bit_cell.expr(meta))), + l_pos_r_neg.expr(meta) + - ((constant_from!(1) - lhs.flag_bit_cell.expr(meta)) + * rhs.flag_bit_cell.expr(meta)), + l_neg_r_pos.expr(meta) + - (lhs.flag_bit_cell.expr(meta) + * (constant_from!(1) - rhs.flag_bit_cell.expr(meta))), + l_neg_r_neg.expr(meta) + - (lhs.flag_bit_cell.expr(meta) * rhs.flag_bit_cell.expr(meta)), + op_is_eq.expr(meta) * (res.expr(meta) - res_is_eq.expr(meta)), + op_is_ne.expr(meta) + * (res.expr(meta) - constant_from!(1) + res_is_eq.expr(meta)), + op_is_lt.expr(meta) + * (res.expr(meta) + - l_neg_r_pos.expr(meta) + - l_pos_r_pos.expr(meta) * res_is_lt.expr(meta) + - l_neg_r_neg.expr(meta) * res_is_lt.expr(meta)), + op_is_le.expr(meta) + * (res.expr(meta) + - l_neg_r_pos.expr(meta) + - l_pos_r_pos.expr(meta) * res_is_lt.expr(meta) + - l_neg_r_neg.expr(meta) * res_is_lt.expr(meta) + - res_is_eq.expr(meta)), + op_is_gt.expr(meta) + * (res.expr(meta) + - l_pos_r_neg.expr(meta) + - l_pos_r_pos.expr(meta) * res_is_gt.expr(meta) + - l_neg_r_neg.expr(meta) * res_is_gt.expr(meta)), + op_is_ge.expr(meta) + * (res.expr(meta) + - l_pos_r_neg.expr(meta) + - l_pos_r_pos.expr(meta) * res_is_gt.expr(meta) + - l_neg_r_neg.expr(meta) * res_is_gt.expr(meta) + - res_is_eq.expr(meta)), + ] + }), + ); + + let eid = common_config.eid_cell; + let sp = common_config.sp_cell; + + let memory_table_lookup_stack_read_rhs = allocator.alloc_memory_table_lookup_read_cell( + "op_bin stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |meta| is_i32.expr(meta), + move |meta| rhs.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + let memory_table_lookup_stack_read_lhs = allocator.alloc_memory_table_lookup_read_cell( + "op_bin stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(2), + move |meta| is_i32.expr(meta), + move |meta| lhs.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + let memory_table_lookup_stack_write = allocator.alloc_memory_table_lookup_write_cell( + "op_bin stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(2), + move |____| constant_from!(1), + move |meta| res.expr(meta), + move |____| constant_from!(1), + ); + + Box::new(RelConfig { + is_i32, + lhs, + rhs, + diff, + diff_inv, + res, + res_is_eq, + res_is_lt, + res_is_gt, + op_is_eq, + op_is_ne, + op_is_lt, + op_is_gt, + op_is_le, + op_is_ge, + op_is_sign, + l_pos_r_pos, + l_neg_r_pos, + l_pos_r_neg, + l_neg_r_neg, + memory_table_lookup_stack_read_lhs, + memory_table_lookup_stack_read_rhs, + memory_table_lookup_stack_write, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let is_i32 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let op_is_sign := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let lhs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_with_flag_bit_cell_dyn_sign", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ op_is_sign; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let rhs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_with_flag_bit_cell_dyn_sign", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| constraint_builder |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ op_is_sign; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let diff := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let diff_inv := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let res := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let res_is_eq := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let res_is_lt := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let res_is_gt := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let op_is_eq := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let op_is_ne := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let op_is_lt := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let op_is_gt := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let op_is_le := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let op_is_ge := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "rel: selector" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ + F + ], + [ F + ], + "expr", + [] + |), + [ + op_is_eq; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ + F + ], + [ F + ], + "expr", + [] + |), + [ + op_is_ne; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + op_is_lt; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + op_is_gt; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + op_is_le; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + op_is_ge; + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "rel: compare diff" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_lt; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + diff, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_gt; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + diff, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "u64_cell" + |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_gt; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_lt; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_eq; + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + diff, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_eq; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + diff, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + diff_inv; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_eq; + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let l_pos_r_pos := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let l_pos_r_neg := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let l_neg_r_pos := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let l_neg_r_neg := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "rel: compare op res" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + l_pos_r_pos; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "flag_bit_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "flag_bit_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + l_pos_r_neg; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "flag_bit_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "flag_bit_cell" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + l_neg_r_pos; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "flag_bit_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "flag_bit_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + l_neg_r_neg; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "flag_bit_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "flag_bit_cell" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + op_is_eq; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_eq; + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + op_is_ne; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_eq; + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + op_is_lt; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + l_neg_r_pos; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + l_pos_r_pos; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_lt; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + l_neg_r_neg; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_lt; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + op_is_le; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + l_neg_r_pos; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + l_pos_r_pos; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_lt; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + l_neg_r_neg; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_lt; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_eq; + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + op_is_gt; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + l_pos_r_neg; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + l_pos_r_pos; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_gt; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + l_neg_r_neg; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_gt; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + op_is_ge; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + l_pos_r_neg; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + l_pos_r_pos; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_gt; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + l_neg_r_neg; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_gt; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_is_eq; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let memory_table_lookup_stack_read_rhs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_bin stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + rhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_read_lhs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_bin stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 2 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lhs, + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_write := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_bin stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 2 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ res; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig" + [ + ("is_i32", M.read (| is_i32 |)); + ("lhs", M.read (| lhs |)); + ("rhs", M.read (| rhs |)); + ("diff", M.read (| diff |)); + ("diff_inv", M.read (| diff_inv |)); + ("res", M.read (| res |)); + ("res_is_eq", M.read (| res_is_eq |)); + ("res_is_lt", M.read (| res_is_lt |)); + ("res_is_gt", M.read (| res_is_gt |)); + ("op_is_eq", M.read (| op_is_eq |)); + ("op_is_ne", M.read (| op_is_ne |)); + ("op_is_lt", M.read (| op_is_lt |)); + ("op_is_gt", M.read (| op_is_gt |)); + ("op_is_le", M.read (| op_is_le |)); + ("op_is_ge", M.read (| op_is_ge |)); + ("op_is_sign", M.read (| op_is_sign |)); + ("l_pos_r_pos", M.read (| l_pos_r_pos |)); + ("l_neg_r_pos", M.read (| l_neg_r_pos |)); + ("l_pos_r_neg", M.read (| l_pos_r_neg |)); + ("l_neg_r_neg", M.read (| l_neg_r_neg |)); + ("memory_table_lookup_stack_read_lhs", + M.read (| memory_table_lookup_stack_read_lhs |)); + ("memory_table_lookup_stack_read_rhs", + M.read (| memory_table_lookup_stack_read_rhs |)); + ("memory_table_lookup_stack_write", + M.read (| memory_table_lookup_stack_write |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_rel_RelConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_rel_RelConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + let subop_eq = |meta: &mut VirtualCells| { + self.op_is_eq.expr(meta) + * constant!(bn_to_field( + &(BigUint::from(RelOp::Eq as u64) << OPCODE_ARG0_SHIFT) + )) + }; + let subop_ne = |meta: &mut VirtualCells| { + self.op_is_ne.expr(meta) + * constant!(bn_to_field( + &(BigUint::from(RelOp::Ne as u64) << OPCODE_ARG0_SHIFT) + )) + }; + let subop_gt_u = |meta: &mut VirtualCells| { + self.op_is_gt.expr(meta) + * (constant_from!(1) - self.op_is_sign.expr(meta)) + * constant!(bn_to_field( + &(BigUint::from(RelOp::UnsignedGt as u64) << OPCODE_ARG0_SHIFT) + )) + }; + let subop_ge_u = |meta: &mut VirtualCells| { + self.op_is_ge.expr(meta) + * (constant_from!(1) - self.op_is_sign.expr(meta)) + * constant!(bn_to_field( + &(BigUint::from(RelOp::UnsignedGe as u64) << OPCODE_ARG0_SHIFT) + )) + }; + let subop_lt_u = |meta: &mut VirtualCells| { + self.op_is_lt.expr(meta) + * (constant_from!(1) - self.op_is_sign.expr(meta)) + * constant!(bn_to_field( + &(BigUint::from(RelOp::UnsignedLt as u64) << OPCODE_ARG0_SHIFT) + )) + }; + let subop_le_u = |meta: &mut VirtualCells| { + self.op_is_le.expr(meta) + * (constant_from!(1) - self.op_is_sign.expr(meta)) + * constant!(bn_to_field( + &(BigUint::from(RelOp::UnsignedLe as u64) << OPCODE_ARG0_SHIFT) + )) + }; + let subop_gt_s = |meta: &mut VirtualCells| { + self.op_is_gt.expr(meta) + * self.op_is_sign.expr(meta) + * constant!(bn_to_field( + &(BigUint::from(RelOp::SignedGt as u64) << OPCODE_ARG0_SHIFT) + )) + }; + let subop_ge_s = |meta: &mut VirtualCells| { + self.op_is_ge.expr(meta) + * self.op_is_sign.expr(meta) + * constant!(bn_to_field( + &(BigUint::from(RelOp::SignedGe as u64) << OPCODE_ARG0_SHIFT) + )) + }; + let subop_lt_s = |meta: &mut VirtualCells| { + self.op_is_lt.expr(meta) + * self.op_is_sign.expr(meta) + * constant!(bn_to_field( + &(BigUint::from(RelOp::SignedLt as u64) << OPCODE_ARG0_SHIFT) + )) + }; + let subop_le_s = |meta: &mut VirtualCells| { + self.op_is_le.expr(meta) + * self.op_is_sign.expr(meta) + * constant!(bn_to_field( + &(BigUint::from(RelOp::SignedLe as u64) << OPCODE_ARG0_SHIFT) + )) + }; + + let subop = |meta: &mut VirtualCells| { + subop_eq(meta) + + subop_ne(meta) + + subop_ge_u(meta) + + subop_gt_u(meta) + + subop_le_u(meta) + + subop_lt_u(meta) + + subop_ge_s(meta) + + subop_gt_s(meta) + + subop_le_s(meta) + + subop_lt_s(meta) + }; + + constant!(bn_to_field( + &(BigUint::from(OpcodeClass::Rel as u64) << OPCODE_CLASS_SHIFT) + )) + subop(meta) + + self.is_i32.expr(meta) + * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG1_SHIFT))) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.read (| + let subop_eq := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_eq" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 0) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let subop_ne := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_ne" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 1) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let subop_gt_u := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_gt" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_sign" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 3) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let subop_ge_u := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_ge" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_sign" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 5) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let subop_lt_u := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_lt" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_sign" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 7) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let subop_le_u := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_le" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_sign" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 9) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let subop_gt_s := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_gt" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_sign" + |); + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 2) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let subop_ge_s := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_ge" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_sign" + |); + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 4) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let subop_lt_s := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_lt" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_sign" + |); + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 6) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let subop_le_s := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_le" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_sign" + |); + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 8) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let subop := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + subop_eq; + Value.Tuple + [ M.read (| meta |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + subop_ne; + Value.Tuple + [ M.read (| meta |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + subop_ge_u; + Value.Tuple + [ M.read (| meta |) ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + subop_gt_u; + Value.Tuple + [ M.read (| meta |) ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + subop_le_u; + Value.Tuple [ M.read (| meta |) ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + subop_lt_u; + Value.Tuple [ M.read (| meta |) ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + subop_ge_s; + Value.Tuple [ M.read (| meta |) ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ subop_gt_s; Value.Tuple [ M.read (| meta |) ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ subop_le_s; Value.Tuple [ M.read (| meta |) ] ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ subop_lt_s; Value.Tuple [ M.read (| meta |) ] ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 14 + |)) + ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_CLASS_SHIFT" |) + |) + ] + |) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]), + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ subop; Value.Tuple [ M.read (| meta |) ] ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "is_i32" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_ARG1_SHIFT" |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + let (class, var_type, lhs, rhs, value, diff) = match entry.eentry.step_info { + StepInfo::I32Comp { + class, + left, + right, + value, + } => { + let var_type = VarType::I32; + let lhs = left as u32 as u64; + let rhs = right as u32 as u64; + let diff = if lhs < rhs { rhs - lhs } else { lhs - rhs }; + + (class, var_type, lhs, rhs, value, diff) + } + + StepInfo::I64Comp { + class, + left, + right, + value, + } => { + let var_type = VarType::I64; + let lhs = left as u64; + let rhs = right as u64; + let diff = if lhs < rhs { rhs - lhs } else { lhs - rhs }; + + (class, var_type, lhs, rhs, value, diff) + } + + _ => unreachable!(), + }; + + if var_type == VarType::I32 { + self.is_i32.assign(ctx, F::one())?; + } + + let op_is_sign = vec![ + RelOp::SignedGt, + RelOp::SignedGe, + RelOp::SignedLt, + RelOp::SignedLe, + ] + .contains(&class); + + if op_is_sign { + self.op_is_sign.assign(ctx, F::one())?; + } + + { + let (l_neg, r_neg) = if op_is_sign { + let l_neg = if var_type == VarType::I32 { + (lhs as i32).is_negative() + } else { + (lhs as i64).is_negative() + }; + let r_neg = if var_type == VarType::I32 { + (rhs as i32).is_negative() + } else { + (rhs as i64).is_negative() + }; + (l_neg, r_neg) + } else { + (false, false) + }; + + self.l_pos_r_pos.assign(ctx, F::from(!l_neg && !r_neg))?; + self.l_pos_r_neg.assign(ctx, F::from(!l_neg && r_neg))?; + self.l_neg_r_pos.assign(ctx, F::from(l_neg && !r_neg))?; + self.l_neg_r_neg.assign(ctx, F::from(l_neg && r_neg))?; + } + + self.lhs + .assign(ctx, lhs.into(), var_type == VarType::I32, op_is_sign)?; + self.rhs + .assign(ctx, rhs.into(), var_type == VarType::I32, op_is_sign)?; + self.diff.assign(ctx, diff.into())?; + + self.diff_inv + .assign(ctx, F::from(diff).invert().unwrap_or(F::zero()))?; + { + self.res_is_eq.assign_bool(ctx, lhs == rhs)?; + self.res_is_gt.assign_bool(ctx, lhs > rhs)?; + self.res_is_lt.assign_bool(ctx, lhs < rhs)?; + } + self.res + .assign(ctx, if value { F::one() } else { F::zero() })?; + + match class { + RelOp::Eq => { + self.op_is_eq.assign(ctx, F::one())?; + } + RelOp::Ne => { + self.op_is_ne.assign(ctx, F::one())?; + } + RelOp::SignedGt => { + self.op_is_gt.assign(ctx, F::one())?; + } + RelOp::UnsignedGt => { + self.op_is_gt.assign(ctx, F::one())?; + } + RelOp::SignedGe => { + self.op_is_ge.assign(ctx, F::one())?; + } + RelOp::UnsignedGe => { + self.op_is_ge.assign(ctx, F::one())?; + } + RelOp::SignedLt => { + self.op_is_lt.assign(ctx, F::one())?; + } + RelOp::UnsignedLt => { + self.op_is_lt.assign(ctx, F::one())?; + } + RelOp::SignedLe => { + self.op_is_le.assign(ctx, F::one())?; + } + RelOp::UnsignedLe => { + self.op_is_le.assign(ctx, F::one())?; + } + }; + + self.memory_table_lookup_stack_read_rhs.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + var_type == VarType::I32, + rhs, + )?; + + self.memory_table_lookup_stack_read_lhs.assign( + ctx, + entry.memory_rw_entires[1].start_eid, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + step.current.sp + 2, + LocationType::Stack, + var_type == VarType::I32, + lhs, + )?; + + self.memory_table_lookup_stack_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[2].end_eid, + step.current.sp + 2, + LocationType::Stack, + true, + value as u64, + )?; + + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.match_operator (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32Comp", + "class" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32Comp", + "left" + |) in + let γ0_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32Comp", + "right" + |) in + let γ0_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32Comp", + "value" + |) in + let class := M.copy (| γ0_0 |) in + let left := M.copy (| γ0_1 |) in + let right := M.copy (| γ0_2 |) in + let value := M.copy (| γ0_3 |) in + let var_type := + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) in + let lhs := + M.alloc (| M.rust_cast (M.rust_cast (M.read (| left |))) |) in + let rhs := + M.alloc (| M.rust_cast (M.rust_cast (M.read (| right |))) |) in + let diff := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (M.read (| lhs |)) + (M.read (| rhs |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + BinOp.Panic.sub (| + Integer.U64, + M.read (| rhs |), + M.read (| lhs |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + BinOp.Panic.sub (| + Integer.U64, + M.read (| lhs |), + M.read (| rhs |) + |) + |))) + ] + |) + |) in + M.alloc (| + Value.Tuple + [ + M.read (| class |); + M.read (| var_type |); + M.read (| lhs |); + M.read (| rhs |); + M.read (| value |); + M.read (| diff |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64Comp", + "class" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64Comp", + "left" + |) in + let γ0_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64Comp", + "right" + |) in + let γ0_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64Comp", + "value" + |) in + let class := M.copy (| γ0_0 |) in + let left := M.copy (| γ0_1 |) in + let right := M.copy (| γ0_2 |) in + let value := M.copy (| γ0_3 |) in + let var_type := + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I64" [] + |) in + let lhs := M.alloc (| M.rust_cast (M.read (| left |)) |) in + let rhs := M.alloc (| M.rust_cast (M.read (| right |)) |) in + let diff := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (M.read (| lhs |)) + (M.read (| rhs |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + BinOp.Panic.sub (| + Integer.U64, + M.read (| rhs |), + M.read (| lhs |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + BinOp.Panic.sub (| + Integer.U64, + M.read (| lhs |), + M.read (| rhs |) + |) + |))) + ] + |) + |) in + M.alloc (| + Value.Tuple + [ + M.read (| class |); + M.read (| var_type |); + M.read (| lhs |); + M.read (| rhs |); + M.read (| value |); + M.read (| diff |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_2 := M.SubPointer.get_tuple_field (| γ, 2 |) in + let γ0_3 := M.SubPointer.get_tuple_field (| γ, 3 |) in + let γ0_4 := M.SubPointer.get_tuple_field (| γ, 4 |) in + let γ0_5 := M.SubPointer.get_tuple_field (| γ, 5 |) in + let class := M.copy (| γ0_0 |) in + let var_type := M.copy (| γ0_1 |) in + let lhs := M.copy (| γ0_2 |) in + let rhs := M.copy (| γ0_3 |) in + let value := M.copy (| γ0_4 |) in + let diff := M.copy (| γ0_5 |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + var_type; + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "is_i32" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let op_is_sign := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "specs::itable::RelOp" ], + "contains", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::itable::RelOp"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::itable::RelOp" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::itable::RelOp" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.StructTuple + "specs::itable::RelOp::SignedGt" + []; + Value.StructTuple + "specs::itable::RelOp::SignedGe" + []; + Value.StructTuple + "specs::itable::RelOp::SignedLt" + []; + Value.StructTuple + "specs::itable::RelOp::SignedLe" + [] + ] + |) + ] + |) + |)) + ] + |) + |) + ] + |); + class + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use op_is_sign in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_sign" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use op_is_sign in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let l_neg := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" + ], + "eq", + [] + |), + [ + var_type; + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "i32", + "is_negative", + [] + |), + [ M.rust_cast (M.read (| lhs |)) ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "i64", + "is_negative", + [] + |), + [ M.rust_cast (M.read (| lhs |)) ] + |) + |))) + ] + |) + |) in + let r_neg := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" + ], + "eq", + [] + |), + [ + var_type; + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "i32", + "is_negative", + [] + |), + [ M.rust_cast (M.read (| rhs |)) ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "i64", + "is_negative", + [] + |), + [ M.rust_cast (M.read (| rhs |)) ] + |) + |))) + ] + |) + |) in + M.alloc (| + Value.Tuple [ M.read (| l_neg |); M.read (| r_neg |) ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple [ Value.Bool false; Value.Bool false ] + |))) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let l_neg := M.copy (| γ0_0 |) in + let r_neg := M.copy (| γ0_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "l_pos_r_pos" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "bool" ], + "from", + [] + |), + [ + LogicalOp.and (| + UnOp.Pure.not (M.read (| l_neg |)), + ltac:(M.monadic + (UnOp.Pure.not (M.read (| r_neg |)))) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "l_pos_r_neg" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "bool" ], + "from", + [] + |), + [ + LogicalOp.and (| + UnOp.Pure.not (M.read (| l_neg |)), + ltac:(M.monadic (M.read (| r_neg |))) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "l_neg_r_pos" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "bool" ], + "from", + [] + |), + [ + LogicalOp.and (| + M.read (| l_neg |), + ltac:(M.monadic + (UnOp.Pure.not (M.read (| r_neg |)))) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "l_neg_r_neg" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "bool" ], + "from", + [] + |), + [ + LogicalOp.and (| + M.read (| l_neg |), + ltac:(M.monadic (M.read (| r_neg |))) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "lhs" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ Ty.path "u64" ], + "into", + [] + |), + [ M.read (| lhs |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + var_type; + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| op_is_sign |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64CellWithFlagBitDynSign") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "rhs" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ Ty.path "u64" ], + "into", + [] + |), + [ M.read (| rhs |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + var_type; + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| op_is_sign |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "diff" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ Ty.path "u64" ], + "into", + [] + |), + [ M.read (| diff |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "diff_inv" + |); + M.read (| ctx |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "subtle::CtOption") [ F ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "invert", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| diff |) ] + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "res_is_eq" + |); + M.read (| ctx |); + BinOp.Pure.eq (M.read (| lhs |)) (M.read (| rhs |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "res_is_gt" + |); + M.read (| ctx |); + BinOp.Pure.gt (M.read (| lhs |)) (M.read (| rhs |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "res_is_lt" + |); + M.read (| ctx |); + BinOp.Pure.lt (M.read (| lhs |)) (M.read (| rhs |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "res" + |); + M.read (| ctx |); + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use value in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + |))) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + class, + [ + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_eq" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_ne" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_gt" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_gt" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_ge" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_ge" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_lt" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_lt" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_le" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "op_is_le" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "memory_table_lookup_stack_read_rhs" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + var_type; + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| rhs |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "memory_table_lookup_stack_read_lhs" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 2 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + var_type; + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| lhs |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_rel::RelConfig", + "memory_table_lookup_stack_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 2 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 2 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool true; + M.rust_cast (M.read (| value |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn mops(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, _: &EventTableEntry) -> u32 { + 1 + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Integer 1)) ] |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant!(F::one())) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "one", [] |), + [] + |) + ] + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)); + ("sp_diff", InstanceField.Method (sp_diff F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_rel_RelConfig_F. + End op_rel. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_return.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_return.v new file mode 100644 index 000000000..692a9f8ab --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_return.v @@ -0,0 +1,3560 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_return. + (* StructRecord + { + name := "ReturnConfig"; + ty_params := [ "F" ]; + fields := + [ + ("keep", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("drop", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("is_i32", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("value", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("frame_table_lookup", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell") + [ F ]); + ("memory_table_lookup_stack_read", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_write", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "ReturnConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_return_ReturnConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_return::ReturnConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let keep = allocator.alloc_bit_cell(); + let drop = allocator.alloc_common_range_cell(); + let is_i32 = allocator.alloc_bit_cell(); + let value = allocator.alloc_u64_cell(); + + let frame_table_lookup = common_config.jtable_lookup_cell; + + let fid_cell = common_config.fid_cell; + let iid_cell = common_config.iid_cell; + let frame_id_cell = common_config.frame_id_cell; + let eid = common_config.eid_cell; + let sp = common_config.sp_cell; + + let memory_table_lookup_stack_read = allocator.alloc_memory_table_lookup_read_cell( + "op_return stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |meta| is_i32.expr(meta), + move |meta| value.u64_cell.expr(meta), + move |meta| keep.expr(meta), + ); + let memory_table_lookup_stack_write = allocator.alloc_memory_table_lookup_write_cell( + "op_return stack write", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + drop.expr(meta) + constant_from!(1), + move |meta| is_i32.expr(meta), + move |meta| value.u64_cell.expr(meta), + move |meta| keep.expr(meta), + ); + + constraint_builder.constraints.push(( + "return frame table lookups", + Box::new(move |meta| { + vec![ + frame_table_lookup.cell.expr(meta) + - JumpTableConfig::encode_lookup( + frame_id_cell.expr(meta), + frame_id_cell.next_expr(meta), + fid_cell.expr(meta), + fid_cell.next_expr(meta), + iid_cell.next_expr(meta), + ), + ] + }), + )); + + Box::new(ReturnConfig { + keep, + drop, + is_i32, + value, + frame_table_lookup, + memory_table_lookup_stack_read, + memory_table_lookup_stack_write, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let keep := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let drop := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_i32 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let frame_table_lookup := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "jtable_lookup_cell" + |) + |) in + let fid_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "fid_cell" + |) + |) in + let iid_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "iid_cell" + |) + |) in + let frame_id_cell := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "frame_id_cell" + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let memory_table_lookup_stack_read := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_return stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ keep; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_write := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_return stack write" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ drop; M.read (| meta |) ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ keep; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| constraint_builder |), + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder", + "constraints" + |); + Value.Tuple + [ + M.read (| Value.String "return frame table lookups" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + frame_table_lookup, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell", + "cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::jtable::expression::JtableLookupEntryEncode", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + [ F ], + "encode_lookup", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + frame_id_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + frame_id_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + fid_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + fid_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + iid_cell; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_return::ReturnConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_return::ReturnConfig" + [ + ("keep", M.read (| keep |)); + ("drop", M.read (| drop |)); + ("is_i32", M.read (| is_i32 |)); + ("value", M.read (| value |)); + ("frame_table_lookup", M.read (| frame_table_lookup |)); + ("memory_table_lookup_stack_read", + M.read (| memory_table_lookup_stack_read |)); + ("memory_table_lookup_stack_write", + M.read (| memory_table_lookup_stack_write |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_return_ReturnConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_return_ReturnConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_return::ReturnConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + constant!(bn_to_field( + &(BigUint::from(OpcodeClass::Return as u64) << OPCODE_CLASS_SHIFT) + )) + self.drop.expr(meta) + * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG0_SHIFT))) + + self.keep.expr(meta) + * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG1_SHIFT))) + + self.is_i32.expr(meta) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 8 + |)) + ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_CLASS_SHIFT" |) + |) + ] + |) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_return::ReturnConfig", + "drop" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_return::ReturnConfig", + "keep" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_ARG1_SHIFT" |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_return::ReturnConfig", + "is_i32" + |); + M.read (| meta |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::Return { + drop, + keep, + keep_values, + .. + } => { + assert!(keep.len() <= 1); + assert_eq!(keep.len(), keep_values.len()); + + self.drop.assign(ctx, F::from( *drop as u64))?; + + if keep_values.len() == 0 { + self.keep.assign(ctx, 0.into())?; + } else { + self.keep.assign(ctx, 1.into())?; + self.is_i32 + .assign(ctx, (VarType::from(keep[0]) as u64).into())?; + self.value.assign(ctx, keep_values[0])?; + + self.memory_table_lookup_stack_read.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + VarType::from(keep[0]) == VarType::I32, + keep_values[0], + )?; + + self.memory_table_lookup_stack_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + step.current.sp + drop + 1, + LocationType::Stack, + VarType::from(keep[0]) == VarType::I32, + keep_values[0], + )?; + } + + self.frame_table_lookup.cell.assign_bn( + ctx, + &encode_frame_table_entry( + step.current.last_jump_eid.to_biguint().unwrap(), + step.next.last_jump_eid.to_biguint().unwrap(), + step.current.fid.to_biguint().unwrap(), + step.next.fid.to_biguint().unwrap(), + step.next.iid.to_biguint().unwrap(), + ), + )?; + Ok(()) + } + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Return", + "drop" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Return", + "keep" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Return", + "keep_values" + |) in + let drop := M.alloc (| γ1_0 |) in + let keep := M.alloc (| γ1_1 |) in + let keep_values := M.alloc (| γ1_2 |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.le + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + (Value.Integer 1)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "assertion failed: keep.len() <= 1" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |) + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ M.read (| keep_values |) ] + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_return::ReturnConfig", + "drop" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.read (| M.read (| drop |) |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep_values |) ] + |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_return::ReturnConfig", + "keep" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ Value.Integer 0 ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_return::ReturnConfig", + "keep" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ Value.Integer 1 ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_return::ReturnConfig", + "is_i32" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::types::ValueType" + ], + "from", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + Value.Integer 0 + ] + |) + |) + ] + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_return::ReturnConfig", + "value" + |); + M.read (| ctx |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + Value.Integer 0 + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_return::ReturnConfig", + "memory_table_lookup_stack_read" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::types::ValueType" + ], + "from", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + Value.Integer 0 + ] + |) + |) + ] + |) + |); + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + Value.Integer 0 + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_return::ReturnConfig", + "memory_table_lookup_stack_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.path "u32", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "u32" ] + ], + "add", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |); + M.read (| drop |) + ] + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::types::ValueType" + ], + "from", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + Value.Integer 0 + ] + |) + |) + ] + |) + |); + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |); + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + Value.Integer 0 + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCell") + [ F ], + [ F ], + "assign_bn", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_return::ReturnConfig", + "frame_table_lookup" + |), + "delphinus_zkwasm::circuits::etable::allocator::AllocatedJumpTableLookupCell", + "cell" + |); + M.read (| ctx |); + M.alloc (| + M.call_closure (| + M.get_function (| + "specs::encode::frame_table::encode_frame_table_entry", + [ Ty.path "num_bigint::biguint::BigUint" ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "num_bigint::biguint::BigUint" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "num_bigint::biguint::ToBigUint", + Ty.path "u32", + [], + "to_biguint", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "last_jump_eid" + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "num_bigint::biguint::BigUint" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "num_bigint::biguint::ToBigUint", + Ty.path "u32", + [], + "to_biguint", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "next" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "last_jump_eid" + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "num_bigint::biguint::BigUint" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "num_bigint::biguint::ToBigUint", + Ty.path "u32", + [], + "to_biguint", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "fid" + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "num_bigint::biguint::BigUint" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "num_bigint::biguint::ToBigUint", + Ty.path "u32", + [], + "to_biguint", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "next" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "fid" + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "num_bigint::biguint::BigUint" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "num_bigint::biguint::ToBigUint", + Ty.path "u32", + [], + "to_biguint", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "next" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "iid" + |) + ] + |) + ] + |) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, meta: &mut VirtualCells<'_, F>) -> Option> { + Some(self.drop.expr(meta)) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_return::ReturnConfig", + "drop" + |); + M.read (| meta |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn mops(&self, meta: &mut VirtualCells<'_, F>) -> Option> { + Some(self.keep.expr(meta)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_return::ReturnConfig", + "keep" + |); + M.read (| meta |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, entry: &EventTableEntry) -> u32 { + match &entry.step_info { + StepInfo::Return { keep, .. } => { + if keep.len() > 0 { + assert!(keep.len() == 1); + 1 + } else { + 0 + } + } + _ => unreachable!(), + } + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let entry := M.alloc (| entry |) in + M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Return", + "keep" + |) in + let keep := M.alloc (| γ1_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + (Value.Integer 1)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "assertion failed: keep.len() == 1" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Integer 1 |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Integer 0 |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + fn jops_expr(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from_bn!(&self.jops())) + } + *) + Definition jops_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_return::ReturnConfig") + [ F ], + [ F ], + "jops", + [] + |), + [ M.read (| self |) ] + |) + |) + ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn jops(&self) -> BigUint { + encode_jops(1, 0) + } + *) + Definition jops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_function (| "delphinus_zkwasm::circuits::jtable::encode_jops", [] |), + [ Value.Integer 1; Value.Integer 0 ] + |))) + | _, _ => M.impossible + end. + + (* + fn next_frame_id( + &self, + meta: &mut VirtualCells<'_, F>, + common_config: &EventTableCommonConfig, + ) -> Option> { + Some(common_config.frame_id_cell.next_expr(meta)) + } + *) + Definition next_frame_id (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta; common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let common_config := M.alloc (| common_config |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "frame_id_cell" + |); + M.read (| meta |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn next_fid( + &self, + meta: &mut VirtualCells<'_, F>, + common_config: &EventTableCommonConfig, + ) -> Option> { + Some(common_config.fid_cell.next_expr(meta)) + } + *) + Definition next_fid (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta; common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let common_config := M.alloc (| common_config |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "fid_cell" + |); + M.read (| meta |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn next_iid( + &self, + meta: &mut VirtualCells<'_, F>, + common_config: &EventTableCommonConfig, + ) -> Option> { + Some(common_config.iid_cell.next_expr(meta)) + } + *) + Definition next_iid (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta; common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let common_config := M.alloc (| common_config |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "iid_cell" + |); + M.read (| meta |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("sp_diff", InstanceField.Method (sp_diff F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)); + ("jops_expr", InstanceField.Method (jops_expr F)); + ("jops", InstanceField.Method (jops F)); + ("next_frame_id", InstanceField.Method (next_frame_id F)); + ("next_fid", InstanceField.Method (next_fid F)); + ("next_iid", InstanceField.Method (next_iid F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_return_ReturnConfig_F. + End op_return. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_select.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_select.v new file mode 100644 index 000000000..33ef0a8fc --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_select.v @@ -0,0 +1,3733 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_select. + (* StructRecord + { + name := "SelectConfig"; + ty_params := [ "F" ]; + fields := + [ + ("cond", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("cond_inv", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("val1", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("val2", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("res", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("is_i32", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("memory_table_lookup_stack_read_cond", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_read_val2", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_read_val1", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_write", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "SelectConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_select_SelectConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_select::SelectConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let cond = allocator.alloc_u64_cell(); + let cond_inv = allocator.alloc_unlimited_cell(); + + let val1 = allocator.alloc_u64_cell(); + let val2 = allocator.alloc_u64_cell(); + let res = allocator.alloc_u64_cell(); + let is_i32 = allocator.alloc_bit_cell(); + + constraint_builder.push( + "select: cond is zero", + Box::new(move |meta| { + vec![ + (constant_from!(1) - cond.u64_cell.expr(meta) * cond_inv.expr(meta)) + * (res.u64_cell.expr(meta) - val2.u64_cell.expr(meta)), + ] + }), + ); + + constraint_builder.push( + "select: cond is not zero", + Box::new(move |meta| { + vec![ + cond.u64_cell.expr(meta) * (res.u64_cell.expr(meta) - val1.u64_cell.expr(meta)), + ] + }), + ); + + let eid = common_config.eid_cell; + let sp = common_config.sp_cell; + + let memory_table_lookup_stack_read_cond = allocator.alloc_memory_table_lookup_read_cell( + "op_select stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |____| constant_from!(1), + move |meta| cond.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + let memory_table_lookup_stack_read_val2 = allocator.alloc_memory_table_lookup_read_cell( + "op_select stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(2), + move |meta| is_i32.expr(meta), + move |meta| val2.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + let memory_table_lookup_stack_read_val1 = allocator.alloc_memory_table_lookup_read_cell( + "op_select stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(3), + move |meta| is_i32.expr(meta), + move |meta| val1.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + let memory_table_lookup_stack_write = allocator.alloc_memory_table_lookup_write_cell( + "op_select stack write", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(3), + move |meta| is_i32.expr(meta), + move |meta| res.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + Box::new(SelectConfig { + cond, + cond_inv, + val1, + val2, + res, + is_i32, + memory_table_lookup_stack_read_cond, + memory_table_lookup_stack_read_val2, + memory_table_lookup_stack_read_val1, + memory_table_lookup_stack_write, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let cond := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let cond_inv := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let val1 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let val2 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let res := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_i32 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "select: cond is zero" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cond, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + cond_inv; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + res, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + val2, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "select: cond is not zero" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cond, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + res, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + val1, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let memory_table_lookup_stack_read_cond := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_select stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + cond, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_read_val2 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_select stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 2 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + val2, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_read_val1 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_select stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 3 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + val1, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_write := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_select stack write" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 3 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + res, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_select::SelectConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_select::SelectConfig" + [ + ("cond", M.read (| cond |)); + ("cond_inv", M.read (| cond_inv |)); + ("val1", M.read (| val1 |)); + ("val2", M.read (| val2 |)); + ("res", M.read (| res |)); + ("is_i32", M.read (| is_i32 |)); + ("memory_table_lookup_stack_read_cond", + M.read (| memory_table_lookup_stack_read_cond |)); + ("memory_table_lookup_stack_read_val2", + M.read (| memory_table_lookup_stack_read_val2 |)); + ("memory_table_lookup_stack_read_val1", + M.read (| memory_table_lookup_stack_read_val1 |)); + ("memory_table_lookup_stack_write", + M.read (| memory_table_lookup_stack_write |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_select_SelectConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_select_SelectConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_select::SelectConfig") + [ F ]. + + (* + fn opcode(&self, _: &mut VirtualCells<'_, F>) -> Expression { + constant!(bn_to_field( + &(BigUint::from(OpcodeClass::Select as u64) << OPCODE_CLASS_SHIFT) + )) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| + β1, + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 7 + |)) + ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_CLASS_SHIFT" |) + |) + ] + |) + |) + ] + |) + ])) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::Select { + val1, + val2, + cond, + result, + vtype, + } => { + self.val1.assign(ctx, *val1)?; + self.val2.assign(ctx, *val2)?; + self.cond.assign(ctx, *cond)?; + self.cond_inv + .assign(ctx, F::from( *cond).invert().unwrap_or(F::zero()))?; + self.res.assign(ctx, *result)?; + self.is_i32.assign_bool(ctx, *vtype == VarType::I32)?; + + self.memory_table_lookup_stack_read_cond.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + true, + *cond, + )?; + + self.memory_table_lookup_stack_read_val2.assign( + ctx, + entry.memory_rw_entires[1].start_eid, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + step.current.sp + 2, + LocationType::Stack, + *vtype == VarType::I32, + *val2, + )?; + + self.memory_table_lookup_stack_read_val1.assign( + ctx, + entry.memory_rw_entires[2].start_eid, + step.current.eid, + entry.memory_rw_entires[2].end_eid, + step.current.sp + 3, + LocationType::Stack, + *vtype == VarType::I32, + *val1, + )?; + + self.memory_table_lookup_stack_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[3].end_eid, + step.current.sp + 3, + LocationType::Stack, + *vtype == VarType::I32, + *result, + )?; + + Ok(()) + } + + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Select", + "val1" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Select", + "val2" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Select", + "cond" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Select", + "result" + |) in + let γ1_4 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Select", + "vtype" + |) in + let val1 := M.alloc (| γ1_0 |) in + let val2 := M.alloc (| γ1_1 |) in + let cond := M.alloc (| γ1_2 |) in + let result := M.alloc (| γ1_3 |) in + let vtype := M.alloc (| γ1_4 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_select::SelectConfig", + "val1" + |); + M.read (| ctx |); + M.read (| M.read (| val1 |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_select::SelectConfig", + "val2" + |); + M.read (| ctx |); + M.read (| M.read (| val2 |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_select::SelectConfig", + "cond" + |); + M.read (| ctx |); + M.read (| M.read (| cond |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_select::SelectConfig", + "cond_inv" + |); + M.read (| ctx |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "subtle::CtOption") [ F ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "invert", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.read (| cond |) |) ] + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_select::SelectConfig", + "res" + |); + M.read (| ctx |); + M.read (| M.read (| result |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_select::SelectConfig", + "is_i32" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.read (| vtype |); + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_select::SelectConfig", + "memory_table_lookup_stack_read_cond" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool true; + M.read (| M.read (| cond |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_select::SelectConfig", + "memory_table_lookup_stack_read_val2" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 2 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.read (| vtype |); + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| M.read (| val2 |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_select::SelectConfig", + "memory_table_lookup_stack_read_val1" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 2 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 2 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 3 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.read (| vtype |); + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| M.read (| val1 |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_select::SelectConfig", + "memory_table_lookup_stack_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 3 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 3 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.read (| vtype |); + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| M.read (| result |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(2)) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 2 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn mops(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, _: &EventTableEntry) -> u32 { + 1 + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Integer 1)) ] |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("sp_diff", InstanceField.Method (sp_diff F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_select_SelectConfig_F. + End op_select. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_store.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_store.v new file mode 100644 index 000000000..5a30cfc66 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_store.v @@ -0,0 +1,13129 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_store. + (* StructRecord + { + name := "StoreConfig"; + ty_params := [ "F" ]; + fields := + [ + ("opcode_store_offset", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") [ F ]); + ("load_block_index", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") [ F ]); + ("load_block_inner_pos_bits", + Ty.apply + (Ty.path "array") + [ Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ] + ]); + ("load_block_inner_pos", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("is_cross_block", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("cross_block_rem", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("cross_block_rem_diff", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("load_tailing", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("load_tailing_diff", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("load_picked", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("load_leading", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("load_picked_byte_proof", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") [ F ]); + ("unchanged_value", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("bytes", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("len_modulus", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("store_value", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("store_value_tailing_u16_u8_high", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") [ F ]); + ("store_value_tailing_u16_u8_low", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") [ F ]); + ("store_value_wrapped", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("is_one_byte", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_two_bytes", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_four_bytes", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_eight_bytes", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_i32", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("memory_table_lookup_stack_read_pos", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_read_val", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_heap_read1", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_heap_read2", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_heap_write1", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]); + ("memory_table_lookup_heap_write2", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]); + ("lookup_pow_modulus", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("lookup_pow_power", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("address_within_allocated_pages_helper", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "StoreConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_store_StoreConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let opcode_store_offset = allocator.alloc_u32_cell(); + + // which heap offset to load + let load_block_index = allocator.alloc_u32_cell(); + let load_block_inner_pos_bits = [0; 3].map(|_| allocator.alloc_bit_cell()); + let load_block_inner_pos = allocator.alloc_unlimited_cell(); + let is_cross_block = allocator.alloc_bit_cell(); + let cross_block_rem = allocator.alloc_common_range_cell(); + let cross_block_rem_diff = allocator.alloc_common_range_cell(); + + let bytes = allocator.alloc_unlimited_cell(); + let len_modulus = allocator.alloc_unlimited_cell(); + + let load_tailing = allocator.alloc_u64_cell(); + let load_tailing_diff = allocator.alloc_u64_cell(); + let load_picked = allocator.alloc_u64_cell(); + let load_picked_byte_proof = allocator.alloc_u8_cell(); + let load_leading = allocator.alloc_u64_cell(); + + let lookup_pow_modulus = common_config.pow_table_lookup_modulus_cell; + let lookup_pow_power = common_config.pow_table_lookup_power_cell; + + let store_value = allocator.alloc_u64_cell(); + let store_value_wrapped = allocator.alloc_unlimited_cell(); + + let is_one_byte = allocator.alloc_bit_cell(); + let is_two_bytes = allocator.alloc_bit_cell(); + let is_four_bytes = allocator.alloc_bit_cell(); + let is_eight_bytes = allocator.alloc_bit_cell(); + let is_i32 = allocator.alloc_bit_cell(); + + let sp = common_config.sp_cell; + let eid = common_config.eid_cell; + + let memory_table_lookup_stack_read_val = allocator.alloc_memory_table_lookup_read_cell( + "store read data", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |meta| is_i32.expr(meta), + move |meta| store_value.expr(meta), + move |____| constant_from!(1), + ); + + let memory_table_lookup_stack_read_pos = allocator + .alloc_memory_table_lookup_read_cell_with_value( + "store read pos", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(2), + move |____| constant_from!(1), + move |____| constant_from!(1), + ); + + let memory_table_lookup_heap_read1 = allocator + .alloc_memory_table_lookup_read_cell_with_value( + "store load origin1", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Heap as u64), + move |meta| load_block_index.expr(meta), + move |____| constant_from!(0), + move |____| constant_from!(1), + ); + + let memory_table_lookup_heap_read2 = allocator + .alloc_memory_table_lookup_read_cell_with_value( + "store load origin2", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Heap as u64), + move |meta| load_block_index.expr(meta) + constant_from!(1), + move |____| constant_from!(0), + move |meta| is_cross_block.expr(meta), + ); + + let memory_table_lookup_heap_write1 = allocator + .alloc_memory_table_lookup_write_cell_with_value( + "store write res1", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Heap as u64), + move |meta| load_block_index.expr(meta), + move |____| constant_from!(0), + move |____| constant_from!(1), + ); + + let memory_table_lookup_heap_write2 = allocator + .alloc_memory_table_lookup_write_cell_with_value( + "store write res1", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Heap as u64), + move |meta| load_block_index.expr(meta) + constant_from!(1), + move |____| constant_from!(0), + move |meta| is_cross_block.expr(meta), + ); + + let store_base = memory_table_lookup_stack_read_pos.value_cell; + + let store_value_in_heap1 = memory_table_lookup_heap_write1.value_cell; + let store_value_in_heap2 = memory_table_lookup_heap_write2.value_cell; + + let load_value_in_heap1 = memory_table_lookup_heap_read1.value_cell; + let load_value_in_heap2 = memory_table_lookup_heap_read2.value_cell; + + constraint_builder.push( + "op_store length", + Box::new(move |meta| { + vec![ + is_one_byte.expr(meta) + + is_two_bytes.expr(meta) + + is_four_bytes.expr(meta) + + is_eight_bytes.expr(meta) + - constant_from!(1), + ] + }), + ); + + constraint_builder.push( + "op_store bytes", + Box::new(move |meta| { + vec![ + bytes.expr(meta) + - constant_from!(1) + - is_two_bytes.expr(meta) + - constant_from!(3) * is_four_bytes.expr(meta) + - constant_from!(7) * is_eight_bytes.expr(meta), + ] + }), + ); + + constraint_builder.push( + "op_store load_block_index", + Box::new(move |meta| { + vec![ + load_block_index.expr(meta) * constant_from!(WASM_BLOCK_BYTE_SIZE) + + load_block_inner_pos.expr(meta) + - opcode_store_offset.expr(meta) + - store_base.expr(meta), + load_block_inner_pos.expr(meta) + - load_block_inner_pos_bits[0].expr(meta) + - load_block_inner_pos_bits[1].expr(meta) * constant_from!(2) + - load_block_inner_pos_bits[2].expr(meta) * constant_from!(4), + ] + }), + ); + + constraint_builder.push( + "op_store cross_block", + Box::new(move |meta| { + vec![ + is_cross_block.expr(meta) * constant_from!(WASM_BLOCK_BYTE_SIZE) + + cross_block_rem.expr(meta) + - load_block_inner_pos.expr(meta) + - bytes.expr(meta) + + constant_from!(1), + cross_block_rem.expr(meta) + cross_block_rem_diff.expr(meta) + - constant_from!(WASM_BLOCK_BYTE_SIZE - 1), + (is_cross_block.expr(meta) - constant_from!(1)) + * load_value_in_heap2.expr(meta), + ] + }), + ); + + let unchanged_value = allocator.alloc_unlimited_cell(); + + constraint_builder.push( + "op_store len modulus", + Box::new(move |meta| { + vec![ + len_modulus.expr(meta) + - is_one_byte.expr(meta) * constant_from!(1u64 << 8) + - is_two_bytes.expr(meta) * constant_from!(1u64 << 16) + - is_four_bytes.expr(meta) * constant_from!(1u64 << 32) + - is_eight_bytes.expr(meta) + * constant_from_bn!(&(BigUint::from(1u64) << 64)), + ] + }), + ); + + constraint_builder.push( + "op_store pick value1", + Box::new(move |meta| { + vec![ + unchanged_value.expr(meta) + - load_tailing.expr(meta) + - load_leading.expr(meta) + * lookup_pow_modulus.expr(meta) + * len_modulus.expr(meta), + ] + }), + ); + + constraint_builder.push( + "op_store pick value2", + Box::new(move |meta| { + vec![ + unchanged_value.expr(meta) + + load_picked.expr(meta) * lookup_pow_modulus.expr(meta) + - load_value_in_heap1.expr(meta) + - load_value_in_heap2.expr(meta) + * constant_from_bn!(&(BigUint::from(1u64) << 64)), + ] + }), + ); + + constraint_builder.push( + "op_store pick value3", + Box::new(move |meta| { + vec![ + unchanged_value.expr(meta) + + store_value_wrapped.expr(meta) * lookup_pow_modulus.expr(meta) + - store_value_in_heap1.expr(meta) + - store_value_in_heap2.expr(meta) + * constant_from_bn!(&(BigUint::from(1u64) << 64)), + ] + }), + ); + + constraint_builder.push( + "op_store pick helper value check", + Box::new(move |meta| { + vec![ + load_tailing.expr(meta) + load_tailing_diff.expr(meta) + constant_from!(1) + - lookup_pow_modulus.expr(meta), + ] + }), + ); + + constraint_builder.push( + "op_store pick value size check", + Box::new(move |meta| { + vec![ + is_four_bytes.expr(meta) + * (load_picked.u16_cells_le[2].expr(meta) + + load_picked.u16_cells_le[3].expr(meta)), + is_two_bytes.expr(meta) + * (load_picked.expr(meta) - load_picked.u16_cells_le[0].expr(meta)), + is_one_byte.expr(meta) + * (load_picked.expr(meta) - load_picked_byte_proof.expr(meta)), + ] + }), + ); + + let store_value_tailing_u16_u8_high = allocator.alloc_u8_cell(); + let store_value_tailing_u16_u8_low = allocator.alloc_u8_cell(); + + constraint_builder.push( + "op_store tailing u16 decompose", + Box::new(move |meta| { + vec![ + store_value_tailing_u16_u8_high.expr(meta) * constant_from!(1 << 8) + + store_value_tailing_u16_u8_low.expr(meta) + - store_value.u16_cells_le[0].expr(meta), + ] + }), + ); + + constraint_builder.push( + "op_store value wrap", + Box::new(move |meta| { + vec![ + store_value_wrapped.expr(meta) + - (is_one_byte.expr(meta) * store_value_tailing_u16_u8_low.expr(meta) + + is_two_bytes.expr(meta) * store_value.u16_cells_le[0].expr(meta) + + is_four_bytes.expr(meta) + * (store_value.u16_cells_le[0].expr(meta) + + store_value.u16_cells_le[1].expr(meta) + * constant_from!(1 << 16)) + + is_eight_bytes.expr(meta) * store_value.expr(meta)), + ] + }), + ); + + constraint_builder.push( + "op_store pow lookup", + Box::new(move |meta| { + vec![ + lookup_pow_power.expr(meta) + - pow_table_power_encode( + load_block_inner_pos.expr(meta) * constant_from!(8), + ), + ] + }), + ); + + let current_memory_page_size = common_config.mpages_cell; + + let address_within_allocated_pages_helper = allocator.alloc_common_range_cell(); + constraint_builder.push( + "op_store allocated address", + Box::new(move |meta| { + vec![ + (load_block_index.expr(meta) + + is_cross_block.expr(meta) + + constant_from!(1) + + address_within_allocated_pages_helper.expr(meta) + - current_memory_page_size.expr(meta) + * constant_from!(WASM_BLOCKS_PER_PAGE)), + ] + }), + ); + + Box::new(StoreConfig { + opcode_store_offset, + load_block_index, + load_block_inner_pos_bits, + load_block_inner_pos, + is_cross_block, + cross_block_rem, + cross_block_rem_diff, + load_tailing, + load_picked, + load_picked_byte_proof, + load_leading, + unchanged_value, + store_value, + store_value_tailing_u16_u8_high, + store_value_tailing_u16_u8_low, + store_value_wrapped, + is_one_byte, + is_two_bytes, + is_four_bytes, + is_eight_bytes, + is_i32, + memory_table_lookup_stack_read_pos, + memory_table_lookup_stack_read_val, + memory_table_lookup_heap_read1, + memory_table_lookup_heap_read2, + memory_table_lookup_heap_write1, + memory_table_lookup_heap_write2, + lookup_pow_power, + lookup_pow_modulus, + address_within_allocated_pages_helper, + load_tailing_diff, + bytes, + len_modulus, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let opcode_store_offset := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u32_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let load_block_index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u32_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let load_block_inner_pos_bits := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.path "i32" ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "i32" ] ] + (Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ]); + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ] + ] + |), + [ + repeat (Value.Integer 0) 3; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let load_block_inner_pos := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_cross_block := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let cross_block_rem := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let cross_block_rem_diff := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let bytes := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let len_modulus := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let load_tailing := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let load_tailing_diff := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let load_picked := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let load_picked_byte_proof := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u8_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let load_leading := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let lookup_pow_modulus := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "pow_table_lookup_modulus_cell" + |) + |) in + let lookup_pow_power := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "pow_table_lookup_power_cell" + |) + |) in + let store_value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let store_value_wrapped := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_one_byte := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_two_bytes := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_four_bytes := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_eight_bytes := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_i32 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let memory_table_lookup_stack_read_val := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "store read data" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ store_value; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_read_pos := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell_with_value", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "store read pos" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 2 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_heap_read1 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell_with_value", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "store load origin1" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Heap_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "expr", + [] + |), + [ load_block_index; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 0 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_heap_read2 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell_with_value", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "store load origin2" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Heap_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "expr", + [] + |), + [ load_block_index; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 0 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_cross_block; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_heap_write1 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell_with_value", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "store write res1" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Heap_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "expr", + [] + |), + [ load_block_index; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 0 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_heap_write2 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell_with_value", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "store write res1" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Heap_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "expr", + [] + |), + [ load_block_index; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 0 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_cross_block; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let store_base := + M.copy (| + M.SubPointer.get_struct_record_field (| + memory_table_lookup_stack_read_pos, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "value_cell" + |) + |) in + let store_value_in_heap1 := + M.copy (| + M.SubPointer.get_struct_record_field (| + memory_table_lookup_heap_write1, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "value_cell" + |) + |) in + let store_value_in_heap2 := + M.copy (| + M.SubPointer.get_struct_record_field (| + memory_table_lookup_heap_write2, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "value_cell" + |) + |) in + let load_value_in_heap1 := + M.copy (| + M.SubPointer.get_struct_record_field (| + memory_table_lookup_heap_read1, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "value_cell" + |) + |) in + let load_value_in_heap2 := + M.copy (| + M.SubPointer.get_struct_record_field (| + memory_table_lookup_heap_read2, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "value_cell" + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_store length" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_one_byte; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_two_bytes; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_four_bytes; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_eight_bytes; + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_store bytes" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + bytes; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_two_bytes; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 3 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_four_bytes; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 7 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_eight_bytes; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_store load_block_index" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "expr", + [] + |), + [ + load_block_index; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::utils::WASM_BLOCK_BYTE_SIZE" + |) + |)) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_block_inner_pos; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "expr", + [] + |), + [ + opcode_store_offset; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + store_base; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_block_inner_pos; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + load_block_inner_pos_bits, + M.alloc (| + Value.Integer + 0 + |) + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + load_block_inner_pos_bits, + M.alloc (| + Value.Integer + 1 + |) + |); + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 2 + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + load_block_inner_pos_bits, + M.alloc (| + Value.Integer 2 + |) + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 4 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_store cross_block" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_cross_block; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::utils::WASM_BLOCK_BYTE_SIZE" + |) + |)) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + cross_block_rem; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_block_inner_pos; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + bytes; + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + cross_block_rem; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + cross_block_rem_diff; + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.sub (| + Integer.U32, + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::utils::WASM_BLOCK_BYTE_SIZE" + |) + |), + Value.Integer 1 + |)) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_cross_block; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_value_in_heap2; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let unchanged_value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_store len modulus" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + len_modulus; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_one_byte; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 8 + |) + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_two_bytes; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 16 + |) + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_four_bytes; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 32 + |) + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_eight_bytes; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "i32" + ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + Value.Integer + 1 + ] + |); + Value.Integer + 64 + ] + |) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_store pick value1" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + unchanged_value; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + load_tailing; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + load_leading; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + lookup_pow_modulus; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + len_modulus; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_store pick value2" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + unchanged_value; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + load_picked; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + lookup_pow_modulus; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_value_in_heap1; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_value_in_heap2; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "i32" + ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + Value.Integer + 1 + ] + |); + Value.Integer + 64 + ] + |) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_store pick value3" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + unchanged_value; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + store_value_wrapped; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + lookup_pow_modulus; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + store_value_in_heap1; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + store_value_in_heap2; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "i32" + ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + Value.Integer + 1 + ] + |); + Value.Integer + 64 + ] + |) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_store pick helper value check" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + load_tailing; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + load_tailing_diff; + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + lookup_pow_modulus; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_store pick value size check" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_four_bytes; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + load_picked, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| + Value.Integer 2 + |) + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + load_picked, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| + Value.Integer 3 + |) + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_two_bytes; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + load_picked; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + load_picked, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| + Value.Integer 0 + |) + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_one_byte; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + load_picked; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_picked_byte_proof; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let store_value_tailing_u16_u8_high := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u8_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let store_value_tailing_u16_u8_low := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u8_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_store tailing u16 decompose" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + store_value_tailing_u16_u8_high; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 8 + |)) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + store_value_tailing_u16_u8_low; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + store_value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| + Value.Integer 0 + |) + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_store value wrap" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + store_value_wrapped; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_one_byte; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + store_value_tailing_u16_u8_low; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_two_bytes; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + store_value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| + Value.Integer + 0 + |) + |); + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_four_bytes; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + store_value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| + Value.Integer + 0 + |) + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ + F + ], + [ F + ], + "expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + store_value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| + Value.Integer + 1 + |) + |); + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 16 + |)) + ] + |) + ] + ] + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_eight_bytes; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + store_value; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_store pow lookup" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + lookup_pow_power; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::rtable::pow_table_power_encode", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + load_block_inner_pos; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 8 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let current_memory_page_size := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "mpages_cell" + |) + |) in + let address_within_allocated_pages_helper := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_store allocated address" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "expr", + [] + |), + [ + load_block_index; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_cross_block; + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + address_within_allocated_pages_helper; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + current_memory_page_size; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::utils::WASM_BLOCKS_PER_PAGE" + |) + |)) + ] + |) + ] + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig" + [ + ("opcode_store_offset", M.read (| opcode_store_offset |)); + ("load_block_index", M.read (| load_block_index |)); + ("load_block_inner_pos_bits", + M.read (| load_block_inner_pos_bits |)); + ("load_block_inner_pos", M.read (| load_block_inner_pos |)); + ("is_cross_block", M.read (| is_cross_block |)); + ("cross_block_rem", M.read (| cross_block_rem |)); + ("cross_block_rem_diff", M.read (| cross_block_rem_diff |)); + ("load_tailing", M.read (| load_tailing |)); + ("load_picked", M.read (| load_picked |)); + ("load_picked_byte_proof", M.read (| load_picked_byte_proof |)); + ("load_leading", M.read (| load_leading |)); + ("unchanged_value", M.read (| unchanged_value |)); + ("store_value", M.read (| store_value |)); + ("store_value_tailing_u16_u8_high", + M.read (| store_value_tailing_u16_u8_high |)); + ("store_value_tailing_u16_u8_low", + M.read (| store_value_tailing_u16_u8_low |)); + ("store_value_wrapped", M.read (| store_value_wrapped |)); + ("is_one_byte", M.read (| is_one_byte |)); + ("is_two_bytes", M.read (| is_two_bytes |)); + ("is_four_bytes", M.read (| is_four_bytes |)); + ("is_eight_bytes", M.read (| is_eight_bytes |)); + ("is_i32", M.read (| is_i32 |)); + ("memory_table_lookup_stack_read_pos", + M.read (| memory_table_lookup_stack_read_pos |)); + ("memory_table_lookup_stack_read_val", + M.read (| memory_table_lookup_stack_read_val |)); + ("memory_table_lookup_heap_read1", + M.read (| memory_table_lookup_heap_read1 |)); + ("memory_table_lookup_heap_read2", + M.read (| memory_table_lookup_heap_read2 |)); + ("memory_table_lookup_heap_write1", + M.read (| memory_table_lookup_heap_write1 |)); + ("memory_table_lookup_heap_write2", + M.read (| memory_table_lookup_heap_write2 |)); + ("lookup_pow_power", M.read (| lookup_pow_power |)); + ("lookup_pow_modulus", M.read (| lookup_pow_modulus |)); + ("address_within_allocated_pages_helper", + M.read (| address_within_allocated_pages_helper |)); + ("load_tailing_diff", M.read (| load_tailing_diff |)); + ("bytes", M.read (| bytes |)); + ("len_modulus", M.read (| len_modulus |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_store_StoreConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_store_StoreConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + let store_size = self.is_eight_bytes.expr(meta) * constant_from!(3) + + self.is_four_bytes.expr(meta) * constant_from!(2) + + self.is_two_bytes.expr(meta) * constant_from!(1) + + constant_from!(1); + + constant!(bn_to_field( + &(BigUint::from(OpcodeClass::Store as u64) << OPCODE_CLASS_SHIFT) + )) + self.is_i32.expr(meta) + * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG0_SHIFT))) + + store_size * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG1_SHIFT))) + + self.opcode_store_offset.expr(meta) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.read (| + let store_size := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "is_eight_bytes" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 3 |)) |) ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "is_four_bytes" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 2 |)) |) ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "is_two_bytes" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 24 + |)) + ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_CLASS_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "is_i32" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| store_size |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG1_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "opcode_store_offset" + |); + M.read (| meta |) + ] + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match entry.eentry.step_info { + StepInfo::Store { + vtype, + store_size, + offset, + raw_address, + effective_address, + pre_block_value1, + updated_block_value1, + pre_block_value2, + updated_block_value2, + value, + } => { + let len = store_size.byte_size() as u32; + + self.opcode_store_offset.assign(ctx, offset)?; + + let inner_byte_index = byte_offset_from_address(effective_address); + let block_start_index = block_from_address(effective_address); + + self.load_block_index.assign(ctx, block_start_index)?; + self.load_block_inner_pos + .assign_u32(ctx, inner_byte_index)?; + self.load_block_inner_pos_bits[0].assign_bool(ctx, inner_byte_index & 1 != 0)?; + self.load_block_inner_pos_bits[1].assign_bool(ctx, inner_byte_index & 2 != 0)?; + self.load_block_inner_pos_bits[2].assign_bool(ctx, inner_byte_index & 4 != 0)?; + + let len_modulus = BigUint::from(1u64) << (len * 8); + self.len_modulus.assign_bn(ctx, &len_modulus)?; + + let pos_modulus = 1 << (inner_byte_index * 8); + self.lookup_pow_modulus.assign(ctx, pos_modulus.into())?; + self.lookup_pow_power.assign_bn( + ctx, + &pow_table_power_encode(BigUint::from(inner_byte_index * 8)), + )?; + + let is_cross_block = inner_byte_index + len > WASM_BLOCK_BYTE_SIZE; + self.is_cross_block.assign_bool(ctx, is_cross_block)?; + let rem = (inner_byte_index + len - 1) & WASM_BLOCK_BYTE_OFFSET_MASK; + self.cross_block_rem.assign_u32(ctx, rem)?; + self.cross_block_rem_diff + .assign_u32(ctx, WASM_BLOCK_BYTE_SIZE - 1 - rem)?; + + let tailing_bits = inner_byte_index * 8; + let picked_bits = len * 8; + let load_value: BigUint = + (BigUint::from(pre_block_value2) << 64) + pre_block_value1; + let tailing: u64 = load_value.to_u64_digits().first().unwrap_or(&0u64).clone() + & ((1 << tailing_bits) - 1); + let picked: u64 = ((&load_value >> tailing_bits) + & ((BigUint::from(1u64) << picked_bits) - 1u64)) + .to_u64_digits() + .first() + .unwrap_or(&0u64) + .clone(); + let leading: u64 = (load_value >> (picked_bits + tailing_bits)) + .to_u64_digits() + .first() + .unwrap_or(&0u64) + .clone(); + + self.load_tailing.assign(ctx, tailing)?; + self.load_tailing_diff + .assign(ctx, pos_modulus - 1 - tailing)?; + self.load_picked.assign(ctx, picked)?; + if len == 1 { + self.load_picked_byte_proof.assign(ctx, picked.into())?; + } + self.load_leading.assign(ctx, leading)?; + + self.unchanged_value.assign_bn( + ctx, + &((BigUint::from(leading) << ((inner_byte_index + len) * 8)) + tailing), + )?; + + self.store_value.assign(ctx, value)?; + self.store_value_tailing_u16_u8_low + .assign(ctx, (value & 0xff).into())?; + self.store_value_tailing_u16_u8_high + .assign(ctx, ((value >> 8) & 0xff).into())?; + let value_wrapped = if len == 8 { + value + } else { + value & ((1 << (len * 8)) - 1) + }; + self.store_value_wrapped.assign(ctx, value_wrapped.into())?; + + self.is_one_byte.assign_bool(ctx, len == 1)?; + self.is_two_bytes.assign_bool(ctx, len == 2)?; + self.is_four_bytes.assign_bool(ctx, len == 4)?; + self.is_eight_bytes.assign_bool(ctx, len == 8)?; + self.bytes.assign(ctx, (len as u64).into())?; + self.is_i32.assign_bool(ctx, vtype == VarType::I32)?; + + self.address_within_allocated_pages_helper.assign_u32( + ctx, + step.current.allocated_memory_pages * WASM_BLOCKS_PER_PAGE + - (block_start_index + is_cross_block as u32 + 1), + )?; + + self.memory_table_lookup_stack_read_val.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + vtype == VarType::I32, + value as u64, + )?; + + self.memory_table_lookup_stack_read_pos.assign( + ctx, + entry.memory_rw_entires[1].start_eid, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + step.current.sp + 2, + LocationType::Stack, + true, + raw_address as u64, + )?; + + self.memory_table_lookup_heap_read1.assign( + ctx, + entry.memory_rw_entires[2].start_eid, + step.current.eid, + entry.memory_rw_entires[2].end_eid, + effective_address >> 3, + LocationType::Heap, + false, + pre_block_value1, + )?; + + self.memory_table_lookup_heap_write1.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[3].end_eid, + effective_address >> 3, + LocationType::Heap, + false, + updated_block_value1, + )?; + + if is_cross_block { + self.memory_table_lookup_heap_read2.assign( + ctx, + entry.memory_rw_entires[4].start_eid, + step.current.eid, + entry.memory_rw_entires[4].end_eid, + (effective_address >> 3) + 1, + LocationType::Heap, + false, + pre_block_value2, + )?; + + self.memory_table_lookup_heap_write2.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[5].end_eid, + (effective_address >> 3) + 1, + LocationType::Heap, + false, + updated_block_value2, + )?; + } + Ok(()) + } + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "vtype" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "store_size" + |) in + let γ0_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "offset" + |) in + let γ0_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "raw_address" + |) in + let γ0_4 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "effective_address" + |) in + let γ0_5 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "pre_block_value1" + |) in + let γ0_6 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "updated_block_value1" + |) in + let γ0_7 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "pre_block_value2" + |) in + let γ0_8 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "updated_block_value2" + |) in + let γ0_9 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "value" + |) in + let vtype := M.copy (| γ0_0 |) in + let store_size := M.copy (| γ0_1 |) in + let offset := M.copy (| γ0_2 |) in + let raw_address := M.copy (| γ0_3 |) in + let effective_address := M.copy (| γ0_4 |) in + let pre_block_value1 := M.copy (| γ0_5 |) in + let updated_block_value1 := M.copy (| γ0_6 |) in + let pre_block_value2 := M.copy (| γ0_7 |) in + let updated_block_value2 := M.copy (| γ0_8 |) in + let value := M.copy (| γ0_9 |) in + let len := + M.alloc (| + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path "specs::mtable::MemoryStoreSize", + "byte_size", + [] + |), + [ store_size ] + |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "opcode_store_offset" + |); + M.read (| ctx |); + M.read (| offset |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let inner_byte_index := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::mtable::utils::byte_offset_from_address", + [] + |), + [ M.read (| effective_address |) ] + |) + |) in + let block_start_index := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::mtable::utils::block_from_address", + [] + |), + [ M.read (| effective_address |) ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "load_block_index" + |); + M.read (| ctx |); + M.read (| block_start_index |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "load_block_inner_pos" + |); + M.read (| ctx |); + M.read (| inner_byte_index |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "load_block_inner_pos_bits" + |), + M.alloc (| Value.Integer 0 |) + |); + M.read (| ctx |); + BinOp.Pure.ne + (BinOp.Pure.bit_and + (M.read (| inner_byte_index |)) + (Value.Integer 1)) + (Value.Integer 0) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "load_block_inner_pos_bits" + |), + M.alloc (| Value.Integer 1 |) + |); + M.read (| ctx |); + BinOp.Pure.ne + (BinOp.Pure.bit_and + (M.read (| inner_byte_index |)) + (Value.Integer 2)) + (Value.Integer 0) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "load_block_inner_pos_bits" + |), + M.alloc (| Value.Integer 2 |) + |); + M.read (| ctx |); + BinOp.Pure.ne + (BinOp.Pure.bit_and + (M.read (| inner_byte_index |)) + (Value.Integer 4)) + (Value.Integer 0) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let len_modulus := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + BinOp.Panic.mul (| + Integer.U32, + M.read (| len |), + Value.Integer 8 + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_bn", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "len_modulus" + |); + M.read (| ctx |); + len_modulus + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let pos_modulus := + M.alloc (| + BinOp.Panic.shl (| + Value.Integer 1, + BinOp.Panic.mul (| + Integer.U32, + M.read (| inner_byte_index |), + Value.Integer 8 + |) + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "lookup_pow_modulus" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| pos_modulus |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_bn", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "lookup_pow_power" + |); + M.read (| ctx |); + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::rtable::pow_table_power_encode", + [ Ty.path "num_bigint::biguint::BigUint" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "from", + [] + |), + [ + BinOp.Panic.mul (| + Integer.U32, + M.read (| inner_byte_index |), + Value.Integer 8 + |) + ] + |) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let is_cross_block := + M.alloc (| + BinOp.Pure.gt + (BinOp.Panic.add (| + Integer.U32, + M.read (| inner_byte_index |), + M.read (| len |) + |)) + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::utils::WASM_BLOCK_BYTE_SIZE" + |) + |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "is_cross_block" + |); + M.read (| ctx |); + M.read (| is_cross_block |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let rem := + M.alloc (| + BinOp.Pure.bit_and + (BinOp.Panic.sub (| + Integer.U32, + BinOp.Panic.add (| + Integer.U32, + M.read (| inner_byte_index |), + M.read (| len |) + |), + Value.Integer 1 + |)) + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::utils::WASM_BLOCK_BYTE_OFFSET_MASK" + |) + |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "cross_block_rem" + |); + M.read (| ctx |); + M.read (| rem |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "cross_block_rem_diff" + |); + M.read (| ctx |); + BinOp.Panic.sub (| + Integer.U32, + BinOp.Panic.sub (| + Integer.U32, + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::utils::WASM_BLOCK_BYTE_SIZE" + |) + |), + Value.Integer 1 + |), + M.read (| rem |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let tailing_bits := + M.alloc (| + BinOp.Panic.mul (| + Integer.U32, + M.read (| inner_byte_index |), + Value.Integer 8 + |) + |) in + let picked_bits := + M.alloc (| + BinOp.Panic.mul (| + Integer.U32, + M.read (| len |), + Value.Integer 8 + |) + |) in + let load_value := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "i32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| pre_block_value2 |) ] + |); + Value.Integer 64 + ] + |); + M.read (| pre_block_value1 |) + ] + |) + |) in + let tailing := + M.alloc (| + BinOp.Pure.bit_and + (M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "u64", + [], + "clone", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.path "u64" ] ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u64" ], + "first", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "num_bigint::biguint::BigUint", + "to_u64_digits", + [] + |), + [ load_value ] + |) + |) + ] + |) + ] + |); + M.alloc (| Value.Integer 0 |) + ] + |) + ] + |)) + (BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.shl (| + Value.Integer 1, + M.read (| tailing_bits |) + |), + Value.Integer 1 + |)) + |) in + let picked := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "u64", + [], + "clone", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.path "u64" ] ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u64" ], + "first", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "num_bigint::biguint::BigUint", + "to_u64_digits", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::BitAnd", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "bitand", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shr", + Ty.apply + (Ty.path "&") + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + [ Ty.path "u32" ], + "shr", + [] + |), + [ + load_value; + M.read (| tailing_bits |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| picked_bits |) + ] + |); + Value.Integer 1 + ] + |) + ] + |) + |) + ] + |) + |) + ] + |) + ] + |); + M.alloc (| Value.Integer 0 |) + ] + |) + ] + |) + |) in + let leading := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "u64", + [], + "clone", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.path "u64" ] ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u64" ], + "first", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "num_bigint::biguint::BigUint", + "to_u64_digits", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shr", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shr", + [] + |), + [ + M.read (| load_value |); + BinOp.Panic.add (| + Integer.U32, + M.read (| picked_bits |), + M.read (| tailing_bits |) + |) + ] + |) + |) + ] + |) + |) + ] + |) + ] + |); + M.alloc (| Value.Integer 0 |) + ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "load_tailing" + |); + M.read (| ctx |); + M.read (| tailing |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "load_tailing_diff" + |); + M.read (| ctx |); + BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.sub (| + Integer.U64, + M.read (| pos_modulus |), + Value.Integer 1 + |), + M.read (| tailing |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "load_picked" + |); + M.read (| ctx |); + M.read (| picked |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq (M.read (| len |)) (Value.Integer 1) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "load_picked_byte_proof" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| picked |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "load_leading" + |); + M.read (| ctx |); + M.read (| leading |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign_bn", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "unchanged_value" + |); + M.read (| ctx |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| leading |) ] + |); + BinOp.Panic.mul (| + Integer.U32, + BinOp.Panic.add (| + Integer.U32, + M.read (| inner_byte_index |), + M.read (| len |) + |), + Value.Integer 8 + |) + ] + |); + M.read (| tailing |) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "store_value" + |); + M.read (| ctx |); + M.read (| value |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "store_value_tailing_u16_u8_low" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ + BinOp.Pure.bit_and + (M.read (| value |)) + (Value.Integer 255) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU8Cell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "store_value_tailing_u16_u8_high" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ + BinOp.Pure.bit_and + (BinOp.Panic.shr (| + M.read (| value |), + Value.Integer 8 + |)) + (Value.Integer 255) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let value_wrapped := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq (M.read (| len |)) (Value.Integer 8) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + value)); + fun γ => + ltac:(M.monadic + (M.alloc (| + BinOp.Pure.bit_and + (M.read (| value |)) + (BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.shl (| + Value.Integer 1, + BinOp.Panic.mul (| + Integer.U32, + M.read (| len |), + Value.Integer 8 + |) + |), + Value.Integer 1 + |)) + |))) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "store_value_wrapped" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| value_wrapped |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "is_one_byte" + |); + M.read (| ctx |); + BinOp.Pure.eq (M.read (| len |)) (Value.Integer 1) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "is_two_bytes" + |); + M.read (| ctx |); + BinOp.Pure.eq (M.read (| len |)) (Value.Integer 2) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "is_four_bytes" + |); + M.read (| ctx |); + BinOp.Pure.eq (M.read (| len |)) (Value.Integer 4) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "is_eight_bytes" + |); + M.read (| ctx |); + BinOp.Pure.eq (M.read (| len |)) (Value.Integer 8) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "bytes" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.rust_cast (M.read (| len |)) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "is_i32" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + vtype; + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "address_within_allocated_pages_helper" + |); + M.read (| ctx |); + BinOp.Panic.sub (| + Integer.U32, + BinOp.Panic.mul (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "allocated_memory_pages" + |) + |), + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::utils::WASM_BLOCKS_PER_PAGE" + |) + |) + |), + BinOp.Panic.add (| + Integer.U32, + BinOp.Panic.add (| + Integer.U32, + M.read (| block_start_index |), + M.rust_cast (M.read (| is_cross_block |)) + |), + Value.Integer 1 + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "memory_table_lookup_stack_read_val" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + vtype; + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| M.use value |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "memory_table_lookup_stack_read_pos" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 2 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool true; + M.rust_cast (M.read (| raw_address |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "memory_table_lookup_heap_read1" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 2 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 2 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.shr (| + M.read (| effective_address |), + Value.Integer 3 + |); + Value.StructTuple + "specs::mtable::LocationType::Heap" + []; + Value.Bool false; + M.read (| pre_block_value1 |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "memory_table_lookup_heap_write1" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 3 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.shr (| + M.read (| effective_address |), + Value.Integer 3 + |); + Value.StructTuple + "specs::mtable::LocationType::Heap" + []; + Value.Bool false; + M.read (| updated_block_value1 |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use is_cross_block in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "memory_table_lookup_heap_read2" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 4 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 4 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + BinOp.Panic.shr (| + M.read (| effective_address |), + Value.Integer 3 + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Heap" + []; + Value.Bool false; + M.read (| pre_block_value2 |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "memory_table_lookup_heap_write2" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 5 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + BinOp.Panic.shr (| + M.read (| effective_address |), + Value.Integer 3 + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Heap" + []; + Value.Bool false; + M.read (| updated_block_value2 |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(2)) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 2 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn mops(&self, meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1) + self.is_cross_block.expr(meta)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_store::StoreConfig", + "is_cross_block" + |); + M.read (| meta |) + ] + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, entry: &EventTableEntry) -> u32 { + match entry.step_info { + StepInfo::Store { + store_size, + effective_address, + .. + } => { + let is_cross_block = (effective_address as u64 & 7) + store_size.byte_size() > 8; + if is_cross_block { + 2 + } else { + 1 + } + } + _ => unreachable!(), + } + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let entry := M.alloc (| entry |) in + M.read (| + M.match_operator (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "specs::etable::EventTableEntry", + "step_info" + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "store_size" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "effective_address" + |) in + let store_size := M.copy (| γ0_0 |) in + let effective_address := M.copy (| γ0_1 |) in + let is_cross_block := + M.alloc (| + BinOp.Pure.gt + (BinOp.Panic.add (| + Integer.U64, + BinOp.Pure.bit_and + (M.rust_cast (M.read (| effective_address |))) + (Value.Integer 7), + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::mtable::MemoryStoreSize", + "byte_size", + [] + |), + [ store_size ] + |) + |)) + (Value.Integer 8) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use is_cross_block in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| Value.Integer 2 |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Integer 1 |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("sp_diff", InstanceField.Method (sp_diff F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_store_StoreConfig_F. + End op_store. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_test.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_test.v new file mode 100644 index 000000000..1109e4e2e --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_test.v @@ -0,0 +1,2353 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_test. + (* StructRecord + { + name := "TestConfig"; + ty_params := [ "F" ]; + fields := + [ + ("is_i32_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("res_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("value_inv_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("value_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("memory_table_lookup_stack_read", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_write", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "TestConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_test_TestConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_test::TestConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let is_i32_cell = allocator.alloc_bit_cell(); + let res_cell = allocator.alloc_bit_cell(); + let value_cell = allocator.alloc_u64_cell(); + let value_inv_cell = allocator.alloc_unlimited_cell(); + + constraint_builder.constraints.push(( + "op_test res = !value", + Box::new(move |meta| { + vec![ + res_cell.expr(meta) * value_cell.u64_cell.expr(meta), + value_cell.u64_cell.expr(meta) * value_inv_cell.expr(meta) - constant_from!(1) + + res_cell.expr(meta), + ] + }), + )); + + let eid = common_config.eid_cell; + let sp = common_config.sp_cell; + + let memory_table_lookup_stack_read = allocator.alloc_memory_table_lookup_read_cell( + "op_test stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |meta| is_i32_cell.expr(meta), + move |meta| value_cell.u64_cell.expr(meta), + move |____| constant_from!(1), + ); + + let memory_table_lookup_stack_write = allocator.alloc_memory_table_lookup_write_cell( + "op_test stack write", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |____| constant_from!(1), + move |meta| res_cell.expr(meta), + move |____| constant_from!(1), + ); + + Box::new(TestConfig { + is_i32_cell, + res_cell, + value_inv_cell, + value_cell, + memory_table_lookup_stack_read, + memory_table_lookup_stack_write, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let is_i32_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let res_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let value_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let value_inv_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| constraint_builder |), + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder", + "constraints" + |); + Value.Tuple + [ + M.read (| Value.String "op_test res = !value" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value_cell, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value_cell, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + value_inv_cell; + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + res_cell; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + ] + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let memory_table_lookup_stack_read := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_test stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value_cell, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let memory_table_lookup_stack_write := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_test stack write" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ res_cell; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_test::TestConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_test::TestConfig" + [ + ("is_i32_cell", M.read (| is_i32_cell |)); + ("res_cell", M.read (| res_cell |)); + ("value_inv_cell", M.read (| value_inv_cell |)); + ("value_cell", M.read (| value_cell |)); + ("memory_table_lookup_stack_read", + M.read (| memory_table_lookup_stack_read |)); + ("memory_table_lookup_stack_write", + M.read (| memory_table_lookup_stack_write |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_test_TestConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_test_TestConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_test::TestConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + constant!(bn_to_field( + &(BigUint::from(OpcodeClass::Test as u64) << OPCODE_CLASS_SHIFT) + )) + constant_from!(TestOp::Eqz as u16) + * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG0_SHIFT))) + + self.is_i32_cell.expr(meta) + * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG1_SHIFT))) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 13 + |)) + ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_CLASS_SHIFT" |) + |) + ] + |) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (M.rust_cast (Value.Integer 0)) ] + |) + ]; + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_ARG0_SHIFT" |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_test::TestConfig", + "is_i32_cell" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_ARG1_SHIFT" |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::Test { + vtype, + value, + result, + } => { + self.is_i32_cell.assign_u32(ctx, *vtype as u32)?; + + self.value_cell.assign(ctx, *value)?; + self.value_inv_cell + .assign(ctx, F::from( *value).invert().unwrap_or(F::zero()))?; + self.res_cell.assign_u32(ctx, *result as u32)?; + + self.memory_table_lookup_stack_read.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + *vtype == VarType::I32, + *value, + )?; + + self.memory_table_lookup_stack_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + step.current.sp + 1, + LocationType::Stack, + true, + *result as u32 as u64, + )?; + + Ok(()) + } + + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Test", + "vtype" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Test", + "value" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Test", + "result" + |) in + let vtype := M.alloc (| γ1_0 |) in + let value := M.alloc (| γ1_1 |) in + let result := M.alloc (| γ1_2 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_test::TestConfig", + "is_i32_cell" + |); + M.read (| ctx |); + M.rust_cast (M.read (| M.read (| vtype |) |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_test::TestConfig", + "value_cell" + |); + M.read (| ctx |); + M.read (| M.read (| value |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_test::TestConfig", + "value_inv_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "subtle::CtOption") [ F ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "invert", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.read (| value |) |) ] + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_u32", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_test::TestConfig", + "res_cell" + |); + M.read (| ctx |); + M.rust_cast (M.read (| M.read (| result |) |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_test::TestConfig", + "memory_table_lookup_stack_read" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.read (| vtype |); + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |); + M.read (| M.read (| value |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_test::TestConfig", + "memory_table_lookup_stack_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool true; + M.rust_cast + (M.rust_cast (M.read (| M.read (| result |) |))) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn mops(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, _: &EventTableEntry) -> u32 { + 1 + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Integer 1)) ] |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_test_TestConfig_F. + End op_test. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/op_unary.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_unary.v new file mode 100644 index 000000000..dfc7a26d2 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/op_unary.v @@ -0,0 +1,7283 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module etable. + Module op_configure. + Module op_unary. + (* StructRecord + { + name := "UnaryConfig"; + ty_params := [ "F" ]; + fields := + [ + ("operand_inv", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("bits", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("operand_is_zero", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_ctz", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_clz", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_popcnt", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_i32", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("aux1", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("aux2", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("lookup_pow_modulus", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("lookup_pow_power", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("bit_table_lookup", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells") + [ F ]); + ("ctz_degree_helper", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("memory_table_lookup_stack_read", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("memory_table_lookup_stack_write", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructTuple + { + name := "UnaryConfigBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_unary_UnaryConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfigBuilder". + + (* + fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> { + let operand_is_zero = allocator.alloc_bit_cell(); + let operand_inv = allocator.alloc_unlimited_cell(); + let bits = allocator.alloc_unlimited_cell(); + + let is_ctz = allocator.alloc_bit_cell(); + let is_clz = allocator.alloc_bit_cell(); + let is_popcnt = allocator.alloc_bit_cell(); + let is_i32 = allocator.alloc_bit_cell(); + + let aux1 = allocator.alloc_u64_cell(); + let aux2 = allocator.alloc_u64_cell(); + + let ctz_degree_helper = allocator.alloc_unlimited_cell(); + + let lookup_pow_modulus = common_config.pow_table_lookup_modulus_cell; + let lookup_pow_power = common_config.pow_table_lookup_power_cell; + let lookup_popcnt = common_config.bit_table_lookup_cells; + + let eid = common_config.eid_cell; + let sp = common_config.sp_cell; + + let memory_table_lookup_stack_read = allocator + .alloc_memory_table_lookup_read_cell_with_value( + "op_unary stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |meta| is_i32.expr(meta), + move |____| constant_from!(1), + ); + let operand = memory_table_lookup_stack_read.value_cell; + + let memory_table_lookup_stack_write = allocator + .alloc_memory_table_lookup_write_cell_with_value( + "op_unary stack write", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |meta| is_i32.expr(meta), + move |____| constant_from!(1), + ); + let result = memory_table_lookup_stack_write.value_cell; + + constraint_builder.push( + "op_unary: selector", + Box::new(move |meta| { + vec![ + (is_ctz.expr(meta) + is_clz.expr(meta) + is_popcnt.expr(meta) + - constant_from!(1)), + ] + }), + ); + + constraint_builder.push( + "op_unary: zero cond", + Box::new(move |meta| { + vec![ + operand_is_zero.expr(meta) * operand.expr(meta), + operand.expr(meta) * operand_inv.expr(meta) - constant_from!(1) + + operand_is_zero.expr(meta), + ] + }), + ); + + constraint_builder.push( + "op_unary: bits", + Box::new(move |meta| { + vec![bits.expr(meta) - constant_from!(64) + constant_from!(32) * is_i32.expr(meta)] + }), + ); + + constraint_builder.push( + "op_unary: clz", + Box::new(move |meta| { + let operand_is_not_zero = constant_from!(1) - operand_is_zero.expr(meta); + + vec![ + operand_is_zero.expr(meta) * (result.expr(meta) - bits.expr(meta)), + operand_is_not_zero.clone() + * (lookup_pow_modulus.expr(meta) + aux1.u64_cell.expr(meta) + - operand.expr(meta)), + operand_is_not_zero.clone() + * (aux1.u64_cell.expr(meta) + aux2.u64_cell.expr(meta) + constant_from!(1) + - lookup_pow_modulus.expr(meta)), + operand_is_not_zero + * (lookup_pow_power.expr(meta) + - pow_table_power_encode( + bits.expr(meta) - result.expr(meta) - constant_from!(1), + )), + ] + .into_iter() + .map(|constraint| constraint * is_clz.expr(meta)) + .collect() + }), + ); + + constraint_builder.push( + "op_unary: ctz", + Box::new(move |meta| { + let operand_is_not_zero = constant_from!(1) - operand_is_zero.expr(meta); + + vec![ + ctz_degree_helper.expr(meta) + - (aux1.u64_cell.expr(meta) + * lookup_pow_modulus.expr(meta) + * constant_from!(2)), + operand_is_zero.expr(meta) * (result.expr(meta) - bits.expr(meta)), + operand_is_not_zero + * (ctz_degree_helper.expr(meta) + lookup_pow_modulus.expr(meta) + - operand.expr(meta)), + lookup_pow_power.expr(meta) - pow_table_power_encode(result.expr(meta)), + ] + .into_iter() + .map(|constraint| constraint * is_ctz.expr(meta)) + .collect() + }), + ); + + constraint_builder.push( + "op_unary: lookup popcnt", + Box::new(move |meta| { + vec![ + lookup_popcnt.op.expr(meta) - constant_from!(BitTableOp::Popcnt.index()), + lookup_popcnt.left.expr(meta) - operand.expr(meta), + lookup_popcnt.result.expr(meta) - result.expr(meta), + ] + .into_iter() + .map(|constraint| constraint * is_popcnt.expr(meta)) + .collect() + }), + ); + + Box::new(UnaryConfig { + operand_inv, + bits, + operand_is_zero, + is_ctz, + is_clz, + is_popcnt, + is_i32, + aux1, + aux2, + lookup_pow_modulus, + lookup_pow_power, + ctz_degree_helper, + bit_table_lookup: lookup_popcnt, + memory_table_lookup_stack_read, + memory_table_lookup_stack_write, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ common_config; allocator; constraint_builder ] => + ltac:(M.monadic + (let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let operand_is_zero := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let operand_inv := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let bits := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_ctz := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_clz := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_popcnt := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_i32 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let aux1 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let aux2 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let ctz_degree_helper := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let lookup_pow_modulus := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "pow_table_lookup_modulus_cell" + |) + |) in + let lookup_pow_power := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "pow_table_lookup_power_cell" + |) + |) in + let lookup_popcnt := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "bit_table_lookup_cells" + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let memory_table_lookup_stack_read := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell_with_value", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_unary stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let operand := + M.copy (| + M.SubPointer.get_struct_record_field (| + memory_table_lookup_stack_read, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell", + "value_cell" + |) + |) in + let memory_table_lookup_stack_write := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell_with_value", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "op_unary stack write" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_i32; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let result := + M.copy (| + M.SubPointer.get_struct_record_field (| + memory_table_lookup_stack_write, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell", + "value_cell" + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_unary: selector" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_ctz; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_clz; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_popcnt; + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_unary: zero cond" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + operand_is_zero; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + operand; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + operand; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + operand_inv; + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + operand_is_zero; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_unary: bits" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + bits; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 64 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 32 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_i32; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_unary: clz" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let operand_is_not_zero := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer 1 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ operand_is_zero; M.read (| meta |) ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ + Ty.path + "alloc::alloc::Global" + ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + operand_is_zero; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ + F + ], + [ F + ], + "expr", + [] + |), + [ + result; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ + F + ], + [ F + ], + "expr", + [] + |), + [ + bits; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ + operand_is_not_zero + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ + F + ], + [ + F + ], + "expr", + [] + |), + [ + lookup_pow_modulus; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ + F + ], + [ + F + ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + aux1, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ + F + ], + [ F + ], + "expr", + [] + |), + [ + operand; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ + operand_is_not_zero + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ + F + ], + [ + F + ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + aux1, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ + F + ], + [ + F + ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + aux2, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ + F + ], + [ F + ], + "expr", + [] + |), + [ + lookup_pow_modulus; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| + operand_is_not_zero + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ + F + ], + [ F + ], + "expr", + [] + |), + [ + lookup_pow_power; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::rtable::pow_table_power_encode", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ + F + ], + [ + F + ], + "expr", + [] + |), + [ + bits; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ + F + ], + [ + F + ], + "expr", + [] + |), + [ + result; + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let constraint := + M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| + constraint + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_clz; + M.read (| + meta + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_unary: ctz" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let operand_is_not_zero := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer 1 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ operand_is_zero; M.read (| meta |) ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ + Ty.path + "alloc::alloc::Global" + ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + ctz_degree_helper; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ + F + ], + [ + F + ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + aux1, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ + F + ], + [ + F + ], + "expr", + [] + |), + [ + lookup_pow_modulus; + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 2 + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + operand_is_zero; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ + F + ], + [ F + ], + "expr", + [] + |), + [ + result; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ + F + ], + [ F + ], + "expr", + [] + |), + [ + bits; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| + operand_is_not_zero + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ + F + ], + [ + F + ], + "expr", + [] + |), + [ + ctz_degree_helper; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ + F + ], + [ + F + ], + "expr", + [] + |), + [ + lookup_pow_modulus; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ + F + ], + [ F + ], + "expr", + [] + |), + [ + operand; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + lookup_pow_power; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::rtable::pow_table_power_encode", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ + F + ], + [ F + ], + "expr", + [] + |), + [ + result; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let constraint := + M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| + constraint + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_ctz; + M.read (| + meta + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "op_unary: lookup popcnt" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lookup_popcnt, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells", + "op" + |); + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::bit_table::BitTableOp", + "index", + [] + |), + [ + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::bit_table::BitTableOp::Popcnt" + [] + |) + ] + |)) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lookup_popcnt, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells", + "left" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + operand; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + lookup_popcnt, + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells", + "result" + |); + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + result; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let constraint := + M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| + constraint + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_popcnt; + M.read (| meta |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig" + [ + ("operand_inv", M.read (| operand_inv |)); + ("bits", M.read (| bits |)); + ("operand_is_zero", M.read (| operand_is_zero |)); + ("is_ctz", M.read (| is_ctz |)); + ("is_clz", M.read (| is_clz |)); + ("is_popcnt", M.read (| is_popcnt |)); + ("is_i32", M.read (| is_i32 |)); + ("aux1", M.read (| aux1 |)); + ("aux2", M.read (| aux2 |)); + ("lookup_pow_modulus", M.read (| lookup_pow_modulus |)); + ("lookup_pow_power", M.read (| lookup_pow_power |)); + ("ctz_degree_helper", M.read (| ctz_degree_helper |)); + ("bit_table_lookup", M.read (| lookup_popcnt |)); + ("memory_table_lookup_stack_read", + M.read (| memory_table_lookup_stack_read |)); + ("memory_table_lookup_stack_write", + M.read (| memory_table_lookup_stack_write |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_unary_UnaryConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_unary_UnaryConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + macro_rules! op_expr { + ($op: expr, $field: ident) => { + self.$field.expr(meta) + * constant!(bn_to_field( + &(BigUint::from($op as u64) << OPCODE_ARG0_SHIFT) + )) + }; + } + + let opcode_class = constant!(bn_to_field( + &(BigUint::from(OpcodeClass::Unary as u64) << OPCODE_CLASS_SHIFT) + )); + let var_type = self.is_i32.expr(meta) + * constant!(bn_to_field(&(BigUint::from(1u64) << OPCODE_ARG1_SHIFT))); + let op = op_expr!(UnaryOp::Ctz, is_ctz) + + op_expr!(UnaryOp::Clz, is_clz) + + op_expr!(UnaryOp::Popcnt, is_popcnt); + + opcode_class + var_type + op + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.read (| + let opcode_class := + M.alloc (| + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 10 + |)) + ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_CLASS_SHIFT" |) + |) + ] + |) + |) + ] + |) + ] + |) in + let var_type := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "is_i32" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 1 ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_ARG1_SHIFT" |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + |) in + let op := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "is_ctz" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 0) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "is_clz" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 1) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "is_popcnt" + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (Value.Integer 2) ] + |); + M.read (| + M.get_constant (| + "specs::itable::OPCODE_ARG0_SHIFT" + |) + |) + ] + |) + |) + ] + |) + ] + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ M.read (| opcode_class |); M.read (| var_type |) ] + |); + M.read (| op |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::UnaryOp { + class, + vtype, + operand, + result, + } => { + self.is_i32.assign_bool(ctx, *vtype == VarType::I32)?; + + self.operand_inv + .assign(ctx, F::from( *operand).invert().unwrap_or(F::zero()))?; + self.operand_is_zero.assign_bool(ctx, *operand == 0)?; + + let (bits, max) = if *vtype == VarType::I32 { + (32, 1u128 << 32) + } else { + (64, 1u128 << 64) + }; + self.bits.assign(ctx, F::from(bits))?; + + match class { + UnaryOp::Ctz => { + self.is_ctz.assign_bool(ctx, true)?; + + /* + * 0000 0100 0000 1000 + * |____________| |__| + * hd boundary + * + */ + let least_one_pos = *result; + let hd = ( *operand) + .checked_shr(least_one_pos as u32 + 1) + .unwrap_or(0); + let boundary = bn_to_field(&BigUint::from(1u128 << least_one_pos)); + + self.aux1.assign(ctx, hd)?; + self.lookup_pow_modulus.assign(ctx, boundary)?; + self.lookup_pow_power.assign( + ctx, + bn_to_field(&pow_table_power_encode(BigUint::from(least_one_pos))), + )?; + + self.ctz_degree_helper + .assign(ctx, F::from(hd) * boundary * F::from(2))?; + } + UnaryOp::Clz => { + self.is_clz.assign_bool(ctx, true)?; + + /* + * operand: + * 0000 0100 0000 1000 + * aux1: tail of operand + * i.e. 00 0000 1000 + * boundary: operand minus tail + * i.e. 100 0000 0000 + * aux2: make sure aux1(tail) is less than boundary + * boundary - aux1 - 1 + */ + let boundary = max.checked_shr(1 + *result as u32).unwrap_or(0) as u64; + let tail = *operand ^ boundary; + + self.lookup_pow_modulus + .assign(ctx, F::from(boundary as u64))?; + self.aux1.assign(ctx, tail)?; + // If `operand = 0``, then `boundary == tail == 0`` and therefore `- 1` will panic in debug mode. + // Since `aux2`` is useless when `operand = 0`, we give 0. + let aux2 = (boundary - tail).checked_sub(1).unwrap_or(0); + self.aux2.assign(ctx, aux2)?; + if boundary != 0 { + self.lookup_pow_modulus.assign(ctx, boundary.into())?; + self.lookup_pow_power.assign( + ctx, + bn_to_field(&pow_table_power_encode(BigUint::from( + bits - *result - 1, + ))), + )?; + } + } + UnaryOp::Popcnt => { + self.is_popcnt.assign_bool(ctx, true)?; + + self.bit_table_lookup.assign( + ctx, + BitTableOp::Popcnt, + *operand, + 0, + *result, + )?; + } + } + + self.memory_table_lookup_stack_read.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + *vtype == VarType::I32, + *operand, + )?; + + self.memory_table_lookup_stack_write.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + step.current.sp + 1, + LocationType::Stack, + *vtype == VarType::I32, + *result as u32 as u64, + )?; + + Ok(()) + } + + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::UnaryOp", + "class" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::UnaryOp", + "vtype" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::UnaryOp", + "operand" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::UnaryOp", + "result" + |) in + let class := M.alloc (| γ1_0 |) in + let vtype := M.alloc (| γ1_1 |) in + let operand := M.alloc (| γ1_2 |) in + let result := M.alloc (| γ1_3 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "is_i32" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.read (| vtype |); + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "operand_inv" + |); + M.read (| ctx |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "subtle::CtOption") [ F ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "invert", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.read (| operand |) |) ] + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "operand_is_zero" + |); + M.read (| ctx |); + BinOp.Pure.eq + (M.read (| M.read (| operand |) |)) + (Value.Integer 0) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.match_operator (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.read (| vtype |); + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.Tuple + [ + Value.Integer 32; + BinOp.Panic.shl (| + Value.Integer 1, + Value.Integer 32 + |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple + [ + Value.Integer 64; + BinOp.Panic.shl (| + Value.Integer 1, + Value.Integer 64 + |) + ] + |))) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let bits := M.copy (| γ0_0 |) in + let max := M.copy (| γ0_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "bits" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| bits |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + class, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "is_ctz" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let least_one_pos := + M.copy (| M.read (| result |) |) in + let hd := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "u64", + "checked_shr", + [] + |), + [ + M.read (| M.read (| operand |) |); + BinOp.Panic.add (| + Integer.U32, + M.rust_cast + (M.read (| least_one_pos |)), + Value.Integer 1 + |) + ] + |); + Value.Integer 0 + ] + |) + |) in + let boundary := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u128" ], + "from", + [] + |), + [ + BinOp.Panic.shl (| + Value.Integer 1, + M.read (| least_one_pos |) + |) + ] + |) + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "aux1" + |); + M.read (| ctx |); + M.read (| hd |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "lookup_pow_modulus" + |); + M.read (| ctx |); + M.read (| boundary |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "lookup_pow_power" + |); + M.read (| ctx |); + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::rtable::pow_table_power_encode", + [ + Ty.path + "num_bigint::biguint::BigUint" + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + least_one_pos + |) + ] + |) + ] + |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "ctz_degree_helper" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ F ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ F ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| hd |) ] + |); + M.read (| boundary |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 2 ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "is_clz" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let boundary := + M.alloc (| + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u128" ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "u128", + "checked_shr", + [] + |), + [ + M.read (| max |); + BinOp.Panic.add (| + Integer.U32, + Value.Integer 1, + M.rust_cast + (M.read (| M.read (| result |) |)) + |) + ] + |); + Value.Integer 0 + ] + |)) + |) in + let tail := + M.alloc (| + BinOp.Pure.bit_xor + (M.read (| M.read (| operand |) |)) + (M.read (| boundary |)) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "lookup_pow_modulus" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use boundary |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "aux1" + |); + M.read (| ctx |); + M.read (| tail |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let aux2 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "u64", + "checked_sub", + [] + |), + [ + BinOp.Panic.sub (| + Integer.U64, + M.read (| boundary |), + M.read (| tail |) + |); + Value.Integer 1 + ] + |); + Value.Integer 0 + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "aux2" + |); + M.read (| ctx |); + M.read (| aux2 |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.read (| boundary |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "lookup_pow_modulus" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| boundary |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "lookup_pow_power" + |); + M.read (| ctx |); + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::rtable::pow_table_power_encode", + [ + Ty.path + "num_bigint::biguint::BigUint" + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ Ty.path "u64" + ], + "from", + [] + |), + [ + BinOp.Panic.sub (| + Integer.U64, + BinOp.Panic.sub (| + Integer.U64, + M.read (| + bits + |), + M.read (| + M.read (| + result + |) + |) + |), + Value.Integer + 1 + |) + ] + |) + ] + |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "is_popcnt" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedBitTableLookupCells") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "bit_table_lookup" + |); + M.read (| ctx |); + Value.StructTuple + "delphinus_zkwasm::circuits::bit_table::BitTableOp::Popcnt" + []; + M.read (| M.read (| operand |) |); + Value.Integer 0; + M.read (| M.read (| result |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "memory_table_lookup_stack_read" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.read (| vtype |); + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |); + M.read (| M.read (| operand |) |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::etable::op_configure::op_unary::UnaryConfig", + "memory_table_lookup_stack_write" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "eq", + [] + |), + [ + M.read (| vtype |); + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |) + ] + |); + M.rust_cast + (M.rust_cast + (M.read (| M.read (| result |) |))) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ] + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn mops(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, _: &EventTableEntry) -> u32 { + 1 + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; β1 ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let β1 := M.alloc (| β1 |) in + M.match_operator (| β1, [ fun γ => ltac:(M.monadic (Value.Integer 1)) ] |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_etable_op_configure_op_unary_UnaryConfig_F. + End op_unary. + End op_configure. + End etable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/etable/op_configure/simulations/op_bin.v b/CoqOfRust/zkWasm/circuits/etable/op_configure/simulations/op_bin.v new file mode 100644 index 000000000..a89329d1f --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/op_configure/simulations/op_bin.v @@ -0,0 +1,117 @@ +Require Import CoqOfRust.CoqOfRust. +Require Import simulations.M. + +Require Import zkWasm.circuits.etable.simulations.allocator. +Require Import zkWasm.circuits.etable.simulations.allocator_type. +Require Import zkWasm.circuits.etable.simulations.constraint_builder. +Require Import zkWasm.circuits.etable.simulations.mod. +Require Import zkWasm.circuits.simulations.cell. +Require Import zkWasm.simulations.state. + +Import simulations.M.Notations. + +(* pub struct BinConfig { + lhs: AllocatedU64CellWithFlagBitDyn, + rhs: AllocatedU64CellWithFlagBitDyn, + + is_i32: AllocatedBitCell, + + d: AllocatedU64Cell, + d_flag_helper_diff: AllocatedCommonRangeCell, + + aux1: AllocatedU64Cell, + aux2: AllocatedU64Cell, + + overflow: AllocatedBitCell, + is_add: AllocatedBitCell, + is_sub: AllocatedBitCell, + is_mul: AllocatedBitCell, + is_div_u: AllocatedBitCell, + is_rem_u: AllocatedBitCell, + is_div_s: AllocatedBitCell, + is_rem_s: AllocatedBitCell, + is_div_s_or_rem_s: AllocatedBitCell, + + res_flag: AllocatedUnlimitedCell, + size_modulus: AllocatedUnlimitedCell, + normalized_lhs: AllocatedUnlimitedCell, + normalized_rhs: AllocatedUnlimitedCell, + d_leading_u16: AllocatedUnlimitedCell, + degree_helper1: AllocatedUnlimitedCell, + degree_helper2: AllocatedUnlimitedCell, + + memory_table_lookup_stack_read_lhs: AllocatedMemoryTableLookupReadCell, + memory_table_lookup_stack_read_rhs: AllocatedMemoryTableLookupReadCell, + memory_table_lookup_stack_write: AllocatedMemoryTableLookupWriteCell, +} *) + +Module BinConfig. + Record t {F : Set} {H : deps.FieldExt.Trait F} : Set := { + lhs : AllocatedU64CellWithFlagBitDyn.t F; + rhs : AllocatedU64CellWithFlagBitDyn.t F; + + is_i32 : AllocatedBitCell.t F; + + d : AllocatedU64Cell.t F; + d_flag_helper_diff : AllocatedCommonRangeCell.t F; + + aux1 : AllocatedU64Cell.t F; + aux2 : AllocatedU64Cell.t F; + + overflow : AllocatedBitCell.t F; + is_add : AllocatedBitCell.t F; + is_sub : AllocatedBitCell.t F; + is_mul : AllocatedBitCell.t F; + is_div_u : AllocatedBitCell.t F; + is_rem_u : AllocatedBitCell.t F; + is_div_s : AllocatedBitCell.t F; + is_rem_s : AllocatedBitCell.t F; + is_div_s_or_rem_s : AllocatedBitCell.t F; + + res_flag : AllocatedUnlimitedCell.t F; + size_modulus : AllocatedUnlimitedCell.t F; + normalized_lhs : AllocatedUnlimitedCell.t F; + normalized_rhs : AllocatedUnlimitedCell.t F; + d_leading_u16 : AllocatedUnlimitedCell.t F; + degree_helper1 : AllocatedUnlimitedCell.t F; + degree_helper2 : AllocatedUnlimitedCell.t F; + + memory_table_lookup_stack_read_lhs : AllocatedMemoryTableLookupReadCell.t F; + memory_table_lookup_stack_read_rhs : AllocatedMemoryTableLookupReadCell.t F; + memory_table_lookup_stack_write : AllocatedMemoryTableLookupWriteCell.t F; + }. + Arguments t : clear implicits. +End BinConfig. + +(* pub struct BinConfigBuilder {} *) + +Module BinConfigBuilder. + Inductive t : Set := + | Make. +End BinConfigBuilder. + +Module Impl_EventTableOpcodeConfigBuilder_for_BinConfigBuilder. + (* fn configure( + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + ) -> Box> *) + Definition configure {F : Set} {_ : deps.FieldExt.Trait F} + (common_config : EventTableCommonConfig.t F) : + MS? (State.t F) Empty_set unit. + (* + let is_i32 = allocator.alloc_bit_cell(); + *) + refine (letS? is_i32 := Impl_EventTableCellAllocator.alloc_bit_cell in _). + (* + let lhs = allocator + .alloc_u64_with_flag_bit_cell_dyn(constraint_builder, move |meta| is_i32.expr(meta)); + *) + (* refine (letS? lhs := + (Impl_EventTableCellAllocator.alloc_u64_with_flag_bit_cell_dyn + constraint_builder + (fun meta => _) + ) in _). *) + refine (returnS? tt). + Defined. +End Impl_EventTableOpcodeConfigBuilder_for_BinConfigBuilder. diff --git a/CoqOfRust/zkWasm/circuits/etable/simulations/allocator.v b/CoqOfRust/zkWasm/circuits/etable/simulations/allocator.v new file mode 100644 index 000000000..b747c84c7 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/simulations/allocator.v @@ -0,0 +1,31 @@ +Require Import CoqOfRust.CoqOfRust. +Require Import simulations.M. + +Require Import zkWasm.circuits.etable.simulations.allocator_type. +Require Import zkWasm.circuits.simulations.cell. +Require Import zkWasm.simulations.deps. +Require Import zkWasm.simulations.state. + +Import simulations.M.Notations. + +(* impl EventTableCellAllocator { *) +Module Impl_EventTableCellAllocator. + (* pub(crate) fn alloc_bit_cell(&mut self) -> AllocatedBitCell { + AllocatedBitCell { + cell: self.alloc(&EventTableCellType::Bit), + } + } *) + Definition alloc_bit_cell {F : Set} {_ : deps.FieldExt.Trait F} : + MS? (State.t F) Empty_set (cell.AllocatedBitCell.t F). + Admitted. + + (* pub(crate) fn alloc_u64_with_flag_bit_cell_dyn( + &mut self, + constraint_builder: &mut ConstraintBuilder, + is_i32: impl Fn(&mut VirtualCells<'_, F>) -> Expression + 'static, + ) -> AllocatedU64CellWithFlagBitDyn *) + Definition alloc_u64_with_flag_bit_cell_dyn {F : Set} {_ : deps.FieldExt.Trait F} + (is_i32 : unit) : + MS? (State.t F) Empty_set (cell.AllocatedU64CellWithFlagBitDyn.t F). + Admitted. +End Impl_EventTableCellAllocator. diff --git a/CoqOfRust/zkWasm/circuits/etable/simulations/allocator_type.v b/CoqOfRust/zkWasm/circuits/etable/simulations/allocator_type.v new file mode 100644 index 000000000..843a03de7 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/simulations/allocator_type.v @@ -0,0 +1,28 @@ +Require Import CoqOfRust.CoqOfRust. +Require Import simulations.M. + +Require zkWasm.circuits.simulations.cell. +Require zkWasm.simulations.deps. + +Import simulations.M.Notations. + +Module AllocatedMemoryTableLookupReadCell. + Parameter t : forall (F : Set) {_ : deps.FieldExt.Trait F}, Set. +End AllocatedMemoryTableLookupReadCell. + +Module AllocatedMemoryTableLookupWriteCell. + Parameter t : forall (F : Set) {_ : deps.FieldExt.Trait F}, Set. +End AllocatedMemoryTableLookupWriteCell. + +(* pub(crate) struct EventTableCellAllocator { + k: u32, + pub(crate) free_cells: BTreeMap, + all_cols: BTreeMap>>>, + free_u32_cells: Vec>, + free_u32_permutation_cells: Vec>, + free_u64_cells: Vec>, + _mark: PhantomData, +} *) +Module EventTableCellAllocator. + Parameter t : forall (F : Set) {_ : deps.FieldExt.Trait F}, Set. +End EventTableCellAllocator. diff --git a/CoqOfRust/zkWasm/circuits/etable/simulations/constraint_builder.v b/CoqOfRust/zkWasm/circuits/etable/simulations/constraint_builder.v new file mode 100644 index 000000000..0ccf57c8d --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/simulations/constraint_builder.v @@ -0,0 +1,10 @@ +Require Import CoqOfRust.CoqOfRust. +Require Import simulations.M. + +Require zkWasm.simulations.deps. + +Import simulations.M.Notations. + +Module ConstraintBuilder. + Parameter t : forall (F : Set) {_ : deps.FieldExt.Trait F}, Set. +End ConstraintBuilder. diff --git a/CoqOfRust/zkWasm/circuits/etable/simulations/mod.v b/CoqOfRust/zkWasm/circuits/etable/simulations/mod.v new file mode 100644 index 000000000..1633062a5 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/etable/simulations/mod.v @@ -0,0 +1,10 @@ +Require Import CoqOfRust.CoqOfRust. +Require Import simulations.M. + +Require zkWasm.simulations.deps. + +Import simulations.M.Notations. + +Module EventTableCommonConfig. + Parameter t : forall (F : Set) {_ : deps.FieldExt.Trait F}, Set. +End EventTableCommonConfig. diff --git a/CoqOfRust/zkWasm/circuits/external_host_call_table/assign.v b/CoqOfRust/zkWasm/circuits/external_host_call_table/assign.v new file mode 100644 index 000000000..4ee2b7972 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/external_host_call_table/assign.v @@ -0,0 +1,1493 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module external_host_call_table. + Module assign. + Module Impl_delphinus_zkwasm_circuits_external_host_call_table_ExternalHostCallChip_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallChip") + [ F ]. + + (* + pub(in crate::circuits) fn assign( + self, + layouter: impl Layouter, + table: &ExternalHostCallTable, + ) -> Result<(), Error> { + layouter.assign_region( + || "foreign table", + |region| { + // Assign Fixed Column + { + for offset in 0..self.maximal_available_rows { + region.assign_fixed( + || "external host call idx", + self.config.idx, + offset, + || Ok(F::from(offset as u64)), + )?; + } + } + + // Assign Advice Columns + { + let mut offset = 0; + + { + region.assign_advice( + || "external host call opcode", + self.config.opcode, + offset, + || Ok(F::zero()), + )?; + + region.assign_advice( + || "external host call operand", + self.config.operand, + offset, + || Ok(F::zero()), + )?; + } + + offset += 1; + + for entry in table.entries() { + region.assign_advice( + || "external host call opcode", + self.config.opcode, + offset, + || Ok(F::from(entry.op as u64)), + )?; + + region.assign_advice( + || "external host call operand", + self.config.operand, + offset, + || Ok(F::from(entry.value)), + )?; + + offset += 1; + } + } + + Ok(()) + }, + )?; + + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Layouter_F_ ], [ self; layouter; table ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let layouter := M.alloc (| layouter |) in + let table := M.alloc (| table |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::Layouter", + impl_Layouter_F_, + [ F ], + "assign_region", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::Region") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ]); + Ty.tuple []; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + layouter; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| Value.String "foreign table" |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let region := M.copy (| γ |) in + M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallChip", + "maximal_available_rows" + |) + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let offset := + M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_fixed", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + region + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "external host call idx" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallChip", + "config" + |), + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig", + "idx" + |) + |); + M.read (| + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + offset + |)) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + let offset := M.alloc (| Value.Integer 0 |) in + let _ := + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| region |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "external host call opcode" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallChip", + "config" + |), + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig", + "opcode" + |) + |); + M.read (| offset |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| region |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "external host call operand" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallChip", + "config" + |), + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig", + "operand" + |) + |); + M.read (| offset |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |) in + let _ := + let β := offset in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::external_host_call_table::ExternalHostCallEntry"; + Ty.path + "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::external_host_call_table::ExternalHostCallTable", + "entries", + [] + |), + [ M.read (| table |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "specs::external_host_call_table::ExternalHostCallEntry" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let entry := + M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_advice", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + region + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "external host call opcode" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallChip", + "config" + |), + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig", + "opcode" + |) + |); + M.read (| + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + entry + |), + "specs::external_host_call_table::ExternalHostCallEntry", + "op" + |) + |)) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_advice", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + region + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "external host call operand" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallChip", + "config" + |), + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig", + "operand" + |) + |); + M.read (| + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + entry + |), + "specs::external_host_call_table::ExternalHostCallEntry", + "value" + |) + |) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let _ := + let β := offset in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_circuits_external_host_call_table_ExternalHostCallChip_F. + End assign. + End external_host_call_table. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/external_host_call_table/configure.v b/CoqOfRust/zkWasm/circuits/external_host_call_table/configure.v new file mode 100644 index 000000000..07a0c15ca --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/external_host_call_table/configure.v @@ -0,0 +1,428 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module external_host_call_table. + Module configure. + Module Impl_delphinus_zkwasm_circuits_external_host_call_table_ExternalHostCallTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig") + [ F ]. + + (* + pub(in crate::circuits) fn configure(meta: &mut ConstraintSystem) -> Self { + Self { + idx: meta.fixed_column(), + opcode: meta.named_advice_column("shared_opcodes".to_string()), + operand: meta.named_advice_column("shared_operands".to_string()), + _phantom: PhantomData, + } + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ meta ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + Value.StructRecord + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig" + [ + ("idx", + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "fixed_column", + [] + |), + [ M.read (| meta |) ] + |)); + ("opcode", + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "named_advice_column", + [] + |), + [ + M.read (| meta |); + M.call_closure (| + M.get_trait_method (| + "alloc::string::ToString", + Ty.path "str", + [], + "to_string", + [] + |), + [ M.read (| Value.String "shared_opcodes" |) ] + |) + ] + |)); + ("operand", + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "named_advice_column", + [] + |), + [ + M.read (| meta |); + M.call_closure (| + M.get_trait_method (| + "alloc::string::ToString", + Ty.path "str", + [], + "to_string", + [] + |), + [ M.read (| Value.String "shared_operands" |) ] + |) + ] + |)); + ("_phantom", Value.StructTuple "core::marker::PhantomData" []) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure" (configure F). + End Impl_delphinus_zkwasm_circuits_external_host_call_table_ExternalHostCallTableConfig_F. + + Module Impl_delphinus_zkwasm_circuits_traits_ConfigureLookupTable_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_external_host_call_table_ExternalHostCallTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig") + [ F ]. + + (* + fn configure_in_table( + &self, + meta: &mut ConstraintSystem, + key: &'static str, + expr: impl FnOnce(&mut VirtualCells<'_, F>) -> Vec>, + ) { + meta.lookup_any(key, |meta| { + vec![( + expr(meta).pop().unwrap(), + encode_host_call_entry( + fixed_curr!(meta, self.idx), + curr!(meta, self.opcode), + curr!(meta, self.operand), + ), + )] + }); + } + *) + Definition configure_in_table (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_FnOnce__mut_VirtualCells_'___F___arrow_Vec_Expression_F__ ], + [ self; meta; key; expr ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let key := M.alloc (| key |) in + let expr := M.alloc (| expr |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "lookup_any", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| key |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + "pop", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow_Vec_Expression_F__, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ + M.read (| expr |); + Value.Tuple + [ M.read (| meta |) ] + ] + |) + |) + ] + |) + ] + |); + M.call_closure (| + M.get_function (| + "specs::external_host_call_table::encode::encode_host_call_entry", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig", + "idx" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig", + "opcode" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig", + "operand" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ] + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::traits::ConfigureLookupTable" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure_in_table", InstanceField.Method (configure_in_table F)) ]. + End Impl_delphinus_zkwasm_circuits_traits_ConfigureLookupTable_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_external_host_call_table_ExternalHostCallTableConfig_F. + End configure. + End external_host_call_table. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/external_host_call_table/mod.v b/CoqOfRust/zkWasm/circuits/external_host_call_table/mod.v new file mode 100644 index 000000000..2050a1208 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/external_host_call_table/mod.v @@ -0,0 +1,182 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module external_host_call_table. + (* StructRecord + { + name := "ExternalHostCallTableConfig"; + ty_params := [ "F" ]; + fields := + [ + ("idx", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]); + ("opcode", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + ("operand", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + ("_phantom", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_external_host_call_table_ExternalHostCallTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig") + [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig" + [ + ("idx", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig", + "idx" + |) + ] + |)); + ("opcode", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig", + "opcode" + |) + ] + |)); + ("operand", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig", + "operand" + |) + ] + |)); + ("_phantom", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig", + "_phantom" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_external_host_call_table_ExternalHostCallTableConfig_F. + + (* StructRecord + { + name := "ExternalHostCallChip"; + ty_params := [ "F" ]; + fields := + [ + ("config", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig") + [ F ]); + ("maximal_available_rows", Ty.path "usize") + ]; + } *) + + Module Impl_delphinus_zkwasm_circuits_external_host_call_table_ExternalHostCallChip_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallChip") + [ F ]. + + (* + pub fn new(config: ExternalHostCallTableConfig, maximal_available_rows: usize) -> Self { + Self { + config, + maximal_available_rows, + } + } + *) + Definition new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ config; maximal_available_rows ] => + ltac:(M.monadic + (let config := M.alloc (| config |) in + let maximal_available_rows := M.alloc (| maximal_available_rows |) in + Value.StructRecord + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallChip" + [ + ("config", M.read (| config |)); + ("maximal_available_rows", M.read (| maximal_available_rows |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "new" (new F). + End Impl_delphinus_zkwasm_circuits_external_host_call_table_ExternalHostCallChip_F. + End external_host_call_table. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/image_table/assign.v b/CoqOfRust/zkWasm/circuits/image_table/assign.v new file mode 100644 index 000000000..7a6b0d4b2 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/image_table/assign.v @@ -0,0 +1,5837 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module image_table. + Module assign. + Module Impl_delphinus_zkwasm_circuits_image_table_ImageTableChip_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::image_table::ImageTableChip") [ F ]. + + (* + pub(crate) fn assign( + &self, + layouter: impl Layouter, + image_table_assigner: &ImageTableAssigner, + image_table: ImageTableLayouter, + ) -> Result>, Error> { + layouter.assign_region( + || "pre image table", + |region| { + let ctx = Rc::new(RefCell::new(Context::new(region))); + + let initialization_state_handler = |base_offset| { + ctx.borrow_mut().offset = base_offset; + + let assign_handler = |field: &F| assign!(ctx, self.config.col, *field); + + let initialization_state = image_table + .initialization_state + .map(assign_handler, assign_handler); + + initialization_state.transpose() + }; + + let static_frame_entries_handler = |base_offset| { + ctx.borrow_mut().offset = base_offset; + + let mut cells = vec![]; + + for (enable, entry) in &image_table.static_frame_entries { + let enable = assign!(ctx, self.config.col, *enable)?; + let entry = assign!(ctx, self.config.col, *entry)?; + + cells.push((enable, entry)); + } + + Ok(cells.try_into().expect(&format!( + "The number of static frame entries should be {}", + STATIC_FRAME_ENTRY_NUMBER + ))) + }; + + let instruction_handler = |base_offset| { + ctx.borrow_mut().offset = base_offset; + + image_table + .instructions + .iter() + .map(|entry| assign!(ctx, self.config.col, *entry)) + .collect::, Error>>() + }; + + let br_table_handler = |base_offset| { + ctx.borrow_mut().offset = base_offset; + + image_table + .br_table_entires + .iter() + .map(|entry| assign!(ctx, self.config.col, *entry)) + .collect::, Error>>() + }; + + let padding_handler = |start_offset, end_offset| { + ctx.borrow_mut().offset = start_offset; + + (start_offset..end_offset) + .map(|_| assign!(ctx, self.config.col, F::zero())) + .collect::, Error>>() + }; + + let init_memory_handler = |base_offset| { + // start from 'base_offset" because 'encode_compilation_table_values' have inserted an empty at the beginning. + ctx.borrow_mut().offset = base_offset; + + image_table + .init_memory_entries + .iter() + .map(|entry| assign!(ctx, self.config.col, *entry)) + .collect::, Error>>() + }; + + let result = image_table_assigner.exec( + initialization_state_handler, + static_frame_entries_handler, + instruction_handler, + br_table_handler, + padding_handler, + init_memory_handler, + )?; + + Ok(ImageTableLayouter { + initialization_state: result.initialization_state, + static_frame_entries: result.static_frame_entries, + instructions: result.instructions, + br_table_entires: result.br_table_entires, + padding_entires: result.padding_entires, + init_memory_entries: result.init_memory_entries, + }) + }, + ) + } + " + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Layouter_F_ ], [ self; layouter; image_table_assigner; image_table ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let layouter := M.alloc (| layouter |) in + let image_table_assigner := M.alloc (| image_table_assigner |) in + let image_table := M.alloc (| image_table |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::Layouter", + impl_Layouter_F_, + [ F ], + "assign_region", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ] ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]); + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] ]; + Ty.function [ Ty.tuple [] ] (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + layouter; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic (M.read (| Value.String "pre image table" |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let region := M.copy (| γ |) in + M.read (| + let ctx := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ] + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "new", + [] + |), + [ M.read (| region |) ] + |) + ] + |) + ] + |) + |) in + let initialization_state_handler := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let base_offset := M.copy (| γ |) in + M.read (| + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ ctx ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |), + M.read (| base_offset |) + |) in + let assign_handler := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let field := + M.copy (| γ |) in + M.read (| + let offset := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "core::cell::Ref") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |) in + let cell := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ + F + ], + "assign_fixed", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "pre image table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::image_table::ImageTableChip", + "config" + |), + "delphinus_zkwasm::circuits::image_table::ImageTableConfig", + "col" + |) + |); + M.read (| + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.read (| + M.read (| + field + |) + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "next", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.read (| + cell + |) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let initialization_state := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "specs::state::InitializationState") + [ F; F ], + "map", + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.SubPointer.get_struct_record_field (| + image_table, + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "initialization_state" + |); + M.read (| assign_handler |); + M.read (| assign_handler |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "specs::state::InitializationState") + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]; + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "transpose", + [] + |), + [ M.read (| initialization_state |) ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let static_frame_entries_handler := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let base_offset := M.copy (| γ |) in + M.read (| + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ ctx ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |), + M.read (| base_offset |) + |) in + let cells := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "array") + [ Ty.tuple [ F; F ] ] + ], + [], + "into_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + image_table, + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "static_frame_entries" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ F; F ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ0_0 := + M.read (| + γ0_0 + |) in + let γ2_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ2_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let enable := + M.alloc (| + γ2_0 + |) in + let entry := + M.alloc (| + γ2_1 + |) in + let enable := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.read (| + let + offset := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "core::cell::Ref") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |) in + let + cell := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ + F + ], + "assign_fixed", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "pre image table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::image_table::ImageTableChip", + "config" + |), + "delphinus_zkwasm::circuits::image_table::ImageTableConfig", + "col" + |) + |); + M.read (| + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.read (| + M.read (| + enable + |) + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ], + "next", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.read (| + cell + |) + ] + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) + |) in + let entry := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.read (| + let + offset := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "core::cell::Ref") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |) in + let + cell := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ + F + ], + "assign_fixed", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "pre image table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::image_table::ImageTableChip", + "config" + |), + "delphinus_zkwasm::circuits::image_table::ImageTableConfig", + "col" + |) + |); + M.read (| + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.read (| + M.read (| + entry + |) + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ], + "next", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.read (| + cell + |) + ] + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + cells; + Value.Tuple + [ + M.read (| + enable + |); + M.read (| + entry + |) + ] + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + |))) + ] + |)) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path + "alloc::alloc::Global" + ] + ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::TryInto", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ], + "try_into", + [] + |), + [ M.read (| cells |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "The number of static frame entries should be " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "usize" + ] + |), + [ + M.get_constant (| + "specs::jtable::STATIC_FRAME_ENTRY_NUMBER" + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let instruction_handler := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let base_offset := M.copy (| γ |) in + M.read (| + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ ctx ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |), + M.read (| base_offset |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ], + [], + "map", + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ F ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + image_table, + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "instructions" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let entry := + M.copy (| + γ + |) in + M.read (| + let offset := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "core::cell::Ref") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |) in + let cell := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ + F + ], + "assign_fixed", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "pre image table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::image_table::ImageTableChip", + "config" + |), + "delphinus_zkwasm::circuits::image_table::ImageTableConfig", + "col" + |) + |); + M.read (| + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.read (| + M.read (| + entry + |) + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F + ], + "next", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.read (| + cell + |) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let br_table_handler := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let base_offset := M.copy (| γ |) in + M.read (| + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ ctx ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |), + M.read (| base_offset |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ], + [], + "map", + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ F ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + image_table, + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "br_table_entires" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let entry := + M.copy (| + γ + |) in + M.read (| + let offset := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "core::cell::Ref") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |) in + let cell := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ + F + ], + "assign_fixed", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "pre image table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::image_table::ImageTableChip", + "config" + |), + "delphinus_zkwasm::circuits::image_table::ImageTableConfig", + "col" + |) + |); + M.read (| + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.read (| + M.read (| + entry + |) + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F + ], + "next", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.read (| + cell + |) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let padding_handler := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let start_offset := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let end_offset := M.copy (| γ |) in + M.read (| + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ ctx ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |), + M.read (| start_offset |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ + Ty.tuple + [ Ty.path "usize" + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "map", + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "usize" + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + M.read (| + start_offset + |)); + ("end_", + M.read (| + end_offset + |)) + ]; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let + offset := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "core::cell::Ref") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |) in + let + cell := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ + F + ], + "assign_fixed", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "pre image table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::image_table::ImageTableChip", + "config" + |), + "delphinus_zkwasm::circuits::image_table::ImageTableConfig", + "col" + |) + |); + M.read (| + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) + |) in + let + _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ], + "next", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.read (| + cell + |) + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let init_memory_handler := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let base_offset := M.copy (| γ |) in + M.read (| + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ ctx ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |), + M.read (| base_offset |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ F ], + [], + "map", + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ F ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + image_table, + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "init_memory_entries" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let entry := + M.copy (| + γ + |) in + M.read (| + let offset := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "core::cell::Ref") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |) in + let cell := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ + F + ], + "assign_fixed", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "pre image table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::image_table::ImageTableChip", + "config" + |), + "delphinus_zkwasm::circuits::image_table::ImageTableConfig", + "col" + |) + |); + M.read (| + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.read (| + M.read (| + entry + |) + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F + ], + "next", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ + F + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + ctx + ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.read (| + cell + |) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let result := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner", + "exec", + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error"; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "specs::state::InitializationState") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + Ty.function + [ + Ty.tuple + [ Ty.path "usize"; Ty.path "usize" ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.read (| image_table_assigner |); + M.read (| initialization_state_handler |); + M.read (| static_frame_entries_handler |); + M.read (| instruction_handler |); + M.read (| br_table_handler |); + M.read (| padding_handler |); + M.read (| init_memory_handler |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter" + [ + ("initialization_state", + M.read (| + M.SubPointer.get_struct_record_field (| + result, + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "initialization_state" + |) + |)); + ("static_frame_entries", + M.read (| + M.SubPointer.get_struct_record_field (| + result, + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "static_frame_entries" + |) + |)); + ("instructions", + M.read (| + M.SubPointer.get_struct_record_field (| + result, + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "instructions" + |) + |)); + ("br_table_entires", + M.read (| + M.SubPointer.get_struct_record_field (| + result, + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "br_table_entires" + |) + |)); + ("padding_entires", + M.read (| + M.SubPointer.get_struct_record_field (| + result, + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "padding_entires" + |) + |)); + ("init_memory_entries", + M.read (| + M.SubPointer.get_struct_record_field (| + result, + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "init_memory_entries" + |) + |)) + ] + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_circuits_image_table_ImageTableChip_F. + End assign. + End image_table. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/image_table/configure.v b/CoqOfRust/zkWasm/circuits/image_table/configure.v new file mode 100644 index 000000000..2a55b2cef --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/image_table/configure.v @@ -0,0 +1,734 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module image_table. + Module configure. + Module Impl_delphinus_zkwasm_circuits_image_table_ImageTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::image_table::ImageTableConfig") [ F ]. + + (* + pub(in crate::circuits) fn configure( + meta: &mut ConstraintSystem, + memory_addr_sel: Option>, + ) -> Self { + cfg_if::cfg_if! { + if #[cfg(feature="uniform-circuit")] { + let col = meta.named_advice_column(super::IMAGE_COL_NAME.to_owned()); + + if cfg!(feature="continuation") { + } + } else { + let col = meta.fixed_column(); + } + } + + meta.enable_equality(col); + + Self { + memory_addr_sel, + col, + _mark: PhantomData, + } + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ meta; memory_addr_sel ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + let memory_addr_sel := M.alloc (| memory_addr_sel |) in + M.read (| + let col := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "fixed_column", + [] + |), + [ M.read (| meta |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "enable_equality", + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ] + |), + [ M.read (| meta |); M.read (| col |) ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::image_table::ImageTableConfig" + [ + ("memory_addr_sel", M.read (| memory_addr_sel |)); + ("col", M.read (| col |)); + ("_mark", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure" (configure F). + + (* + pub fn instruction_lookup( + &self, + meta: &mut ConstraintSystem, + key: &'static str, + expr: impl FnOnce(&mut VirtualCells<'_, F>) -> Expression, + ) { + meta.lookup_any(key, |meta| { + vec![( + ImageTableEncoder::Instruction.encode(expr(meta)), + self.expr(meta), + )] + }); + } + *) + Definition instruction_lookup (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_ ], + [ self; meta; key; expr ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let key := M.alloc (| key |) in + let expr := M.alloc (| expr |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "lookup_any", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| key |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::encode::image_table::ImageTableEncoder", + "encode", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + |), + [ + M.alloc (| + Value.StructTuple + "specs::encode::image_table::ImageTableEncoder::Instruction" + [] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ + M.read (| expr |); + Value.Tuple + [ M.read (| meta |) ] + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::image_table::ImageTableConfig") + [ F ], + "expr", + [] + |), + [ + M.read (| self |); + M.read (| meta |) + ] + |) + ] + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_instruction_lookup : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "instruction_lookup" (instruction_lookup F). + + (* + pub fn init_memory_lookup( + &self, + meta: &mut ConstraintSystem, + key: &'static str, + expr: impl FnOnce(&mut VirtualCells<'_, F>) -> Expression, + ) { + meta.lookup_any(key, |meta| { + vec![( + ImageTableEncoder::InitMemory.encode(expr(meta)), + self.expr(meta), + )] + }); + } + *) + Definition init_memory_lookup (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_ ], + [ self; meta; key; expr ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let key := M.alloc (| key |) in + let expr := M.alloc (| expr |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "lookup_any", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| key |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::encode::image_table::ImageTableEncoder", + "encode", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + |), + [ + M.alloc (| + Value.StructTuple + "specs::encode::image_table::ImageTableEncoder::InitMemory" + [] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ + M.read (| expr |); + Value.Tuple + [ M.read (| meta |) ] + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::image_table::ImageTableConfig") + [ F ], + "expr", + [] + |), + [ + M.read (| self |); + M.read (| meta |) + ] + |) + ] + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_init_memory_lookup : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "init_memory_lookup" (init_memory_lookup F). + + (* + pub fn br_table_lookup( + &self, + meta: &mut ConstraintSystem, + key: &'static str, + expr: impl FnOnce(&mut VirtualCells<'_, F>) -> Expression, + ) { + meta.lookup_any(key, |meta| { + vec![( + ImageTableEncoder::BrTable.encode(expr(meta)), + self.expr(meta), + )] + }); + } + *) + Definition br_table_lookup (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_ ], + [ self; meta; key; expr ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let key := M.alloc (| key |) in + let expr := M.alloc (| expr |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "lookup_any", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| key |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::encode::image_table::ImageTableEncoder", + "encode", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + |), + [ + M.alloc (| + Value.StructTuple + "specs::encode::image_table::ImageTableEncoder::BrTable" + [] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ + M.read (| expr |); + Value.Tuple + [ M.read (| meta |) ] + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::image_table::ImageTableConfig") + [ F ], + "expr", + [] + |), + [ + M.read (| self |); + M.read (| meta |) + ] + |) + ] + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_br_table_lookup : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "br_table_lookup" (br_table_lookup F). + End Impl_delphinus_zkwasm_circuits_image_table_ImageTableConfig_F. + End configure. + End image_table. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/image_table/mod.v b/CoqOfRust/zkWasm/circuits/image_table/mod.v new file mode 100644 index 000000000..833b7c4d5 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/image_table/mod.v @@ -0,0 +1,363 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module image_table. + Definition value_IMAGE_COL_NAME : Value.t := M.run ltac:(M.monadic (Value.String "img_col")). + + Definition value_PAGE_SIZE : Value.t := + M.run + ltac:(M.monadic + (M.alloc (| BinOp.Panic.mul (| Integer.U32, Value.Integer 64, Value.Integer 1024 |) |))). + + Definition value_PAGE_ENTRIES : Value.t := + M.run + ltac:(M.monadic + (M.alloc (| + BinOp.Panic.div (| + Integer.U32, + M.read (| + M.get_constant (| "delphinus_zkwasm::circuits::image_table::PAGE_SIZE" |) + |), + Value.Integer 8 + |) + |))). + + (* + pub fn compute_maximal_pages(k: u32) -> u32 { + let rows: u32 = ((1usize << k) + - RESERVE_ROWS + - INIT_MEMORY_ENTRIES_OFFSET + - STACK_CAPABILITY + - GLOBAL_CAPABILITY) + .try_into() + .unwrap(); + + // A block is 8 bytes. + let bytes = rows * 8; + + bytes / PAGE_SIZE + } + *) + Definition compute_maximal_pages (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ k ] => + ltac:(M.monadic + (let k := M.alloc (| k |) in + M.read (| + let rows := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "core::num::error::TryFromIntError" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::TryInto", + Ty.path "usize", + [ Ty.path "u32" ], + "try_into", + [] + |), + [ + BinOp.Panic.sub (| + Integer.Usize, + BinOp.Panic.sub (| + Integer.Usize, + BinOp.Panic.sub (| + Integer.Usize, + BinOp.Panic.sub (| + Integer.Usize, + BinOp.Panic.shl (| Value.Integer 1, M.read (| k |) |), + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::zkwasm_circuit::RESERVE_ROWS" + |) + |) + |), + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::utils::image_table::INIT_MEMORY_ENTRIES_OFFSET" + |) + |) + |), + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::utils::image_table::STACK_CAPABILITY" + |) + |) + |), + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::utils::image_table::GLOBAL_CAPABILITY" + |) + |) + |) + ] + |) + ] + |) + |) in + let bytes := + M.alloc (| BinOp.Panic.mul (| Integer.U32, M.read (| rows |), Value.Integer 8 |) |) in + M.alloc (| + BinOp.Panic.div (| + Integer.U32, + M.read (| bytes |), + M.read (| + M.get_constant (| "delphinus_zkwasm::circuits::image_table::PAGE_SIZE" |) + |) + |) + |) + |))) + | _, _ => M.impossible + end. + + (* StructRecord + { + name := "ImageTableConfig"; + ty_params := [ "F" ]; + fields := + [ + ("memory_addr_sel", + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ]); + ("col", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]); + ("_mark", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_image_table_ImageTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::image_table::ImageTableConfig") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::image_table::ImageTableConfig" + [ + ("memory_addr_sel", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::image_table::ImageTableConfig", + "memory_addr_sel" + |) + ] + |)); + ("col", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::image_table::ImageTableConfig", + "col" + |) + ] + |)); + ("_mark", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::image_table::ImageTableConfig", + "_mark" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_image_table_ImageTableConfig_F. + + Module Impl_delphinus_zkwasm_circuits_image_table_ImageTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::image_table::ImageTableConfig") [ F ]. + + (* + pub(crate) fn expr(&self, meta: &mut VirtualCells) -> Expression { + cfg_if::cfg_if! { + if #[cfg(feature="uniform-circuit")] { + crate::curr!(meta, self.col) + } else { + crate::fixed_curr!(meta, self.col) + } + } + } + *) + Definition expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::image_table::ImageTableConfig", + "col" + |) + |); + M.call_closure (| + M.get_associated_function (| Ty.path "halo2_proofs::poly::Rotation", "cur", [] |), + [] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_expr : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "expr" (expr F). + End Impl_delphinus_zkwasm_circuits_image_table_ImageTableConfig_F. + + (* StructRecord + { + name := "ImageTableChip"; + ty_params := [ "F" ]; + fields := + [ + ("config", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::image_table::ImageTableConfig") [ F ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_image_table_ImageTableChip_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::image_table::ImageTableChip") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::image_table::ImageTableChip" + [ + ("config", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::image_table::ImageTableConfig") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::image_table::ImageTableChip", + "config" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_image_table_ImageTableChip_F. + + Module Impl_delphinus_zkwasm_circuits_image_table_ImageTableChip_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::image_table::ImageTableChip") [ F ]. + + (* + pub fn new(config: ImageTableConfig) -> Self { + ImageTableChip { config } + } + *) + Definition new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ config ] => + ltac:(M.monadic + (let config := M.alloc (| config |) in + Value.StructRecord + "delphinus_zkwasm::circuits::image_table::ImageTableChip" + [ ("config", M.read (| config |)) ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "new" (new F). + End Impl_delphinus_zkwasm_circuits_image_table_ImageTableChip_F. + End image_table. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/jtable/assign.v b/CoqOfRust/zkWasm/circuits/jtable/assign.v new file mode 100644 index 000000000..3ae327c6d --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/jtable/assign.v @@ -0,0 +1,4160 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module jtable. + Module assign. + Module Impl_delphinus_zkwasm_circuits_jtable_JumpTableChip_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::jtable::JumpTableChip") [ F ]. + + (* + fn assign_first_rest_jops( + &self, + ctx: &mut Context<'_, F>, + rest_jops: BigUint, + ) -> Result, Error> { + let cell = ctx.region.assign_advice( + || "jtable rest", + self.config.data, + JtableOffset::JtableOffsetRest as usize, + || Ok(bn_to_field(&rest_jops)), + )?; + + Ok(cell) + } + *) + Definition assign_first_rest_jops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; rest_jops ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let rest_jops := M.alloc (| rest_jops |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let cell := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "halo2_proofs::plonk::error::Error" ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| Value.String "jtable rest" |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableChip", + "config" + |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "data" + |) + |); + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::circuits::jtable::JtableOffset::JtableOffsetRest_discriminant" + |), + Value.Integer 0 + |)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ rest_jops ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| cell |) ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_first_rest_jops : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign_first_rest_jops" (assign_first_rest_jops F). + + (* + fn init(&self, ctx: &mut Context<'_, F>) -> Result<(), Error> { + let capability = self.max_available_rows / JtableOffset::JtableOffsetMax as usize; + + for i in 0..capability { + ctx.region.assign_fixed( + || "jtable sel", + self.config.sel, + ctx.offset, + || Ok(F::one()), + )?; + + if i == capability - 1 { + ctx.region.assign_advice_from_constant( + || "jtable entry terminate", + self.config.data, + ctx.offset + JtableOffset::JtableOffsetRest as usize, + F::zero(), + )?; + } + + ctx.step(JtableOffset::JtableOffsetMax as usize); + } + + Ok(()) + } + *) + Definition init (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let capability := + M.alloc (| + BinOp.Panic.div (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableChip", + "max_available_rows" + |) + |), + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::circuits::jtable::JtableOffset::JtableOffsetMax_discriminant" + |), + Value.Integer 0 + |)) + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| capability |)) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_fixed", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "jtable sel" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableChip", + "config" + |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "sel" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| i |)) + (BinOp.Panic.sub (| + Integer.Usize, + M.read (| capability |), + Value.Integer 1 + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_advice_from_constant", + [ + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "jtable entry terminate" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableChip", + "config" + |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "data" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |), + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::circuits::jtable::JtableOffset::JtableOffsetRest_discriminant" + |), + Value.Integer 0 + |)) + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "step", + [] + |), + [ + M.read (| ctx |); + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::circuits::jtable::JtableOffset::JtableOffsetMax_discriminant" + |), + Value.Integer 0 + |)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_init : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "init" (init F). + + (* + fn assign_static_entries_and_first_rest_jops( + &self, + ctx: &mut Context<'_, F>, + rest_jops: &mut BigUint, + static_entries: &[StaticFrameEntry; STATIC_FRAME_ENTRY_NUMBER], + ) -> Result<[(AssignedCell, AssignedCell); STATIC_FRAME_ENTRY_NUMBER], Error> { + let mut cells = vec![]; + + for entry in static_entries { + ctx.region.assign_fixed( + || "jtable start entries", + self.config.static_bit, + ctx.offset, + || Ok(F::one()), + )?; + + let enable_cell = ctx.region.assign_advice( + || "jtable enable", + self.config.data, + ctx.offset, + || Ok(F::from(entry.enable as u64)), + )?; + ctx.next(); + + ctx.region.assign_advice( + || "jtable rest", + self.config.data, + ctx.offset, + || Ok(bn_to_field(rest_jops)), + )?; + ctx.next(); + + let entry_cell = ctx.region.assign_advice( + || "jtable entry", + self.config.data, + ctx.offset, + || Ok(bn_to_field(&entry.encode())), + )?; + ctx.next(); + + cells.push((enable_cell, entry_cell)); + + if entry.enable { + *rest_jops -= encode_jops(1, 0); + } + } + + Ok(cells.try_into().expect(&format!( + "The number of static frame entries should be {}", + STATIC_FRAME_ENTRY_NUMBER + ))) + } + *) + Definition assign_static_entries_and_first_rest_jops + (F : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; rest_jops; static_entries ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let rest_jops := M.alloc (| rest_jops |) in + let static_entries := M.alloc (| static_entries |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let cells := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::jtable::StaticFrameEntry" ] + ], + [], + "into_iter", + [] + |), + [ M.read (| static_entries |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "specs::jtable::StaticFrameEntry" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let entry := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_fixed", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "jtable start entries" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableChip", + "config" + |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "static_bit" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let enable_cell := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "jtable enable" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableChip", + "config" + |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "data" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + entry + |), + "specs::jtable::StaticFrameEntry", + "enable" + |) + |)) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "next", + [] + |), + [ M.read (| ctx |) ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "jtable rest" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableChip", + "config" + |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "data" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.read (| + rest_jops + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "next", + [] + |), + [ M.read (| ctx |) ] + |) + |) in + let entry_cell := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "jtable entry" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableChip", + "config" + |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "data" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::jtable::StaticFrameEntry", + "encode", + [] + |), + [ + M.read (| + entry + |) + ] + |) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "next", + [] + |), + [ M.read (| ctx |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + cells; + Value.Tuple + [ + M.read (| enable_cell |); + M.read (| entry_cell |) + ] + ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "specs::jtable::StaticFrameEntry", + "enable" + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::SubAssign", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "sub_assign", + [] + |), + [ + M.read (| rest_jops |); + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::jtable::encode_jops", + [] + |), + [ Value.Integer 1; Value.Integer 0 ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::TryInto", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ], + "try_into", + [] + |), + [ M.read (| cells |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "alloc::string::String", + [], + "deref", + [] + |), + [ + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "The number of static frame entries should be " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ + M.get_constant (| + "specs::jtable::STATIC_FRAME_ENTRY_NUMBER" + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_static_entries_and_first_rest_jops : + forall (F : Ty.t), + M.IsAssociatedFunction + (Self F) + "assign_static_entries_and_first_rest_jops" + (assign_static_entries_and_first_rest_jops F). + + (* + fn assign_jtable_entries( + &self, + ctx: &mut Context<'_, F>, + rest_jops: &mut BigUint, + jtable: &JumpTable, + ) -> Result<(), Error> { + for entry in jtable.entries().iter() { + let rest_f = bn_to_field(rest_jops); + let entry_f = bn_to_field(&entry.encode()); + + ctx.region.assign_advice( + || "jtable enable", + self.config.data, + ctx.offset, + || Ok(F::one()), + )?; + ctx.next(); + + ctx.region.assign_advice( + || "jtable rest", + self.config.data, + ctx.offset, + || Ok(rest_f), + )?; + ctx.next(); + + ctx.region.assign_advice( + || "jtable entry", + self.config.data, + ctx.offset, + || Ok(entry_f), + )?; + ctx.next(); + + *rest_jops -= encode_jops(1, 1); + } + + { + ctx.region.assign_advice( + || "jtable enable", + self.config.data, + ctx.offset, + || Ok(F::zero()), + )?; + ctx.next(); + + ctx.region.assign_advice( + || "jtable rest", + self.config.data, + ctx.offset, + || Ok(F::zero()), + )?; + ctx.next(); + + ctx.region.assign_advice( + || "jtable entry", + self.config.data, + ctx.offset, + || Ok(F::zero()), + )?; + ctx.next(); + } + + Ok(()) + } + *) + Definition assign_jtable_entries (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; rest_jops; jtable ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let rest_jops := M.alloc (| rest_jops |) in + let jtable := M.alloc (| jtable |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "specs::jtable::JumpTableEntry" ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::jtable::JumpTableEntry" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::jtable::JumpTableEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::jtable::JumpTable", + "entries", + [] + |), + [ M.read (| jtable |) ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "specs::jtable::JumpTableEntry" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let entry := M.copy (| γ0_0 |) in + let rest_f := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ M.read (| rest_jops |) ] + |) + |) in + let entry_f := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::jtable::JumpTableEntry", + "encode", + [] + |), + [ M.read (| entry |) ] + |) + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "jtable enable" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableChip", + "config" + |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "data" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "next", + [] + |), + [ M.read (| ctx |) ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "jtable rest" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableChip", + "config" + |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "data" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ M.read (| rest_f |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "next", + [] + |), + [ M.read (| ctx |) ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "jtable entry" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableChip", + "config" + |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "data" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ M.read (| entry_f |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "next", + [] + |), + [ M.read (| ctx |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::SubAssign", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "num_bigint::biguint::BigUint" ], + "sub_assign", + [] + |), + [ + M.read (| rest_jops |); + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::jtable::encode_jops", + [] + |), + [ Value.Integer 1; Value.Integer 1 ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "halo2_proofs::plonk::error::Error" ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| Value.String "jtable enable" |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableChip", + "config" + |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "data" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "delphinus_zkwasm::circuits::utils::Context") [ F ], + "next", + [] + |), + [ M.read (| ctx |) ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "halo2_proofs::plonk::error::Error" ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| Value.String "jtable rest" |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableChip", + "config" + |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "data" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "delphinus_zkwasm::circuits::utils::Context") [ F ], + "next", + [] + |), + [ M.read (| ctx |) ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "halo2_proofs::plonk::error::Error" ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| Value.String "jtable entry" |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableChip", + "config" + |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "data" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "delphinus_zkwasm::circuits::utils::Context") [ F ], + "next", + [] + |), + [ M.read (| ctx |) ] + |) + |) in + M.alloc (| Value.Tuple [] |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_jtable_entries : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign_jtable_entries" (assign_jtable_entries F). + + (* + pub fn assign( + &self, + layouter: impl Layouter, + static_entries: &[StaticFrameEntry; STATIC_FRAME_ENTRY_NUMBER], + jtable: &JumpTable, + ) -> Result< + ( + AssignedCell, + [(AssignedCell, AssignedCell); STATIC_FRAME_ENTRY_NUMBER], + ), + Error, + > { + layouter.assign_region( + || "frame table", + |region| { + let mut ctx = Context::new(region); + + self.init(&mut ctx)?; + ctx.reset(); + + // non-static entry includes `call`` and `return`` op, static entry only includes `return` op + let mut rest_jops = encode_jops( + jtable.entries().len() as u32 + + static_entries.iter().filter(|entry| entry.enable).count() as u32, + jtable.entries().len() as u32, + ); + + let rest_jopss = self.assign_first_rest_jops(&mut ctx, rest_jops.clone())?; + let cells_to_permutation = self.assign_static_entries_and_first_rest_jops( + &mut ctx, + &mut rest_jops, + static_entries, + )?; + self.assign_jtable_entries(&mut ctx, &mut rest_jops, jtable)?; + + Ok((rest_jopss, cells_to_permutation)) + }, + ) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Layouter_F_ ], [ self; layouter; static_entries; jtable ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let layouter := M.alloc (| layouter |) in + let static_entries := M.alloc (| static_entries |) in + let jtable := M.alloc (| jtable |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::Layouter", + impl_Layouter_F_, + [ F ], + "assign_region", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ] ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]); + Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] + ] + ] + ]; + Ty.function [ Ty.tuple [] ] (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + layouter; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ fun γ => ltac:(M.monadic (M.read (| Value.String "frame table" |))) ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let region := M.copy (| γ |) in + M.read (| + let ctx := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "new", + [] + |), + [ M.read (| region |) ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableChip") + [ F ], + "init", + [] + |), + [ M.read (| self |); ctx ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "reset", + [] + |), + [ ctx ] + |) + |) in + let rest_jops := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::jtable::encode_jops", + [] + |), + [ + BinOp.Panic.add (| + Integer.U32, + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::jtable::JumpTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::jtable::JumpTable", + "entries", + [] + |), + [ M.read (| jtable |) ] + |) + ] + |)), + M.rust_cast + (M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "specs::jtable::StaticFrameEntry" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "specs::jtable::StaticFrameEntry" + ] + ] + ] + ] + (Ty.path "bool") + ], + [], + "count", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "specs::jtable::StaticFrameEntry" + ], + [], + "filter", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "specs::jtable::StaticFrameEntry" + ] + ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "specs::jtable::StaticFrameEntry" + ], + "iter", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| static_entries |)) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let entry := + M.copy (| γ |) in + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.read (| entry |) + |), + "specs::jtable::StaticFrameEntry", + "enable" + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |)) + |); + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::jtable::JumpTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::jtable::JumpTable", + "entries", + [] + |), + [ M.read (| jtable |) ] + |) + ] + |)) + ] + |) + |) in + let rest_jopss := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableChip") + [ F ], + "assign_first_rest_jops", + [] + |), + [ + M.read (| self |); + ctx; + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "num_bigint::biguint::BigUint", + [], + "clone", + [] + |), + [ rest_jops ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let cells_to_permutation := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableChip") + [ F ], + "assign_static_entries_and_first_rest_jops", + [] + |), + [ + M.read (| self |); + ctx; + rest_jops; + M.read (| static_entries |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableChip") + [ F ], + "assign_jtable_entries", + [] + |), + [ + M.read (| self |); + ctx; + rest_jops; + M.read (| jtable |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.Tuple + [ + M.read (| rest_jopss |); + M.read (| cells_to_permutation |) + ] + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_circuits_jtable_JumpTableChip_F. + End assign. + End jtable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/jtable/configure.v b/CoqOfRust/zkWasm/circuits/jtable/configure.v new file mode 100644 index 000000000..1e279f806 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/jtable/configure.v @@ -0,0 +1,1885 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module jtable. + Module configure. + (* Trait *) + Module JTableConstraint. + Definition configure (F Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::jtable::configure::JTableConstraint", + Self, + [ F ], + "enable_is_bit", + [] + |), + [ M.read (| self |); M.read (| meta |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::jtable::configure::JTableConstraint", + Self, + [ F ], + "enable_rest_jops_permutation", + [] + |), + [ M.read (| self |); M.read (| meta |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::jtable::configure::JTableConstraint", + Self, + [ F ], + "configure_rest_jops_decrease", + [] + |), + [ M.read (| self |); M.read (| meta |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::jtable::configure::JTableConstraint", + Self, + [ F ], + "disabled_block_should_be_end", + [] + |), + [ M.read (| self |); M.read (| meta |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::jtable::configure::JTableConstraint", + Self, + [ F ], + "disabled_block_has_no_entry_value", + [] + |), + [ M.read (| self |); M.read (| meta |) ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_configure : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::jtable::configure::JTableConstraint" + "configure" + (configure F). + End JTableConstraint. + + Module Impl_delphinus_zkwasm_circuits_jtable_configure_JTableConstraint_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_jtable_JumpTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::jtable::JumpTableConfig") [ F ]. + + (* + fn enable_rest_jops_permutation(&self, meta: &mut ConstraintSystem) { + meta.enable_equality(self.data); + } + *) + Definition enable_rest_jops_permutation (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "enable_equality", + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "data" + |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + (* + fn enable_is_bit(&self, meta: &mut ConstraintSystem) { + meta.create_gate("enable is bit", |meta| { + vec![ + self.enable(meta) + * (self.enable(meta) - constant_from!(1)) + * fixed_curr!(meta, self.sel), + ] + }); + } + *) + Definition enable_is_bit (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "enable is bit" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + "enable", + [] + |), + [ + M.read (| self |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + "enable", + [] + |), + [ + M.read (| self |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "sel" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + (* + fn configure_rest_jops_decrease(&self, meta: &mut ConstraintSystem) { + meta.create_gate("c3. jtable rest decrease", |meta| { + vec![ + (self.rest(meta) - self.next_rest(meta) - constant_from_bn!(&encode_jops(1, 1)) + + self.static_bit(meta)) + * self.enable(meta) + * fixed_curr!(meta, self.sel), + (self.rest(meta) - self.next_rest(meta)) + * (self.enable(meta) - constant_from!(1)) + * fixed_curr!(meta, self.sel), + ] + }); + } + *) + Definition configure_rest_jops_decrease (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c3. jtable rest decrease" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + "rest", + [] + |), + [ + M.read (| self |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + "next_rest", + [] + |), + [ + M.read (| self |); + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::jtable::encode_jops", + [] + |), + [ + Value.Integer + 1; + Value.Integer + 1 + ] + |) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + "static_bit", + [] + |), + [ + M.read (| self |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + "enable", + [] + |), + [ + M.read (| self |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "sel" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + "rest", + [] + |), + [ + M.read (| self |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + "next_rest", + [] + |), + [ + M.read (| self |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + "enable", + [] + |), + [ + M.read (| self |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "sel" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + (* + fn disabled_block_should_be_end(&self, meta: &mut ConstraintSystem) { + meta.create_gate("c5. jtable ends up", |meta| { + vec![ + (constant_from!(1) - self.enable(meta)) + * (constant_from!(1) - self.static_bit(meta)) + * self.rest(meta) + * fixed_curr!(meta, self.sel), + ] + }); + } + *) + Definition disabled_block_should_be_end (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c5. jtable ends up" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + "enable", + [] + |), + [ + M.read (| self |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + "static_bit", + [] + |), + [ + M.read (| self |); + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + "rest", + [] + |), + [ + M.read (| self |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "sel" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + (* + fn disabled_block_has_no_entry_value(&self, meta: &mut ConstraintSystem) { + meta.create_gate("c6. jtable entry is zero on disabled", |meta| { + vec![ + (constant_from!(1) - self.enable(meta)) + * self.entry(meta) + * fixed_curr!(meta, self.sel), + ] + }); + } + *) + Definition disabled_block_has_no_entry_value + (F : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "c6. jtable entry is zero on disabled" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer 1 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + "enable", + [] + |), + [ + M.read (| self |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + "entry", + [] + |), + [ + M.read (| self |); + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "sel" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::jtable::configure::JTableConstraint" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("enable_rest_jops_permutation", + InstanceField.Method (enable_rest_jops_permutation F)); + ("enable_is_bit", InstanceField.Method (enable_is_bit F)); + ("configure_rest_jops_decrease", + InstanceField.Method (configure_rest_jops_decrease F)); + ("disabled_block_should_be_end", + InstanceField.Method (disabled_block_should_be_end F)); + ("disabled_block_has_no_entry_value", + InstanceField.Method (disabled_block_has_no_entry_value F)) + ]. + End Impl_delphinus_zkwasm_circuits_jtable_configure_JTableConstraint_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_jtable_JumpTableConfig_F. + + Module Impl_delphinus_zkwasm_circuits_Lookup_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_jtable_JumpTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::jtable::JumpTableConfig") [ F ]. + + (* + fn configure_in_table( + &self, + meta: &mut ConstraintSystem, + key: &'static str, + expr: impl FnOnce(&mut VirtualCells<'_, F>) -> Expression, + ) { + meta.lookup_any(key, |meta| { + vec![(expr(meta), self.entry(meta) * fixed_curr!(meta, self.sel))] + }); + } + *) + Definition configure_in_table (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_ ], + [ self; meta; key; expr ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let key := M.alloc (| key |) in + let expr := M.alloc (| expr |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "lookup_any", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| key |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ + M.read (| expr |); + Value.Tuple [ M.read (| meta |) ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + "entry", + [] + |), + [ + M.read (| self |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "sel" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ] + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + (* + fn encode(&self, _meta: &mut VirtualCells<'_, F>) -> Expression { + unimplemented!() + } + *) + Parameter encode : forall (F : Ty.t), (list Ty.t) -> (list Value.t) -> M. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::Lookup" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("configure_in_table", InstanceField.Method (configure_in_table F)); + ("encode", InstanceField.Method (encode F)) + ]. + End Impl_delphinus_zkwasm_circuits_Lookup_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_jtable_JumpTableConfig_F. + + Module Impl_delphinus_zkwasm_circuits_jtable_JumpTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::jtable::JumpTableConfig") [ F ]. + + (* + pub(super) fn new( + meta: &mut ConstraintSystem, + cols: &mut impl Iterator>, + ) -> Self { + let sel = meta.fixed_column(); + let static_bit = meta.fixed_column(); + let data = cols.next().unwrap(); + + JumpTableConfig { + sel, + static_bit, + data, + _m: std::marker::PhantomData, + } + } + *) + Definition new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Iterator_Item___Column_Advice__ ], [ meta; cols ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + let cols := M.alloc (| cols |) in + M.read (| + let sel := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "fixed_column", + [] + |), + [ M.read (| meta |) ] + |) + |) in + let static_bit := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "fixed_column", + [] + |), + [ M.read (| meta |) ] + |) + |) in + let data := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___Column_Advice__, + [], + "next", + [] + |), + [ M.read (| cols |) ] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::jtable::JumpTableConfig" + [ + ("sel", M.read (| sel |)); + ("static_bit", M.read (| static_bit |)); + ("data", M.read (| data |)); + ("_m", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "new" (new F). + End Impl_delphinus_zkwasm_circuits_jtable_JumpTableConfig_F. + End configure. + End jtable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/jtable/expression.v b/CoqOfRust/zkWasm/circuits/jtable/expression.v new file mode 100644 index 000000000..3be8e47b5 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/jtable/expression.v @@ -0,0 +1,323 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module jtable. + Module expression. + Module Impl_delphinus_zkwasm_circuits_jtable_JumpTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::jtable::JumpTableConfig") [ F ]. + + (* + pub(super) fn enable(&self, meta: &mut VirtualCells) -> Expression { + nextn!(meta, self.data, JtableOffset::JtableOffsetEnable as i32) + } + *) + Definition enable (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "data" + |) + |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::circuits::jtable::JtableOffset::JtableOffsetEnable_discriminant" + |), + Value.Integer 0 + |)) + ] + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_enable : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "enable" (enable F). + + (* + pub(super) fn rest(&self, meta: &mut VirtualCells) -> Expression { + nextn!(meta, self.data, JtableOffset::JtableOffsetRest as i32) + } + *) + Definition rest (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "data" + |) + |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::circuits::jtable::JtableOffset::JtableOffsetRest_discriminant" + |), + Value.Integer 0 + |)) + ] + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_rest : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "rest" (rest F). + + (* + pub(super) fn next_rest(&self, meta: &mut VirtualCells) -> Expression { + nextn!( + meta, + self.data, + JtableOffset::JtableOffsetRest as i32 + JtableOffset::JtableOffsetMax as i32 + ) + } + *) + Definition next_rest (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "data" + |) + |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + BinOp.Panic.add (| + Integer.I32, + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::circuits::jtable::JtableOffset::JtableOffsetRest_discriminant" + |), + Value.Integer 0 + |)), + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::circuits::jtable::JtableOffset::JtableOffsetMax_discriminant" + |), + Value.Integer 0 + |)) + |) + ] + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_next_rest : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "next_rest" (next_rest F). + + (* + pub(super) fn entry(&self, meta: &mut VirtualCells) -> Expression { + nextn!(meta, self.data, JtableOffset::JtableOffsetEntry as i32) + } + *) + Definition entry (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "data" + |) + |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::circuits::jtable::JtableOffset::JtableOffsetEntry_discriminant" + |), + Value.Integer 0 + |)) + ] + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_entry : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "entry" (entry F). + + (* + pub(super) fn static_bit(&self, meta: &mut VirtualCells) -> Expression { + fixed_curr!(meta, self.static_bit) + } + *) + Definition static_bit (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "static_bit" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_static_bit : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "static_bit" (static_bit F). + End Impl_delphinus_zkwasm_circuits_jtable_JumpTableConfig_F. + + (* Trait *) + (* Empty module 'JtableLookupEntryEncode' *) + + Module Impl_delphinus_zkwasm_circuits_jtable_expression_JtableLookupEntryEncode_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_jtable_JumpTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::jtable::JumpTableConfig") [ F ]. + + (* + fn encode_lookup( + current_last_jump_eid: Expression, + next_last_jump_eid: Expression, + callee_fid: Expression, + next_fid: Expression, + next_iid: Expression, + ) -> Expression { + encode_frame_table_entry( + current_last_jump_eid, + next_last_jump_eid, + callee_fid, + next_fid, + next_iid, + ) + } + *) + Definition encode_lookup (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ current_last_jump_eid; next_last_jump_eid; callee_fid; next_fid; next_iid ] => + ltac:(M.monadic + (let current_last_jump_eid := M.alloc (| current_last_jump_eid |) in + let next_last_jump_eid := M.alloc (| next_last_jump_eid |) in + let callee_fid := M.alloc (| callee_fid |) in + let next_fid := M.alloc (| next_fid |) in + let next_iid := M.alloc (| next_iid |) in + M.call_closure (| + M.get_function (| + "specs::encode::frame_table::encode_frame_table_entry", + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ] + |), + [ + M.read (| current_last_jump_eid |); + M.read (| next_last_jump_eid |); + M.read (| callee_fid |); + M.read (| next_fid |); + M.read (| next_iid |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::jtable::expression::JtableLookupEntryEncode" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("encode_lookup", InstanceField.Method (encode_lookup F)) ]. + End Impl_delphinus_zkwasm_circuits_jtable_expression_JtableLookupEntryEncode_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_jtable_JumpTableConfig_F. + End expression. + End jtable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/jtable/mod.v b/CoqOfRust/zkWasm/circuits/jtable/mod.v new file mode 100644 index 000000000..a36f01a26 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/jtable/mod.v @@ -0,0 +1,360 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module jtable. + Definition value_STATIC_FRAME_ENTRY_IMAGE_TABLE_ENTRY : Value.t := + M.run + ltac:(M.monadic + (M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + M.read (| M.get_constant (| "specs::jtable::STATIC_FRAME_ENTRY_NUMBER" |) |), + Value.Integer 2 + |) + |))). + + Definition value_JOPS_SEPARATE : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 128 |))). + + (* + pub fn encode_jops(return_instructions: u32, call_instructions: u32) -> BigUint { + return_instructions.to_biguint().unwrap() << JOPS_SEPARATE + | call_instructions.to_biguint().unwrap() + } + *) + Definition encode_jops (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ return_instructions; call_instructions ] => + ltac:(M.monadic + (let return_instructions := M.alloc (| return_instructions |) in + let call_instructions := M.alloc (| call_instructions |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::BitOr", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "num_bigint::biguint::BigUint" ], + "bitor", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "usize" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "num_bigint::biguint::BigUint" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "num_bigint::biguint::ToBigUint", + Ty.path "u32", + [], + "to_biguint", + [] + |), + [ return_instructions ] + |) + ] + |); + M.read (| + M.get_constant (| "delphinus_zkwasm::circuits::jtable::JOPS_SEPARATE" |) + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "num_bigint::biguint::BigUint" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "num_bigint::biguint::ToBigUint", + Ty.path "u32", + [], + "to_biguint", + [] + |), + [ call_instructions ] + |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + Enum JtableOffset + { + ty_params := []; + variants := + [ + { + name := "JtableOffsetEnable"; + item := StructTuple []; + discriminant := Some 0; + }; + { + name := "JtableOffsetRest"; + item := StructTuple []; + discriminant := Some 1; + }; + { + name := "JtableOffsetEntry"; + item := StructTuple []; + discriminant := Some 2; + }; + { + name := "JtableOffsetMax"; + item := StructTuple []; + discriminant := Some 3; + } + ]; + } + *) + + (* StructRecord + { + name := "JumpTableConfig"; + ty_params := [ "F" ]; + fields := + [ + ("sel", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]); + ("static_bit", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]); + ("data", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + ("_m", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_jtable_JumpTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::jtable::JumpTableConfig") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::jtable::JumpTableConfig" + [ + ("sel", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "sel" + |) + ] + |)); + ("static_bit", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "static_bit" + |) + ] + |)); + ("data", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "data" + |) + ] + |)); + ("_m", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::jtable::JumpTableConfig", + "_m" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_jtable_JumpTableConfig_F. + + Module Impl_delphinus_zkwasm_circuits_jtable_JumpTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::jtable::JumpTableConfig") [ F ]. + + (* + pub fn configure( + meta: &mut ConstraintSystem, + cols: &mut impl Iterator>, + ) -> Self { + let jtable = Self::new(meta, cols); + jtable.configure(meta); + jtable + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Iterator_Item___Column_Advice__ ], [ meta; cols ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + let cols := M.alloc (| cols |) in + M.read (| + let jtable := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + "new", + [ impl_Iterator_Item___Column_Advice__ ] + |), + [ M.read (| meta |); M.read (| cols |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::jtable::configure::JTableConstraint", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + [ F ], + "configure", + [] + |), + [ jtable; M.read (| meta |) ] + |) + |) in + jtable + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure" (configure F). + End Impl_delphinus_zkwasm_circuits_jtable_JumpTableConfig_F. + + (* StructRecord + { + name := "JumpTableChip"; + ty_params := [ "F" ]; + fields := + [ + ("config", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::jtable::JumpTableConfig") [ F ]); + ("max_available_rows", Ty.path "usize") + ]; + } *) + + Module Impl_delphinus_zkwasm_circuits_jtable_JumpTableChip_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::jtable::JumpTableChip") [ F ]. + + (* + pub fn new(config: JumpTableConfig, max_available_rows: usize) -> Self { + JumpTableChip { + config, + max_available_rows, + } + } + *) + Definition new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ config; max_available_rows ] => + ltac:(M.monadic + (let config := M.alloc (| config |) in + let max_available_rows := M.alloc (| max_available_rows |) in + Value.StructRecord + "delphinus_zkwasm::circuits::jtable::JumpTableChip" + [ + ("config", M.read (| config |)); + ("max_available_rows", M.read (| max_available_rows |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "new" (new F). + End Impl_delphinus_zkwasm_circuits_jtable_JumpTableChip_F. + End jtable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/mod.v b/CoqOfRust/zkWasm/circuits/mod.v new file mode 100644 index 000000000..4df05568d --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/mod.v @@ -0,0 +1,858 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Axiom CompilationTable : + (Ty.path "delphinus_zkwasm::circuits::CompilationTable") = (Ty.path "specs::CompilationTable"). + + Axiom ExecutionTable : + (Ty.path "delphinus_zkwasm::circuits::ExecutionTable") = (Ty.path "specs::ExecutionTable"). + + (* + pub(crate) fn compute_slice_capability(k: u32) -> u32 { + ((1 << k) - RESERVE_ROWS as u32 - 1024) / EVENT_TABLE_ENTRY_ROWS as u32 + } + *) + Definition compute_slice_capability (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ k ] => + ltac:(M.monadic + (let k := M.alloc (| k |) in + BinOp.Panic.div (| + Integer.U32, + BinOp.Panic.sub (| + Integer.U32, + BinOp.Panic.sub (| + Integer.U32, + BinOp.Panic.shl (| Value.Integer 1, M.read (| k |) |), + M.rust_cast + (M.read (| + M.get_constant (| "delphinus_zkwasm::circuits::zkwasm_circuit::RESERVE_ROWS" |) + |)) + |), + Value.Integer 1024 + |), + M.rust_cast + (M.read (| + M.get_constant (| "delphinus_zkwasm::circuits::etable::EVENT_TABLE_ENTRY_ROWS" |) + |)) + |))) + | _, _ => M.impossible + end. + + (* StructRecord + { + name := "ZkWasmCircuit"; + ty_params := [ "F" ]; + fields := + [ + ("k", Ty.path "u32"); + ("slice", Ty.path "specs::slice::Slice"); + ("_data", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_delphinus_zkwasm_circuits_ZkWasmCircuit_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::ZkWasmCircuit") [ F ]. + + (* + pub fn new(k: u32, slice: Slice) -> Result { + { + // entries is empty when called by without_witness + let allocated_memory_pages = slice + .etable + .entries() + .last() + .map(|entry| entry.allocated_memory_pages); + let maximal_pages = compute_maximal_pages(k); + if let Some(allocated_memory_pages) = allocated_memory_pages { + if allocated_memory_pages > maximal_pages { + return Err(BuildingCircuitError::PagesExceedLimit( + allocated_memory_pages, + maximal_pages, + k, + )); + } + } + } + + { + let etable_entires = slice.etable.entries().len() as u32; + let etable_capacity = compute_slice_capability(k); + + if etable_entires > etable_capacity { + return Err(BuildingCircuitError::EtableEntriesExceedLimit( + etable_entires as u32, + etable_capacity as u32, + k, + )); + } + } + + Ok(ZkWasmCircuit { + k, + slice, + _data: PhantomData, + }) + } + *) + Definition new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ k; slice ] => + ltac:(M.monadic + (let k := M.alloc (| k |) in + let slice := M.alloc (| slice |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + let allocated_memory_pages := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.path "specs::etable::EventTableEntry" ] ], + "map", + [ + Ty.path "u32"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "specs::etable::EventTableEntry" ] + ] + ] + (Ty.path "u32") + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::etable::EventTableEntry" ], + "last", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::etable::EventTableEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::etable::EventTable", + "entries", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::etable::EventTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + slice, + "specs::slice::Slice", + "etable" + |) + ] + |) + ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let entry := M.copy (| γ |) in + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "specs::etable::EventTableEntry", + "allocated_memory_pages" + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let maximal_pages := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::image_table::compute_maximal_pages", + [] + |), + [ M.read (| k |) ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := allocated_memory_pages in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let allocated_memory_pages := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| allocated_memory_pages |)) + (M.read (| maximal_pages |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "delphinus_zkwasm::error::BuildingCircuitError::PagesExceedLimit" + [ + M.read (| allocated_memory_pages |); + M.read (| maximal_pages |); + M.read (| k |) + ] + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + let etable_entires := + M.alloc (| + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::etable::EventTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::etable::EventTable", + "entries", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::etable::EventTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + slice, + "specs::slice::Slice", + "etable" + |) + ] + |) + ] + |) + ] + |)) + |) in + let etable_capacity := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::compute_slice_capability", + [] + |), + [ M.read (| k |) ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| etable_entires |)) + (M.read (| etable_capacity |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "delphinus_zkwasm::error::BuildingCircuitError::EtableEntriesExceedLimit" + [ + M.read (| M.use etable_entires |); + M.read (| M.use etable_capacity |); + M.read (| k |) + ] + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "delphinus_zkwasm::circuits::ZkWasmCircuit" + [ + ("k", M.read (| k |)); + ("slice", M.read (| slice |)); + ("_data", Value.StructTuple "core::marker::PhantomData" []) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : forall (F : Ty.t), M.IsAssociatedFunction (Self F) "new" (new F). + + (* + pub fn mock_test(&self, instances: Vec) -> anyhow::Result<()> { + let prover = MockProver::run(self.k, self, vec![instances])?; + assert_eq!(prover.verify(), Ok(())); + + Ok(()) + } + *) + Definition mock_test (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; instances ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let instances := M.alloc (| instances |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let prover := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::dev::MockVerifier") [ F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::dev::MockProver") [ F ], + "run", + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::ZkWasmCircuit") + [ F ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "k" + |) + |); + M.read (| self |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.alloc (| Value.Array [ M.read (| instances |) ] |) ] + |) + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "anyhow::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::dev::MockVerifier") [ F ], + "verify", + [] + |), + [ prover ] + |) + |); + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::dev::VerifyFailure"; + Ty.path "alloc::alloc::Global" + ] + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::dev::VerifyFailure"; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "eq", + [] + |), + [ M.read (| left_val |); M.read (| right_val |) ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::dev::VerifyFailure"; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::dev::VerifyFailure"; + Ty.path "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_mock_test : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "mock_test" (mock_test F). + End Impl_delphinus_zkwasm_circuits_ZkWasmCircuit_F. + + (* Trait *) + (* Empty module 'Encode' *) + + (* Trait *) + Module Lookup. + Definition configure_in_table (F Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_ ], [ self; meta; key; expr ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let key := M.alloc (| key |) in + let expr := M.alloc (| expr |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "lookup_any", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] + ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| key |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ + M.read (| expr |); + Value.Tuple [ M.read (| meta |) ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::Lookup", + Self, + [ F ], + "encode", + [] + |), + [ M.read (| self |); M.read (| meta |) ] + |) + ] + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_configure_in_table : + forall (F : Ty.t), + M.IsProvidedMethod + "delphinus_zkwasm::circuits::Lookup" + "configure_in_table" + (configure_in_table F). + End Lookup. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/mtable/allocator.v b/CoqOfRust/zkWasm/circuits/mtable/allocator.v new file mode 100644 index 000000000..9b09cc109 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/mtable/allocator.v @@ -0,0 +1,4558 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module mtable. + Module allocator. + (* Trait *) + (* Empty module 'MemoryTableCellExpression' *) + + Module Impl_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ]. + + (* + fn next_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + nextn!(meta, self.col, self.rot + MEMORY_TABLE_ENTRY_ROWS as i32) + } + *) + Definition next_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "col" + |) + |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + BinOp.Panic.add (| + Integer.I32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "rot" + |) + |), + M.read (| + M.use + (M.get_constant (| + "delphinus_zkwasm::circuits::mtable::MEMORY_TABLE_ENTRY_ROWS" + |)) + |) + |) + ] + ] + |))) + | _, _ => M.impossible + end. + + (* + fn prev_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + nextn!(meta, self.col, self.rot - MEMORY_TABLE_ENTRY_ROWS as i32) + } + *) + Definition prev_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "col" + |) + |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + BinOp.Panic.sub (| + Integer.I32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "rot" + |) + |), + M.read (| + M.use + (M.get_constant (| + "delphinus_zkwasm::circuits::mtable::MEMORY_TABLE_ENTRY_ROWS" + |)) + |) + |) + ] + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("next_expr", InstanceField.Method (next_expr F)); + ("prev_expr", InstanceField.Method (prev_expr F)) + ]. + End Impl_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedCell_F. + + Module Impl_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedBitCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]. + + (* + fn next_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.next_expr(meta) + } + *) + Definition next_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "next_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedBitCell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn prev_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.prev_expr(meta) + } + *) + Definition prev_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "prev_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedBitCell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("next_expr", InstanceField.Method (next_expr F)); + ("prev_expr", InstanceField.Method (prev_expr F)) + ]. + End Impl_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedBitCell_F. + + Module Impl_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedCommonRangeCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") [ F ]. + + (* + fn next_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.next_expr(meta) + } + *) + Definition next_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "next_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn prev_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.prev_expr(meta) + } + *) + Definition prev_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "prev_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("next_expr", InstanceField.Method (next_expr F)); + ("prev_expr", InstanceField.Method (prev_expr F)) + ]. + End Impl_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedCommonRangeCell_F. + + Module Impl_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedU16Cell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") [ F ]. + + (* + fn next_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.next_expr(meta) + } + *) + Definition next_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "next_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn prev_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.prev_expr(meta) + } + *) + Definition prev_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "prev_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("next_expr", InstanceField.Method (next_expr F)); + ("prev_expr", InstanceField.Method (prev_expr F)) + ]. + End Impl_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedU16Cell_F. + + Module Impl_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedUnlimitedCell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]. + + (* + fn next_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.next_expr(meta) + } + *) + Definition next_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "next_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn prev_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.cell.prev_expr(meta) + } + *) + Definition prev_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCell") [ F ], + [ F ], + "prev_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell", + "cell" + |); + M.read (| meta |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("next_expr", InstanceField.Method (next_expr F)); + ("prev_expr", InstanceField.Method (prev_expr F)) + ]. + End Impl_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedUnlimitedCell_F. + + Module Impl_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedU32Cell_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") [ F ]. + + (* + fn next_expr(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + self.u16_cells_le[0].next_expr(meta) + + (self.u16_cells_le[1].next_expr(meta) * constant_from!(1 << 16)) + } + *) + Definition next_expr (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") [ F ], + [ F ], + "next_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell", + "u16_cells_le" + |), + M.alloc (| Value.Integer 0 |) + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell", + "u16_cells_le" + |), + M.alloc (| Value.Integer 1 |) + |); + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.rust_cast (BinOp.Panic.shl (| Value.Integer 1, Value.Integer 16 |)) + ] + |) + ] + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn prev_expr(&self, _meta: &mut VirtualCells<'_, F>) -> Expression { + unimplemented!() + } + *) + Parameter prev_expr : forall (F : Ty.t), (list Ty.t) -> (list Value.t) -> M. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("next_expr", InstanceField.Method (next_expr F)); + ("prev_expr", InstanceField.Method (prev_expr F)) + ]. + End Impl_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellExpression_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_cell_AllocatedU32Cell_F. + + (* + Enum MemoryTableCellType + { + ty_params := []; + variants := + [ + { + name := "Bit"; + item := StructTuple []; + discriminant := Some 1; + }; + { + name := "U16"; + item := StructTuple []; + discriminant := None; + }; + { + name := "CommonRange"; + item := StructTuple []; + discriminant := None; + }; + { + name := "Unlimited"; + item := StructTuple []; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_fmt_Debug_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellType. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ + M.read (| f |); + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| M.read (| Value.String "Bit" |) |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| M.read (| Value.String "U16" |) |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| M.read (| Value.String "CommonRange" |) |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| M.read (| Value.String "Unlimited" |) |))) + ] + |) + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellType. + + Module Impl_core_clone_Clone_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellType. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| M.read (| self |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellType. + + Module Impl_core_marker_Copy_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellType. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellType. + + Module Impl_core_marker_StructuralPartialEq_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellType. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralPartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralPartialEq_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellType. + + Module Impl_core_cmp_PartialEq_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellType. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType". + + (* PartialEq *) + Definition eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType" + ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType" + ] + |), + [ M.read (| other |) ] + |) + |) in + M.alloc (| BinOp.Pure.eq (M.read (| __self_tag |)) (M.read (| __arg1_tag |)) |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("eq", InstanceField.Method eq) ]. + End Impl_core_cmp_PartialEq_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellType. + + Module Impl_core_marker_StructuralEq_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellType. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType". + + Axiom Implements : + M.IsTraitInstance + "core::marker::StructuralEq" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_StructuralEq_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellType. + + Module Impl_core_cmp_Eq_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellType. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType". + + (* Eq *) + Definition assert_receiver_is_total_eq (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.Tuple [])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Eq" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("assert_receiver_is_total_eq", InstanceField.Method assert_receiver_is_total_eq) ]. + End Impl_core_cmp_Eq_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellType. + + Module Impl_core_cmp_PartialOrd_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellType. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType". + + (* PartialOrd *) + Definition partial_cmp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType" + ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType" + ] + |), + [ M.read (| other |) ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "isize", + [ Ty.path "isize" ], + "partial_cmp", + [] + |), + [ __self_tag; __arg1_tag ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::PartialOrd" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("partial_cmp", InstanceField.Method partial_cmp) ]. + End Impl_core_cmp_PartialOrd_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellType. + + Module Impl_core_cmp_Ord_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellType. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType". + + (* Ord *) + Definition cmp (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.read (| + let __self_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType" + ] + |), + [ M.read (| self |) ] + |) + |) in + let __arg1_tag := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::intrinsics::discriminant_value", + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType" + ] + |), + [ M.read (| other |) ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| "core::cmp::Ord", Ty.path "isize", [], "cmp", [] |), + [ __self_tag; __arg1_tag ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::cmp::Ord" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("cmp", InstanceField.Method cmp) ]. + End Impl_core_cmp_Ord_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellType. + + Definition value_BIT_COLUMNS : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 3 |))). + + Definition value_U16_COLUMNS : Value.t := + M.run + ltac:(M.monadic + (M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.div (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| Ty.path "usize", "next_multiple_of", [] |), + [ + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::allocator::U32_CELLS" + |) + |); + Value.Integer 2 + ] + |), + Value.Integer 2 + |), + M.read (| + M.get_constant (| "delphinus_zkwasm::circuits::mtable::allocator::U64_CELLS" |) + |) + |) + |))). + + Definition value_COMMON_RANGE_COLUMNS : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 1 |))). + + Definition value_UNLIMITED_COLUMNS : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 2 |))). + + Definition value_U32_CELLS : Value.t := + M.run + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use (M.alloc (| Value.Bool false |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| Value.Integer 5 |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Integer 2 |))) + ] + |))). + + Definition value_U64_CELLS : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 1 |))). + + (* StructRecord + { + name := "MemoryTableCellAllocator"; + ty_params := [ "F" ]; + fields := + [ + ("k", Ty.path "u32"); + ("all_cols", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ]); + ("free_cells", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]); + ("free_u32_cells", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") [ F ]; + Ty.path "alloc::alloc::Global" + ]); + ("free_u64_cells", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]; + Ty.path "alloc::alloc::Global" + ]); + ("_mark", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellAllocator_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ]. + + (* Debug *) + Definition fmt (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let names := + M.alloc (| + M.alloc (| + Value.Array + [ + M.read (| Value.String "k" |); + M.read (| Value.String "all_cols" |); + M.read (| Value.String "free_cells" |); + M.read (| Value.String "free_u32_cells" |); + M.read (| Value.String "free_u64_cells" |); + M.read (| Value.String "_mark" |) + ] + |) + |) in + let values := + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "k" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "all_cols" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "free_cells" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "free_u32_cells" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "free_u64_cells" + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "_mark" + |) + |)) + ] + |)) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_fields_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "MemoryTableCellAllocator" |); + (* Unsize *) M.pointer_coercion (M.read (| names |)); + M.read (| values |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt F)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellAllocator_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellAllocator_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator" + [ + ("k", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "k" + |) + ] + |)); + ("all_cols", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "all_cols" + |) + ] + |)); + ("free_cells", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "free_cells" + |) + ] + |)); + ("free_u32_cells", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "free_u32_cells" + |) + ] + |)); + ("free_u64_cells", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "free_u64_cells" + |) + ] + |)); + ("_mark", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "_mark" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellAllocator_F. + + Module Impl_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellAllocator_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ]. + + (* + pub fn assert_no_free_cells(&self) { + for (t, (i, j)) in &self.free_cells { + let cols = self.all_cols.get(t).unwrap(); + + assert!( + *i == cols.len() || ( *i == cols.len() - 1 && *j > 0), + "unused {:?} col should be removed: {}.", + t, + cols.len() - *i - ( *j != 0) as usize + ); + } + + assert!( + self.free_u32_cells.is_empty(), + "unused u32 cells should be removed: {:?}.", + self.free_u32_cells.len() + ); + assert!( + self.free_u64_cells.is_empty(), + "unused u64 cells should be removed: {:?}.", + self.free_u64_cells.len() + ); + } + *) + Definition assert_no_free_cells (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "free_cells" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let t := M.copy (| γ1_0 |) in + let γ1_1 := M.read (| γ1_1 |) in + let γ3_0 := M.SubPointer.get_tuple_field (| γ1_1, 0 |) in + let γ3_1 := M.SubPointer.get_tuple_field (| γ1_1, 1 |) in + let i := M.alloc (| γ3_0 |) in + let j := M.alloc (| γ3_1 |) in + let cols := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "get", + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "all_cols" + |); + M.read (| t |) + ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (LogicalOp.or (| + BinOp.Pure.eq + (M.read (| M.read (| i |) |)) + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| cols |) ] + |)), + ltac:(M.monadic + (LogicalOp.and (| + BinOp.Pure.eq + (M.read (| M.read (| i |) |)) + (BinOp.Panic.sub (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| cols |) ] + |), + Value.Integer 1 + |)), + ltac:(M.monadic + (BinOp.Pure.gt + (M.read (| M.read (| j |) |)) + (Value.Integer 0))) + |))) + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic_fmt", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String "unused " + |); + M.read (| + Value.String + " col should be removed: " + |); + M.read (| + Value.String "." + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_debug", + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType" + ] + ] + |), + [ t ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + BinOp.Panic.sub (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.read (| + cols + |) + ] + |), + M.read (| + M.read (| i |) + |) + |), + M.rust_cast + (BinOp.Pure.ne + (M.read (| + M.read (| j |) + |)) + (Value.Integer + 0)) + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) + |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "is_empty", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "free_u32_cells" + |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic_fmt", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String "unused u32 cells should be removed: " + |); + M.read (| Value.String "." |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ Ty.path "usize" ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "free_u32_cells" + |) + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "is_empty", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "free_u64_cells" + |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic_fmt", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String "unused u64 cells should be removed: " + |); + M.read (| Value.String "." |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ Ty.path "usize" ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "free_u64_cells" + |) + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assert_no_free_cells : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assert_no_free_cells" (assert_no_free_cells F). + + (* + pub fn enable_equality(&mut self, meta: &mut ConstraintSystem, t: &MemoryTableCellType) { + for c in self.all_cols.get(t).unwrap() { + meta.enable_equality( *c); + } + } + *) + Definition enable_equality (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta; t ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let t := M.alloc (| t |) in + M.read (| + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "get", + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "all_cols" + |); + M.read (| t |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let c := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "enable_equality", + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" + ] + ] + |), + [ M.read (| meta |); M.read (| M.read (| c |) |) ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_enable_equality : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "enable_equality" (enable_equality F). + + (* + pub(super) fn prepare_alloc_u32_cell(&mut self) -> AllocatedU32Cell { + let u16_cells_le = [0; 2].map(|_| self.alloc_u16_cell()); + + AllocatedU32Cell { u16_cells_le } + } + *) + Definition prepare_alloc_u32_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let u16_cells_le := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.path "i32" ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "i32" ] ] + (Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ]); + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ] + ] + |), + [ + repeat (Value.Integer 0) 2; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_u16_cell", + [] + |), + [ M.read (| self |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell" + [ ("u16_cells_le", M.read (| u16_cells_le |)) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_prepare_alloc_u32_cell : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "prepare_alloc_u32_cell" (prepare_alloc_u32_cell F). + + (* + pub(super) fn prepare_alloc_u64_cell( + &mut self, + meta: &mut ConstraintSystem, + enable: impl Fn(&mut VirtualCells<'_, F>) -> Expression, + ) -> AllocatedU64Cell { + let u16_cells_le = [0; 4].map(|_| self.alloc_u16_cell()); + let u64_cell = self.alloc_unlimited_cell(); + meta.create_gate("mc9. value", |meta| { + let init = u64_cell.curr_expr(meta); + vec![ + (0..4) + .into_iter() + .map(|x| u16_cells_le[x].curr_expr(meta) * constant_from!(1u64 << (16 * x))) + .fold(init, |acc, x| acc - x) + * enable(meta), + ] + }); + AllocatedU64Cell { + u16_cells_le, + u64_cell, + } + } + *) + Definition prepare_alloc_u64_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_ ], [ self; meta; enable ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let enable := M.alloc (| enable |) in + M.read (| + let u16_cells_le := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.path "i32" ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "i32" ] ] + (Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ]); + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ] + ] + |), + [ + repeat (Value.Integer 0) 4; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_u16_cell", + [] + |), + [ M.read (| self |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let u64_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| self |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "mc9. value" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let init := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ u64_cell; M.read (| meta |) ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ]; + Ty.function + [ + Ty.tuple + [ Ty.path "usize" ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "fold", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ Ty.path "usize" + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + Value.Integer + 0); + ("end_", + Value.Integer 4) + ] + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let x := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ + F + ], + [ + F + ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + u16_cells_le, + x + |); + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + BinOp.Panic.shl (| + Value.Integer + 1, + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer + 16, + M.read (| + x + |) + |) + |) + |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |); + M.read (| init |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun γ => + ltac:(M.monadic + (let + x := + M.copy (| + γ + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ + F + ] + ], + "sub", + [] + |), + [ + M.read (| + acc + |); + M.read (| + x + |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + enable; + Value.Tuple + [ M.read (| meta |) ] + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell" + [ + ("u16_cells_le", M.read (| u16_cells_le |)); + ("u64_cell", M.read (| u64_cell |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_prepare_alloc_u64_cell : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "prepare_alloc_u64_cell" (prepare_alloc_u64_cell F). + + (* + pub(super) fn new( + meta: &mut ConstraintSystem, + k: u32, + sel: Column, + rtable: &RangeTableConfig, + cols: &mut impl Iterator>, + ) -> Self { + let mut allocator = Self::_new(meta, k, sel.clone(), rtable, cols); + for _ in 0..U32_CELLS { + let cell = allocator.prepare_alloc_u32_cell(); + allocator.free_u32_cells.push(cell); + } + for _ in 0..U64_CELLS { + let cell = allocator.prepare_alloc_u64_cell(meta, |meta| fixed_curr!(meta, sel)); + allocator.free_u64_cells.push(cell); + } + allocator + } + *) + Definition new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Iterator_Item___Column_Advice__ ], [ meta; k; sel; rtable; cols ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + let k := M.alloc (| k |) in + let sel := M.alloc (| sel |) in + let rtable := M.alloc (| rtable |) in + let cols := M.alloc (| cols |) in + M.read (| + let allocator := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "_new", + [ impl_Iterator_Item___Column_Advice__ ] + |), + [ + M.read (| meta |); + M.read (| k |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [], + "clone", + [] + |), + [ sel ] + |); + M.read (| rtable |); + M.read (| cols |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::allocator::U32_CELLS" + |) + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "prepare_alloc_u32_cell", + [] + |), + [ allocator ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + allocator, + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "free_u32_cells" + |); + M.read (| cell |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::allocator::U64_CELLS" + |) + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "prepare_alloc_u64_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + allocator; + M.read (| meta |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + allocator, + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "free_u64_cells" + |); + M.read (| cell |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + allocator + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "new" (new F). + + (* + fn _new( + meta: &mut ConstraintSystem, + k: u32, + sel: Column, + rtable: &RangeTableConfig, + cols: &mut impl Iterator>, + ) -> Self { + let mut all_cols = BTreeMap::new(); + all_cols.insert( + MemoryTableCellType::Bit, + [0; BIT_COLUMNS] + .map(|_| BitColumn::configure(meta, cols, |meta| fixed_curr!(meta, sel)).col) + .into_iter() + .collect(), + ); + all_cols.insert( + MemoryTableCellType::U16, + [0; U16_COLUMNS] + .map(|_| U16Column::configure(meta, cols, rtable, |_| constant_from!(1)).col) + .into_iter() + .collect(), + ); + all_cols.insert( + MemoryTableCellType::CommonRange, + [0; COMMON_RANGE_COLUMNS] + .map(|_| { + CommonRangeColumn::configure(meta, cols, rtable, |_| constant_from!(1)).col + }) + .into_iter() + .collect(), + ); + all_cols.insert( + MemoryTableCellType::Unlimited, + [0; UNLIMITED_COLUMNS] + .map(|_| cols.next().unwrap()) + .into_iter() + .collect(), + ); + Self { + k, + all_cols, + free_cells: BTreeMap::from_iter( + vec![ + (MemoryTableCellType::Bit, (0, 0)), + (MemoryTableCellType::U16, (0, 0)), + (MemoryTableCellType::CommonRange, (0, 0)), + (MemoryTableCellType::Unlimited, (0, 0)), + ] + .into_iter(), + ), + free_u32_cells: vec![], + free_u64_cells: vec![], + _mark: PhantomData, + } + } + *) + Definition _new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Iterator_Item___Column_Advice__ ], [ meta; k; sel; rtable; cols ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + let k := M.alloc (| k |) in + let sel := M.alloc (| sel |) in + let rtable := M.alloc (| rtable |) in + let cols := M.alloc (| cols |) in + M.read (| + let all_cols := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + all_cols; + Value.StructTuple + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType::Bit" + []; + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.path "i32" ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "i32" ] ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ] + |), + [ + repeat (Value.Integer 0) 3; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + M.SubPointer.get_struct_record_field (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::bit::BitColumn") + [ F ], + "configure", + [ + impl_Iterator_Item___Column_Advice__; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| meta |); + M.read (| cols |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := + M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |), + "delphinus_zkwasm::circuits::utils::bit::BitColumn", + "col" + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + all_cols; + Value.StructTuple + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType::U16" + []; + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.path "i32" ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "i32" ] ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ] + |), + [ + repeat (Value.Integer 0) 2; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + M.SubPointer.get_struct_record_field (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::u16::U16Column") + [ F ], + "configure", + [ + impl_Iterator_Item___Column_Advice__; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| meta |); + M.read (| cols |); + M.read (| rtable |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |), + "delphinus_zkwasm::circuits::utils::u16::U16Column", + "col" + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + all_cols; + Value.StructTuple + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType::CommonRange" + []; + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.path "i32" ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "i32" ] ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ] + |), + [ + repeat (Value.Integer 0) 1; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + M.SubPointer.get_struct_record_field (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::common_range::CommonRangeColumn") + [ F ], + "configure", + [ + impl_Iterator_Item___Column_Advice__; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.read (| meta |); + M.read (| cols |); + M.read (| rtable |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |), + "delphinus_zkwasm::circuits::utils::common_range::CommonRangeColumn", + "col" + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + all_cols; + Value.StructTuple + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType::Unlimited" + []; + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.path "i32" ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.path "i32" ] ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ] + |), + [ + repeat (Value.Integer 0) 2; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___Column_Advice__, + [], + "next", + [] + |), + [ M.read (| cols |) ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator" + [ + ("k", M.read (| k |)); + ("all_cols", M.read (| all_cols |)); + ("free_cells", + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::FromIterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.tuple + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] + ] + ], + "from_iter", + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.tuple + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] + ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + Value.StructTuple + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType::Bit" + []; + Value.Tuple + [ Value.Integer 0; Value.Integer 0 ] + ]; + Value.Tuple + [ + Value.StructTuple + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType::U16" + []; + Value.Tuple + [ Value.Integer 0; Value.Integer 0 ] + ]; + Value.Tuple + [ + Value.StructTuple + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType::CommonRange" + []; + Value.Tuple + [ Value.Integer 0; Value.Integer 0 ] + ]; + Value.Tuple + [ + Value.StructTuple + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType::Unlimited" + []; + Value.Tuple + [ Value.Integer 0; Value.Integer 0 ] + ] + ] + |) + ] + |) + |)) + ] + |) + ] + |) + ] + |)); + ("free_u32_cells", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("free_u64_cells", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("_mark", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction__new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "_new" (_new F). + + (* + fn alloc(&mut self, t: &MemoryTableCellType) -> AllocatedCell { + let v = self.free_cells.get_mut(t).unwrap(); + let res = AllocatedCell { + col: self.all_cols.get(t).unwrap()[v.0], + rot: v.1 as i32, + _mark: PhantomData, + }; + + v.1 += 1; + if v.1 == MEMORY_TABLE_ENTRY_ROWS as u32 { + v.0 += 1; + v.1 = 0; + } + + res + } + *) + Definition alloc (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; t ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let t := M.alloc (| t |) in + M.read (| + let v := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ Ty.tuple [ Ty.path "usize"; Ty.path "u32" ] ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.tuple [ Ty.path "usize"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + "get_mut", + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "free_cells" + |); + M.read (| t |) + ] + |) + ] + |) + |) in + let res := + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedCell" + [ + ("col", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType"; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "get", + [ + Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "all_cols" + |); + M.read (| t |) + ] + |) + ] + |); + M.read (| M.SubPointer.get_tuple_field (| M.read (| v |), 0 |) |) + ] + |) + |)); + ("rot", + M.rust_cast + (M.read (| M.SubPointer.get_tuple_field (| M.read (| v |), 1 |) |))); + ("_mark", Value.StructTuple "core::marker::PhantomData" []) + ] + |) in + let _ := + let β := M.SubPointer.get_tuple_field (| M.read (| v |), 1 |) in + M.write (| + β, + BinOp.Panic.add (| Integer.U32, M.read (| β |), Value.Integer 1 |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| + M.SubPointer.get_tuple_field (| M.read (| v |), 1 |) + |)) + (M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::MEMORY_TABLE_ENTRY_ROWS" + |) + |))) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let _ := + let β := M.SubPointer.get_tuple_field (| M.read (| v |), 0 |) in + M.write (| + β, + BinOp.Panic.add (| Integer.Usize, M.read (| β |), Value.Integer 1 |) + |) in + let _ := + M.write (| + M.SubPointer.get_tuple_field (| M.read (| v |), 1 |), + Value.Integer 0 + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + res + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "alloc" (alloc F). + + (* + pub(super) fn alloc_bit_cell(&mut self) -> AllocatedBitCell { + AllocatedBitCell { + cell: self.alloc(&MemoryTableCellType::Bit), + } + } + *) + Definition alloc_bit_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedBitCell" + [ + ("cell", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc", + [] + |), + [ + M.read (| self |); + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType::Bit" + [] + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_bit_cell : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "alloc_bit_cell" (alloc_bit_cell F). + + (* + pub(super) fn alloc_common_range_cell(&mut self) -> AllocatedCommonRangeCell { + AllocatedCommonRangeCell { + cell: self.alloc(&MemoryTableCellType::CommonRange), + upper_bound: F::from(common_range_max(self.k) as u64), + } + } + *) + Definition alloc_common_range_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell" + [ + ("cell", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc", + [] + |), + [ + M.read (| self |); + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType::CommonRange" + [] + |) + ] + |)); + ("upper_bound", + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::config::common_range_max", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "k" + |) + |) + ] + |)) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_common_range_cell : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "alloc_common_range_cell" (alloc_common_range_cell F). + + (* + pub(super) fn alloc_u32_state_cell(&mut self) -> AllocatedCommonRangeCell { + self.alloc_common_range_cell() + } + *) + Definition alloc_u32_state_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ M.read (| self |) ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_u32_state_cell : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "alloc_u32_state_cell" (alloc_u32_state_cell F). + + (* + pub(super) fn alloc_u16_cell(&mut self) -> AllocatedU16Cell { + AllocatedU16Cell { + cell: self.alloc(&MemoryTableCellType::U16), + } + } + *) + Definition alloc_u16_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell" + [ + ("cell", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc", + [] + |), + [ + M.read (| self |); + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType::U16" + [] + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_u16_cell : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "alloc_u16_cell" (alloc_u16_cell F). + + (* + pub(super) fn alloc_unlimited_cell(&mut self) -> AllocatedUnlimitedCell { + AllocatedUnlimitedCell { + cell: self.alloc(&MemoryTableCellType::Unlimited), + } + } + *) + Definition alloc_unlimited_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell" + [ + ("cell", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc", + [] + |), + [ + M.read (| self |); + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType::Unlimited" + [] + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_unlimited_cell : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "alloc_unlimited_cell" (alloc_unlimited_cell F). + + (* + pub(super) fn alloc_u32_cell(&mut self) -> AllocatedU32Cell { + self.free_u32_cells.pop().expect("no more free u32 cells") + } + *) + Definition alloc_u32_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") [ F ] + ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "pop", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "free_u32_cells" + |) + ] + |); + M.read (| Value.String "no more free u32 cells" |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_u32_cell : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "alloc_u32_cell" (alloc_u32_cell F). + + (* + pub(super) fn alloc_u64_cell(&mut self) -> AllocatedU64Cell { + self.free_u64_cells.pop().expect("no more free u64 cells") + } + *) + Definition alloc_u64_cell (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ] + ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "pop", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator", + "free_u64_cells" + |) + ] + |); + M.read (| Value.String "no more free u64 cells" |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_alloc_u64_cell : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "alloc_u64_cell" (alloc_u64_cell F). + End Impl_delphinus_zkwasm_circuits_mtable_allocator_MemoryTableCellAllocator_F. + End allocator. + End mtable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/mtable/assign.v b/CoqOfRust/zkWasm/circuits/mtable/assign.v new file mode 100644 index 000000000..4bd5511ea --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/mtable/assign.v @@ -0,0 +1,4930 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module mtable. + Module assign. + Module Impl_delphinus_zkwasm_circuits_mtable_MemoryTableChip_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::mtable::MemoryTableChip") [ F ]. + + (* + fn assign_fixed(&self, ctx: &mut Context<'_, F>) -> Result<(), Error> { + let capability = self.maximal_available_rows / MEMORY_TABLE_ENTRY_ROWS as usize; + + for i in 0..capability { + ctx.region.assign_fixed( + || "mtable: sel", + self.config.entry_sel, + ctx.offset, + || Ok(F::one()), + )?; + + if i == capability - 1 { + ctx.region.assign_advice_from_constant( + || "rest_mops terminate", + self.config.rest_mops_cell.cell.col, + ctx.offset + self.config.rest_mops_cell.cell.rot as usize, + F::zero(), + )?; + + #[cfg(feature = "continuation")] + ctx.region.assign_advice_from_constant( + || "rest_memory_finalize_ops terminate", + self.config.rest_memory_finalize_ops_cell.cell.col, + ctx.offset + self.config.rest_memory_finalize_ops_cell.cell.rot as usize, + F::zero(), + )?; + } + + ctx.step(MEMORY_TABLE_ENTRY_ROWS as usize); + } + + Ok(()) + } + *) + Definition assign_fixed (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let capability := + M.alloc (| + BinOp.Panic.div (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "maximal_available_rows" + |) + |), + M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::MEMORY_TABLE_ENTRY_ROWS" + |) + |)) + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ ("start", Value.Integer 0); ("end_", M.read (| capability |)) ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_fixed", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "mtable: sel" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "entry_sel" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| i |)) + (BinOp.Panic.sub (| + Integer.Usize, + M.read (| capability |), + Value.Integer 1 + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "assign_advice_from_constant", + [ + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "rest_mops terminate" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "rest_mops_cell" + |), + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell", + "cell" + |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "col" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |), + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "rest_mops_cell" + |), + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell", + "cell" + |), + "delphinus_zkwasm::circuits::cell::AllocatedCell", + "rot" + |) + |)) + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "step", + [] + |), + [ + M.read (| ctx |); + M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::MEMORY_TABLE_ENTRY_ROWS" + |) + |)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_fixed : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign_fixed" (assign_fixed F). + + (* + fn constrain_rest_mops_permutation( + &self, + ctx: &mut Context<'_, F>, + init_rest_mops: u64, + ) -> Result, Error> { + let cell = self + .config + .rest_mops_cell + .assign(ctx, F::from(init_rest_mops))?; + + Ok(cell) + } + *) + Definition constrain_rest_mops_permutation + (F : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; init_rest_mops ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let init_rest_mops := M.alloc (| init_rest_mops |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let cell := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "rest_mops_cell" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| init_rest_mops |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| cell |) ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_constrain_rest_mops_permutation : + forall (F : Ty.t), + M.IsAssociatedFunction + (Self F) + "constrain_rest_mops_permutation" + (constrain_rest_mops_permutation F). + + (* + fn assign_entries( + &self, + region: &Region<'_, F>, + mtable: &MemoryWritingTable, + init_rest_mops: u64, + _rest_memory_finalize_ops: u32, + ) -> Result<(), Error> { + macro_rules! assign_advice { + ($ctx:expr, $cell:ident, $value:expr) => { + self.config.$cell.assign($ctx, $value).unwrap() + }; + } + + cfg_if::cfg_if! { + if #[cfg(feature = "continuation")] { + macro_rules! assign_u32_state { + ($ctx:expr, $cell:ident, $value:expr) => { + self.config.$cell.assign($ctx, $value).unwrap() + } + } + } else { + macro_rules! assign_u32_state { + ($ctx:expr, $cell:ident, $value:expr) => { + assign_advice!($ctx, $cell, F::from($value as u64)) + } + } + } + } + + macro_rules! assign_bit { + ($ctx:expr, $cell:ident) => { + assign_advice!($ctx, $cell, F::one()) + }; + } + + macro_rules! assign_bit_if { + ($ctx:expr, $cond:expr, $cell:ident) => { + if $cond { + assign_advice!($ctx, $cell, F::one()); + } + }; + } + + struct Status { + rest_mops: u64, + + init_encode: F, + + is_next_same_ltype_cell: bool, + is_next_same_offset_cell: bool, + offset_diff: u32, + + _rest_memory_finalize_ops: u32, + _post_init_encode_cell: Option, + } + + let status = { + let mut status = Vec::with_capacity(mtable.0.len()); + + let mut rest_mops = init_rest_mops; + let mut _rest_memory_finalize_ops = _rest_memory_finalize_ops; + let mut current_address_init_encode = None; + + let mut iter = mtable.0.iter().peekable(); + + let is_finalized_writing_entry = + |entry: &MemoryWritingEntry, next_entry: Option<&&MemoryWritingEntry>| { + entry.entry.atype == AccessType::Write + && (next_entry.is_none() + || !next_entry + .as_ref() + .unwrap() + .entry + .is_same_location(&entry.entry)) + }; + + while let Some(curr) = iter.next() { + let next = iter.peek(); + + if curr.entry.atype.is_init() { + current_address_init_encode = + Some(bn_to_field(&encode_init_memory_table_entry( + (curr.entry.ltype as u64).into(), + curr.entry.offset.into(), + (curr.entry.is_mutable as u64).into(), + curr.entry.eid.into(), + curr.entry.value.into(), + ))); + } + + let (is_next_same_ltype_cell, is_next_same_offset_cell, offset_diff) = + if let Some(next) = next { + if curr.entry.ltype == next.entry.ltype { + let offset_diff = next.entry.offset - curr.entry.offset; + + (true, curr.entry.offset == next.entry.offset, offset_diff) + } else { + (false, false, 0u32) + } + } else { + (false, false, 0u32) + }; + + status.push(Status { + rest_mops, + + init_encode: current_address_init_encode.unwrap_or(F::zero()), + + is_next_same_ltype_cell, + is_next_same_offset_cell, + offset_diff, + + _rest_memory_finalize_ops, + _post_init_encode_cell: if is_finalized_writing_entry(curr, next) { + Some(bn_to_field( + &((encode_init_memory_table_address::( + (curr.entry.ltype as u64).into(), + curr.entry.offset.into(), + )) * MEMORY_ADDRESS_OFFSET + + (encode_init_memory_table_entry::( + (curr.entry.ltype as u64).into(), + curr.entry.offset.into(), + (curr.entry.is_mutable as u64).into(), + curr.entry.eid.into(), + curr.entry.value.into(), + ))), + )) + } else { + None + }, + }); + + if let Some(next_entry) = next { + if !next_entry.entry.is_same_location(&curr.entry) { + current_address_init_encode = None; + } + } + + if is_finalized_writing_entry(curr, next) { + _rest_memory_finalize_ops -= 1; + } + + if !curr.entry.atype.is_init() { + rest_mops -= 1; + } + } + + status + }; + + mtable.0.par_iter().enumerate().for_each(|(index, entry)| { + let mut ctx = Context::new(region); + + ctx.step(MEMORY_TABLE_ENTRY_ROWS as usize * index); + + assign_bit!(&mut ctx, enabled_cell); + + match entry.entry.ltype { + LocationType::Stack => assign_bit!(&mut ctx, is_stack_cell), + LocationType::Heap => assign_bit!(&mut ctx, is_heap_cell), + LocationType::Global => assign_bit!(&mut ctx, is_global_cell), + }; + + assign_bit_if!(&mut ctx, entry.entry.is_mutable, is_mutable); + + match entry.entry.vtype { + VarType::I32 => assign_bit!(&mut ctx, is_i32_cell), + VarType::I64 => assign_bit!(&mut ctx, is_i64_cell), + }; + + assign_bit_if!(&mut ctx, entry.entry.atype.is_init(), is_init_cell); + + assign_u32_state!(&mut ctx, start_eid_cell, entry.entry.eid); + assign_u32_state!(&mut ctx, end_eid_cell, entry.end_eid); + assign_u32_state!(&mut ctx, eid_diff_cell, entry.end_eid - entry.entry.eid - 1); + assign_advice!(&mut ctx, init_encode_cell, status[index].init_encode); + assign_advice!(&mut ctx, rest_mops_cell, F::from(status[index].rest_mops)); + assign_advice!(&mut ctx, offset_cell, entry.entry.offset); + assign_advice!(&mut ctx, value, entry.entry.value); + + let offset_diff = F::from(status[index].offset_diff as u64); + let offset_diff_inv = offset_diff.invert().unwrap_or(F::zero()); + let offset_diff_inv_helper = offset_diff * offset_diff_inv; + assign_bit_if!( + &mut ctx, + status[index].is_next_same_ltype_cell, + is_next_same_ltype_cell + ); + assign_bit_if!( + &mut ctx, + status[index].is_next_same_offset_cell, + is_next_same_offset_cell + ); + assign_advice!(&mut ctx, offset_diff_cell, status[index].offset_diff); + assign_advice!(&mut ctx, offset_diff_inv_cell, offset_diff_inv); + assign_advice!( + &mut ctx, + offset_diff_inv_helper_cell, + offset_diff_inv_helper + ); + + #[cfg(feature = "continuation")] + { + assign_advice!( + &mut ctx, + rest_memory_finalize_ops_cell, + F::from(status[index]._rest_memory_finalize_ops as u64) + ); + + assign_advice!( + &mut ctx, + address_encode_cell, + bn_to_field(&encode_init_memory_table_address( + (entry.entry.ltype as u64).into(), + entry.entry.offset.into() + )) + ); + + if let Some(post_init_encode) = status[index]._post_init_encode_cell { + assign_advice!(&mut ctx, post_init_encode_cell, post_init_encode); + } + } + + assign_advice!( + &mut ctx, + encode_cell, + bn_to_field(&encode_memory_table_entry( + entry.entry.offset.into(), + (entry.entry.ltype as u64).into(), + if VarType::I32 == entry.entry.vtype { + 1u64.into() + } else { + 0u64.into() + } + )) + ); + }); + + Ok(()) + } + *) + Definition assign_entries (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; region; mtable; init_rest_mops; _rest_memory_finalize_ops ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let region := M.alloc (| region |) in + let mtable := M.alloc (| mtable |) in + let init_rest_mops := M.alloc (| init_rest_mops |) in + let _rest_memory_finalize_ops := M.alloc (| _rest_memory_finalize_ops |) in + M.read (| + let status := + M.copy (| + let status := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::assign::assign_entries::Status") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "with_capacity", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| mtable |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable", + 0 + |) + ] + |) + ] + |) + |) in + let rest_mops := M.copy (| init_rest_mops |) in + let _rest_memory_finalize_ops := M.copy (| _rest_memory_finalize_ops |) in + let current_address_init_encode := + M.alloc (| Value.StructTuple "core::option::Option::None" [] |) in + let iter := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ], + [], + "peekable", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| mtable |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable", + 0 + |) + ] + |) + ] + |) + ] + |) + |) in + let is_finalized_writing_entry := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let entry := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let next_entry := M.copy (| γ |) in + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::AccessType", + [ Ty.path "specs::mtable::AccessType" ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "atype" + |); + M.alloc (| + Value.StructTuple + "specs::mtable::AccessType::Write" + [] + |) + ] + |), + ltac:(M.monadic + (LogicalOp.or (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ] + ], + "is_none", + [] + |), + [ next_entry ] + |), + ltac:(M.monadic + (UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::mtable::MemoryTableEntry", + "is_same_location", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ] + ], + "as_ref", + [] + |), + [ next_entry ] + |) + ] + |) + |) + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |); + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |) + ] + |)))) + |))) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let _ := + M.loop (| + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::peekable::Peekable") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let curr := M.copy (| γ0_0 |) in + let next := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::iter::adapters::peekable::Peekable") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ], + "peek", + [] + |), + [ iter ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::mtable::AccessType", + "is_init", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| curr |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "atype" + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.write (| + current_address_init_encode, + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_function (| + "specs::encode::init_memory_table::encode_init_memory_table_entry", + [ + Ty.path + "num_bigint::biguint::BigUint" + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| curr |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "ltype" + |) + |)) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u32", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| curr |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "offset" + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| curr |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "is_mutable" + |) + |)) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u32", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| curr |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "eid" + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| curr |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "value" + |) + |) + ] + |) + ] + |) + |) + ] + |) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.match_operator (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := next in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let next := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::LocationType", + [ + Ty.path + "specs::mtable::LocationType" + ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| curr |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "ltype" + |); + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| M.read (| next |) |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "ltype" + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let offset_diff := + M.alloc (| + BinOp.Panic.sub (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| M.read (| next |) |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "offset" + |) + |), + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| curr |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "offset" + |) + |) + |) + |) in + M.alloc (| + Value.Tuple + [ + Value.Bool true; + BinOp.Pure.eq + (M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| curr |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "offset" + |) + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| M.read (| next |) |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "offset" + |) + |)); + M.read (| offset_diff |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple + [ + Value.Bool false; + Value.Bool false; + Value.Integer 0 + ] + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple + [ + Value.Bool false; + Value.Bool false; + Value.Integer 0 + ] + |))) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_2 := M.SubPointer.get_tuple_field (| γ, 2 |) in + let is_next_same_ltype_cell := M.copy (| γ0_0 |) in + let is_next_same_offset_cell := M.copy (| γ0_1 |) in + let offset_diff := M.copy (| γ0_2 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::assign::assign_entries::Status") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + status; + Value.StructRecord + "delphinus_zkwasm::circuits::mtable::assign::assign_entries::Status" + [ + ("rest_mops", M.read (| rest_mops |)); + ("init_encode", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ F ], + "unwrap_or", + [] + |), + [ + M.read (| + current_address_init_encode + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + |)); + ("is_next_same_ltype_cell", + M.read (| is_next_same_ltype_cell |)); + ("is_next_same_offset_cell", + M.read (| is_next_same_offset_cell |)); + ("offset_diff", M.read (| offset_diff |)); + ("_rest_memory_finalize_ops", + M.read (| _rest_memory_finalize_ops |)); + ("_post_init_encode_cell", + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ]; + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ] + ] + ] + ] + (Ty.path "bool"), + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ]; + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ] + ] + ] + ], + "call", + [] + |), + [ + is_finalized_writing_entry; + Value.Tuple + [ + M.read (| curr |); + M.read (| next |) + ] + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "u32" + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_function (| + "specs::encode::init_memory_table::encode_init_memory_table_address", + [ + Ty.path + "num_bigint::biguint::BigUint" + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "u64", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + curr + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "ltype" + |) + |)) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "u32", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + curr + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "offset" + |) + |) + ] + |) + ] + |); + M.read (| + M.get_constant (| + "specs::encode::init_memory_table::MEMORY_ADDRESS_OFFSET" + |) + |) + ] + |); + M.call_closure (| + M.get_function (| + "specs::encode::init_memory_table::encode_init_memory_table_entry", + [ + Ty.path + "num_bigint::biguint::BigUint" + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "u64", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + curr + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "ltype" + |) + |)) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "u32", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + curr + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "offset" + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "u64", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + curr + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "is_mutable" + |) + |)) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "u32", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + curr + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "eid" + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "u64", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + curr + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "value" + |) + |) + ] + |) + ] + |) + ] + |) + |) + ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))) + ] + |) + |)) + ] + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := next in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let next_entry := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::mtable::MemoryTableEntry", + "is_same_location", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + M.read (| next_entry |) + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |); + M.SubPointer.get_struct_record_field (| + M.read (| curr |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.write (| + current_address_init_encode, + Value.StructTuple + "core::option::Option::None" + [] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ]; + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ] + ] + ] + ] + (Ty.path "bool"), + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ]; + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ] + ] + ] + ], + "call", + [] + |), + [ + is_finalized_writing_entry; + Value.Tuple + [ + M.read (| curr |); + M.read (| next |) + ] + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + let β := _rest_memory_finalize_ops in + M.write (| + β, + BinOp.Panic.sub (| + Integer.U32, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.path "specs::mtable::AccessType", + "is_init", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| curr |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "atype" + |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + let β := rest_mops in + M.write (| + β, + BinOp.Panic.sub (| + Integer.U64, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + let _ := + M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |) in + M.alloc (| Value.Tuple [] |) + |) + |) + |))) + ] + |))) + |) in + status + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "rayon::iter::ParallelIterator", + Ty.apply + (Ty.path "rayon::iter::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IndexedParallelIterator", + Ty.apply + (Ty.path "rayon::slice::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "rayon::iter::IntoParallelRefIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "par_iter", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| mtable |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable", + 0 + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let index := M.copy (| γ0_0 |) in + let entry := M.copy (| γ0_1 |) in + M.read (| + let ctx := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "new", + [] + |), + [ M.read (| region |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "step", + [] + |), + [ + ctx; + BinOp.Panic.mul (| + Integer.Usize, + M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::MEMORY_TABLE_ENTRY_ROWS" + |) + |)), + M.read (| index |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "enabled_cell" + |); + ctx; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "ltype" + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "is_stack_cell" + |); + ctx; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "is_heap_cell" + |); + ctx; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "is_global_cell" + |); + ctx; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "is_mutable" + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "is_mutable" + |); + ctx; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "vtype" + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "is_i32_cell" + |); + ctx; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "is_i64_cell" + |); + ctx; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::mtable::AccessType", + "is_init", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "atype" + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "is_init_cell" + |); + ctx; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "start_eid_cell" + |); + ctx; + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "eid" + |) + |)) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "end_eid_cell" + |); + ctx; + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "end_eid" + |) + |)) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "eid_diff_cell" + |); + ctx; + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.sub (| + Integer.U32, + BinOp.Panic.sub (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "end_eid" + |) + |), + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "eid" + |) + |) + |), + Value.Integer 1 + |)) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "init_encode_cell" + |); + ctx; + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::assign::assign_entries::Status") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ status; M.read (| index |) ] + |), + "delphinus_zkwasm::circuits::mtable::assign::assign_entries::Status", + "init_encode" + |) + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "rest_mops_cell" + |); + ctx; + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::assign::assign_entries::Status") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ status; M.read (| index |) ] + |), + "delphinus_zkwasm::circuits::mtable::assign::assign_entries::Status", + "rest_mops" + |) + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "offset_cell" + |); + ctx; + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "offset" + |) + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "value" + |); + ctx; + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "value" + |) + |) + ] + |) + ] + |) + |) in + let offset_diff := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::assign::assign_entries::Status") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ status; M.read (| index |) ] + |), + "delphinus_zkwasm::circuits::mtable::assign::assign_entries::Status", + "offset_diff" + |) + |)) + ] + |) + |) in + let offset_diff_inv := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "subtle::CtOption") [ F ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "invert", + [] + |), + [ offset_diff ] + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + |) + |) in + let offset_diff_inv_helper := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + F, + [ F ], + "mul", + [] + |), + [ + M.read (| offset_diff |); + M.read (| offset_diff_inv |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::assign::assign_entries::Status") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ status; M.read (| index |) ] + |), + "delphinus_zkwasm::circuits::mtable::assign::assign_entries::Status", + "is_next_same_ltype_cell" + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "is_next_same_ltype_cell" + |); + ctx; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::assign::assign_entries::Status") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ status; M.read (| index |) ] + |), + "delphinus_zkwasm::circuits::mtable::assign::assign_entries::Status", + "is_next_same_offset_cell" + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "is_next_same_offset_cell" + |); + ctx; + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "offset_diff_cell" + |); + ctx; + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::assign::assign_entries::Status") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ status; M.read (| index |) ] + |), + "delphinus_zkwasm::circuits::mtable::assign::assign_entries::Status", + "offset_diff" + |) + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "offset_diff_inv_cell" + |); + ctx; + M.read (| offset_diff_inv |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "offset_diff_inv_helper_cell" + |); + ctx; + M.read (| offset_diff_inv_helper |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "config" + |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "encode_cell" + |); + ctx; + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_function (| + "specs::encode::memory_table::encode_memory_table_entry", + [ + Ty.path + "num_bigint::biguint::BigUint" + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u32", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "offset" + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "ltype" + |) + |)) + ] + |); + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "specs::mtable::VarType", + [ + Ty.path + "specs::mtable::VarType" + ], + "eq", + [] + |), + [ + M.alloc (| + Value.StructTuple + "specs::mtable::VarType::I32" + [] + |); + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + entry + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "vtype" + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ Value.Integer 1 ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ + Ty.path + "num_bigint::biguint::BigUint" + ], + "into", + [] + |), + [ Value.Integer 0 ] + |) + |))) + ] + |) + |) + ] + |) + |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign_entries : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign_entries" (assign_entries F). + + (* + pub(crate) fn assign( + &self, + layouter: impl Layouter, + mtable: &MemoryWritingTable, + ) -> Result<(AssignedCell, Option>), Error> { + layouter.assign_region( + || "mtable", + |region| { + let mut ctx = Context::new(region); + + debug!("size of memory writing table: {}", mtable.0.len()); + assert!( + mtable.0.len() * (MEMORY_TABLE_ENTRY_ROWS as usize) + < self.maximal_available_rows + ); + + let rest_mops = mtable + .0 + .iter() + .fold(0, |acc, entry| acc + (!entry.entry.atype.is_init() as u64)); + + self.assign_fixed(&mut ctx)?; + ctx.reset(); + + let (rest_memory_finalize_ops, _) = mtable.count_rest_memory_finalize_ops(); + + #[cfg(feature = "continuation")] + let rest_memory_finalize_ops_cell = + self.constrain_rest_memory_finalize_ops(&mut ctx, rest_memory_finalize_ops)?; + + let rest_mops_cell = self.constrain_rest_mops_permutation(&mut ctx, rest_mops)?; + + self.assign_entries(region, &mtable, rest_mops, rest_memory_finalize_ops)?; + + cfg_if::cfg_if! { + if #[cfg(feature="continuation")] { + Ok((rest_mops_cell, Some(rest_memory_finalize_ops_cell))) + } else { + // Useless rest_memory_finalize_ops if continuation is disabled + Ok((rest_mops_cell, None,)) + } + } + }, + ) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Layouter_F_ ], [ self; layouter; mtable ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let layouter := M.alloc (| layouter |) in + let mtable := M.alloc (| mtable |) in + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::Layouter", + impl_Layouter_F_, + [ F ], + "assign_region", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ] ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] + ] + ]; + Ty.path "halo2_proofs::plonk::error::Error" + ]); + Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] ] + ]; + Ty.function [ Ty.tuple [] ] (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + layouter; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ fun γ => ltac:(M.monadic (M.read (| Value.String "mtable" |))) ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let region := M.copy (| γ |) in + M.read (| + let ctx := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "new", + [] + |), + [ M.read (| region |) ] + |) + |) in + let _ := + let lvl := + M.alloc (| Value.StructTuple "log::Level::Debug" [] |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ + lvl; + M.get_constant (| + "log::STATIC_MAX_LEVEL" + |) + ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ + lvl; + M.alloc (| + M.call_closure (| + M.get_function (| + "log::max_level", + [] + |), + [] + |) + |) + ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "log::__private_api::log", + [ Ty.tuple [] ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "size of memory writing table: " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry"; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| mtable |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable", + 0 + |) + ] + |) + |) + ] + |) + ] + |)) + ] + |); + M.read (| lvl |); + M.alloc (| + Value.Tuple + [ + M.read (| + Value.String + "delphinus_zkwasm::circuits::mtable::assign" + |); + M.read (| + Value.String + "delphinus_zkwasm::circuits::mtable::assign" + |); + M.read (| + Value.String + "crates/zkwasm/src/circuits/mtable/assign.rs" + |) + ] + |); + Value.Integer 341; + Value.Tuple [] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.lt + (BinOp.Panic.mul (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| mtable |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable", + 0 + |) + ] + |), + M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::MEMORY_TABLE_ENTRY_ROWS" + |) + |)) + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableChip", + "maximal_available_rows" + |) + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic", + [] + |), + [ + M.read (| + Value.String + "assertion failed: mtable.0.len() * (MEMORY_TABLE_ENTRY_ROWS as usize) < + self.maximal_available_rows" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let rest_mops := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ], + [], + "fold", + [ + Ty.path "u64"; + Ty.function + [ + Ty.tuple + [ + Ty.path "u64"; + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ] + ] + (Ty.path "u64") + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| mtable |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable", + 0 + |) + ] + |) + ] + |); + Value.Integer 0; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let acc := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let entry := M.copy (| γ |) in + BinOp.Panic.add (| + Integer.U64, + M.read (| acc |), + M.rust_cast + (UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::mtable::AccessType", + "is_init", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + entry + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "atype" + |) + ] + |))) + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::MemoryTableChip") + [ F ], + "assign_fixed", + [] + |), + [ M.read (| self |); ctx ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::utils::Context") + [ F ], + "reset", + [] + |), + [ ctx ] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable", + "count_rest_memory_finalize_ops", + [] + |), + [ M.read (| mtable |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let rest_memory_finalize_ops := M.copy (| γ0_0 |) in + let rest_mops_cell := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::MemoryTableChip") + [ F ], + "constrain_rest_mops_permutation", + [] + |), + [ + M.read (| self |); + ctx; + M.read (| rest_mops |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::MemoryTableChip") + [ F ], + "assign_entries", + [] + |), + [ + M.read (| self |); + M.read (| region |); + M.read (| mtable |); + M.read (| rest_mops |); + M.read (| rest_memory_finalize_ops |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.Tuple + [ + M.read (| rest_mops_cell |); + Value.StructTuple + "core::option::Option::None" + [] + ] + ] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_circuits_mtable_MemoryTableChip_F. + End assign. + End mtable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/mtable/mod.v b/CoqOfRust/zkWasm/circuits/mtable/mod.v new file mode 100644 index 000000000..9a806ef37 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/mtable/mod.v @@ -0,0 +1,9098 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module mtable. + Definition value_MEMORY_TABLE_ENTRY_ROWS : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 4 |))). + + Axiom AllocatedU32StateCell : + forall (F : Ty.t), + (Ty.apply (Ty.path "delphinus_zkwasm::circuits::mtable::AllocatedU32StateCell") [ F ]) = + (Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") [ F ]). + + (* StructRecord + { + name := "MemoryTableConfig"; + ty_params := [ "F" ]; + fields := + [ + ("entry_sel", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]); + ("enabled_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_stack_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_heap_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_global_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_next_same_ltype_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_next_same_offset_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_mutable", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_i32_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_i64_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_init_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("start_eid_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("end_eid_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("eid_diff_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("rest_mops_cell", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ]); + ("offset_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") [ F ]); + ("offset_diff_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") [ F ]); + ("offset_diff_inv_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]); + ("offset_diff_inv_helper_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]); + ("encode_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]); + ("init_encode_cell", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") [ F ]); + ("value", Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_mtable_MemoryTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::mtable::MemoryTableConfig") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig" + [ + ("entry_sel", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "entry_sel" + |) + ] + |)); + ("enabled_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "enabled_cell" + |) + ] + |)); + ("is_stack_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "is_stack_cell" + |) + ] + |)); + ("is_heap_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "is_heap_cell" + |) + ] + |)); + ("is_global_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "is_global_cell" + |) + ] + |)); + ("is_next_same_ltype_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "is_next_same_ltype_cell" + |) + ] + |)); + ("is_next_same_offset_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "is_next_same_offset_cell" + |) + ] + |)); + ("is_mutable", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "is_mutable" + |) + ] + |)); + ("is_i32_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "is_i32_cell" + |) + ] + |)); + ("is_i64_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "is_i64_cell" + |) + ] + |)); + ("is_init_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "is_init_cell" + |) + ] + |)); + ("start_eid_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "start_eid_cell" + |) + ] + |)); + ("end_eid_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "end_eid_cell" + |) + ] + |)); + ("eid_diff_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "eid_diff_cell" + |) + ] + |)); + ("rest_mops_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "rest_mops_cell" + |) + ] + |)); + ("offset_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "offset_cell" + |) + ] + |)); + ("offset_diff_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "offset_diff_cell" + |) + ] + |)); + ("offset_diff_inv_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "offset_diff_inv_cell" + |) + ] + |)); + ("offset_diff_inv_helper_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "offset_diff_inv_helper_cell" + |) + ] + |)); + ("encode_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "encode_cell" + |) + ] + |)); + ("init_encode_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "init_encode_cell" + |) + ] + |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "value" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_mtable_MemoryTableConfig_F. + + Module Impl_delphinus_zkwasm_circuits_mtable_MemoryTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::mtable::MemoryTableConfig") [ F ]. + + (* + pub(crate) fn configure( + meta: &mut ConstraintSystem, + k: u32, + cols: &mut (impl Iterator> + Clone), + rtable: &RangeTableConfig, + image_table: &ImageTableConfig, + ) -> Self { + let entry_sel = meta.fixed_column(); + + let mut allocator = MemoryTableCellAllocator::new(meta, k, entry_sel, rtable, cols); + allocator.enable_equality(meta, &MemoryTableCellType::CommonRange); + + let enabled_cell = allocator.alloc_bit_cell(); + let is_stack_cell = allocator.alloc_bit_cell(); + let is_heap_cell = allocator.alloc_bit_cell(); + let is_global_cell = allocator.alloc_bit_cell(); + let is_next_same_ltype_cell = allocator.alloc_bit_cell(); + let is_next_same_offset_cell = allocator.alloc_bit_cell(); + let is_mutable = allocator.alloc_bit_cell(); + + let is_i32_cell = allocator.alloc_bit_cell(); + let is_i64_cell = allocator.alloc_bit_cell(); + let is_init_cell = allocator.alloc_bit_cell(); + + let start_eid_cell = allocator.alloc_u32_state_cell(); + let end_eid_cell = allocator.alloc_u32_state_cell(); + let eid_diff_cell = allocator.alloc_u32_state_cell(); + let rest_mops_cell = allocator.alloc_common_range_cell(); + + let offset_cell = allocator.alloc_u32_cell(); + + let offset_diff_cell = allocator.alloc_u32_cell(); + let offset_diff_inv_cell = allocator.alloc_unlimited_cell(); + let offset_diff_inv_helper_cell = allocator.alloc_unlimited_cell(); + let encode_cell = allocator.alloc_unlimited_cell(); + let init_encode_cell = allocator.alloc_unlimited_cell(); + + #[cfg(feature = "continuation")] + let post_init_encode_cell = allocator.alloc_unlimited_cell(); + #[cfg(feature = "continuation")] + let address_encode_cell = allocator.alloc_unlimited_cell(); + + #[cfg(feature = "continuation")] + let rest_memory_finalize_ops_cell = { + let cell = allocator.alloc_unlimited_cell(); + // FIXME: try to avoid this? + meta.enable_equality(cell.cell.col); + cell + }; + + let value = allocator.alloc_u64_cell(); + + allocator.assert_no_free_cells(); + + macro_rules! location { + ($meta:expr) => { + is_stack_cell.curr_expr($meta) * constant_from!(LocationType::Stack as u64) + + is_global_cell.curr_expr($meta) * constant_from!(LocationType::Global as u64) + + is_heap_cell.curr_expr($meta) * constant_from!(LocationType::Heap) + }; + } + meta.create_gate("mc1. enable seq", |meta| { + vec![ + (enabled_cell.curr_expr(meta) - constant_from!(1)) + * (enabled_cell.next_expr(meta)) + * fixed_curr!(meta, entry_sel), + ] + }); + + meta.create_gate("mc2. ltype unique", |meta| { + vec![ + is_global_cell.curr_expr(meta) + + is_heap_cell.curr_expr(meta) + + is_stack_cell.curr_expr(meta) + - enabled_cell.curr_expr(meta), + ] + .into_iter() + .map(|x| x * fixed_curr!(meta, entry_sel)) + .collect::>() + }); + + meta.create_gate("mc3. ltype group", |meta| { + vec![ + (is_stack_cell.curr_expr(meta) - constant_from!(1)) * is_stack_cell.next_expr(meta), + (is_heap_cell.curr_expr(meta) - constant_from!(1)) + * is_heap_cell.next_expr(meta) + * (is_stack_cell.curr_expr(meta) - constant_from!(1)), + ] + .into_iter() + .map(|x| x * fixed_curr!(meta, entry_sel)) + .collect::>() + }); + + meta.create_gate("mc4a. is_next_same_ltype", |meta| { + vec![ + is_next_same_ltype_cell.curr_expr(meta) + - is_stack_cell.curr_expr(meta) * is_stack_cell.next_expr(meta) + - is_global_cell.curr_expr(meta) * is_global_cell.next_expr(meta) + - is_heap_cell.curr_expr(meta) * is_heap_cell.next_expr(meta), + ] + .into_iter() + .map(|x| x * fixed_curr!(meta, entry_sel)) + .collect::>() + }); + + meta.create_gate("mc4b. is_next_same_offset", |meta| { + vec![ + is_next_same_offset_cell.curr_expr(meta) + * (is_next_same_ltype_cell.curr_expr(meta) - constant_from!(1)), + is_next_same_offset_cell.curr_expr(meta) * offset_diff_cell.curr_expr(meta), + offset_diff_cell.curr_expr(meta) * offset_diff_inv_cell.curr_expr(meta) + - offset_diff_inv_helper_cell.curr_expr(meta), + (is_next_same_offset_cell.curr_expr(meta) - constant_from!(1)) + * is_next_same_ltype_cell.curr_expr(meta) + * (offset_diff_inv_helper_cell.curr_expr(meta) - constant_from!(1)), + ] + .into_iter() + .map(|x| x * fixed_curr!(meta, entry_sel)) + .collect::>() + }); + + meta.create_gate("mc5. offset sort", |meta| { + vec![ + (offset_cell.curr_expr(meta) + offset_diff_cell.curr_expr(meta) + - offset_cell.next_expr(meta)) + * is_next_same_ltype_cell.curr_expr(meta), + ] + .into_iter() + .map(|x| x * fixed_curr!(meta, entry_sel)) + .collect::>() + }); + + meta.create_gate("mc6. eid sort", |meta| { + vec![ + (start_eid_cell.curr_expr(meta) + + eid_diff_cell.curr_expr(meta) + + constant_from!(1) + - end_eid_cell.curr_expr(meta)), + (end_eid_cell.curr_expr(meta) - start_eid_cell.next_expr(meta)) + * is_next_same_offset_cell.curr_expr(meta), + ] + .into_iter() + .map(|x| x * enabled_cell.curr_expr(meta) * fixed_curr!(meta, entry_sel)) + .collect::>() + }); + + meta.create_gate( + "mc7a. global must has init (because of mutability check).", + |meta| { + vec![ + (is_next_same_offset_cell.expr(meta) - constant_from!(1)) + * is_global_cell.next_expr(meta) + * (is_init_cell.next_expr(meta) - constant_from!(1)), + ] + .into_iter() + .map(|x| x * fixed_curr!(meta, entry_sel)) + .collect::>() + }, + ); + + meta.create_gate("mc7b. init encode.", |meta| { + vec![ + (encode_init_memory_table_entry( + location!(meta), + offset_cell.curr_expr(meta), + is_mutable.curr_expr(meta), + start_eid_cell.curr_expr(meta), + value.u64_cell.curr_expr(meta), + ) - init_encode_cell.curr_expr(meta)) + * is_init_cell.curr_expr(meta), + ] + .into_iter() + .map(|x| x * fixed_curr!(meta, entry_sel)) + .collect::>() + }); + + image_table.init_memory_lookup(meta, "mc7c. imtable init", |meta| { + cfg_if::cfg_if! { + if #[cfg(feature = "continuation")] { + ( + address_encode_cell.curr_expr(meta) * fixed_curr!(meta, entry_sel), + init_encode_cell.curr_expr(meta) * fixed_curr!(meta, entry_sel), + ) + } else { + init_encode_cell.curr_expr(meta) * fixed_curr!(meta, entry_sel) + } + } + }); + + meta.create_gate("mc8. vtype", |meta| { + vec![ + is_i32_cell.curr_expr(meta) + is_i64_cell.curr_expr(meta) + - enabled_cell.curr_expr(meta), + is_heap_cell.curr_expr(meta) * is_i32_cell.curr_expr(meta), + is_i32_cell.curr_expr(meta) + * (value.u16_cells_le[2].curr_expr(meta) + + value.u16_cells_le[3].curr_expr(meta)), + is_global_cell.curr_expr(meta) + * is_next_same_offset_cell.curr_expr(meta) + * (is_i32_cell.curr_expr(meta) - is_i32_cell.next_expr(meta)), + ] + .into_iter() + .map(|x| x * fixed_curr!(meta, entry_sel)) + .collect::>() + }); + + /* mc9. value is in allocator */ + + meta.create_gate("mc10b. rest_mops", |meta| { + vec![ + is_init_cell.curr_expr(meta) + * (rest_mops_cell.next_expr(meta) - rest_mops_cell.curr_expr(meta)), + (is_init_cell.curr_expr(meta) - constant_from!(1)) + * (rest_mops_cell.next_expr(meta) + enabled_cell.curr_expr(meta) + - rest_mops_cell.curr_expr(meta)), + ] + .into_iter() + .map(|x| x * fixed_curr!(meta, entry_sel)) + .collect::>() + }); + + meta.create_gate("mc10c. rest_mops decrease to zero", |meta| { + vec![ + (enabled_cell.curr_expr(meta) - constant_from!(1)) * rest_mops_cell.curr_expr(meta), + ] + .into_iter() + .map(|x| x * fixed_curr!(meta, entry_sel)) + .collect::>() + }); + + meta.create_gate("mc11. mutable", |meta| { + vec![ + (is_init_cell.curr_expr(meta) - constant_from!(1)) + * (is_mutable.curr_expr(meta) - constant_from!(1)), + (is_mutable.curr_expr(meta) - is_mutable.next_expr(meta)) + * is_next_same_offset_cell.curr_expr(meta), + ] + .into_iter() + .map(|x| x * enabled_cell.curr_expr(meta) * fixed_curr!(meta, entry_sel)) + .collect::>() + }); + + meta.create_gate("mc12. lookup encode", |meta| { + vec![ + (constant_from!(1) - enabled_cell.curr_expr(meta)) * encode_cell.curr_expr(meta), + encode_memory_table_entry( + offset_cell.curr_expr(meta), + location!(meta), + is_i32_cell.curr_expr(meta), + ) - encode_cell.curr_expr(meta), + ] + .into_iter() + .map(|x| x * fixed_curr!(meta, entry_sel)) + .collect::>() + }); + + #[cfg(feature = "continuation")] + { + use specs::encode::init_memory_table::encode_init_memory_table_address; + use specs::encode::init_memory_table::MEMORY_ADDRESS_OFFSET; + + meta.create_gate("mc13. post init memory entry", |meta| { + let is_writing = constant_from!(1) - is_init_cell.curr_expr(meta); + let next_entry_at_different_position = + constant_from!(1) - is_next_same_offset_cell.curr_expr(meta); + + let is_memory_finalized_position_bit = + is_writing * next_entry_at_different_position; + + vec![ + // rest_memory_finalize_ops_cell decreases. + // `* enabled_cell`: If disabled, rest_memory_finalize_ops_cell should keep the same, + // The termination rest_memory_finalize_ops_cell is constant 0 at the last selected(sel=1) step. + rest_memory_finalize_ops_cell.curr_expr(meta) + - rest_memory_finalize_ops_cell.next_expr(meta) + - is_memory_finalized_position_bit.clone() * enabled_cell.curr_expr(meta), + // encode address_encode_cell. + (encode_init_memory_table_address( + location!(meta), + offset_cell.curr_expr(meta), + ) - address_encode_cell.curr_expr(meta)), + // post_init_encode_cell assigned iff at memory finalized position. + post_init_encode_cell.curr_expr(meta) + * (constant_from!(1) - is_memory_finalized_position_bit.clone()), + // encode post_init_encode_cell. + (post_init_encode_cell.curr_expr(meta) + - address_encode_cell.curr_expr(meta) + * constant_from!(MEMORY_ADDRESS_OFFSET) + - encode_init_memory_table_entry( + location!(meta), + offset_cell.curr_expr(meta), + is_mutable.curr_expr(meta), + start_eid_cell.curr_expr(meta), + value.u64_cell.curr_expr(meta), + )) + * is_memory_finalized_position_bit, + ] + .into_iter() + .map(|x| x * fixed_curr!(meta, entry_sel)) + .collect::>() + }); + } + + Self { + entry_sel, + enabled_cell, + is_stack_cell, + is_heap_cell, + is_global_cell, + is_next_same_ltype_cell, + is_next_same_offset_cell, + is_mutable, + is_i32_cell, + is_i64_cell, + is_init_cell, + start_eid_cell, + end_eid_cell, + eid_diff_cell, + rest_mops_cell, + offset_cell, + offset_diff_cell, + offset_diff_inv_cell, + offset_diff_inv_helper_cell, + value, + init_encode_cell, + encode_cell, + + #[cfg(feature = "continuation")] + post_init_encode_cell, + #[cfg(feature = "continuation")] + address_encode_cell, + #[cfg(feature = "continuation")] + rest_memory_finalize_ops_cell, + } + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Iterator_Item___Column_Advice____plus__Clone ], + [ meta; k; cols; rtable; image_table ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + let k := M.alloc (| k |) in + let cols := M.alloc (| cols |) in + let rtable := M.alloc (| rtable |) in + let image_table := M.alloc (| image_table |) in + M.read (| + let entry_sel := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "fixed_column", + [] + |), + [ M.read (| meta |) ] + |) + |) in + let allocator := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "new", + [ impl_Iterator_Item___Column_Advice____plus__Clone ] + |), + [ + M.read (| meta |); + M.read (| k |); + M.read (| entry_sel |); + M.read (| rtable |); + M.read (| cols |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "enable_equality", + [] + |), + [ + allocator; + M.read (| meta |); + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellType::CommonRange" + [] + |) + ] + |) + |) in + let enabled_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ allocator ] + |) + |) in + let is_stack_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ allocator ] + |) + |) in + let is_heap_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ allocator ] + |) + |) in + let is_global_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ allocator ] + |) + |) in + let is_next_same_ltype_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ allocator ] + |) + |) in + let is_next_same_offset_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ allocator ] + |) + |) in + let is_mutable := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ allocator ] + |) + |) in + let is_i32_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ allocator ] + |) + |) in + let is_i64_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ allocator ] + |) + |) in + let is_init_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ allocator ] + |) + |) in + let start_eid_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_u32_state_cell", + [] + |), + [ allocator ] + |) + |) in + let end_eid_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_u32_state_cell", + [] + |), + [ allocator ] + |) + |) in + let eid_diff_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_u32_state_cell", + [] + |), + [ allocator ] + |) + |) in + let rest_mops_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_common_range_cell", + [] + |), + [ allocator ] + |) + |) in + let offset_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_u32_cell", + [] + |), + [ allocator ] + |) + |) in + let offset_diff_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_u32_cell", + [] + |), + [ allocator ] + |) + |) in + let offset_diff_inv_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ allocator ] + |) + |) in + let offset_diff_inv_helper_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ allocator ] + |) + |) in + let encode_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ allocator ] + |) + |) in + let init_encode_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ allocator ] + |) + |) in + let value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ allocator ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellAllocator") + [ F ], + "assert_no_free_cells", + [] + |), + [ allocator ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "mc1. enable seq" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + enabled_cell; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ enabled_cell; M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| entry_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "mc2. ltype unique" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_global_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_heap_cell; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_stack_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + enabled_cell; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| x |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| entry_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "mc3. ltype group" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_stack_cell; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + is_stack_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_heap_cell; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + is_heap_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_stack_cell; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| x |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| entry_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "mc4a. is_next_same_ltype" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_next_same_ltype_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_stack_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + is_stack_cell; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_global_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + is_global_cell; + M.read (| + meta + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_heap_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + is_heap_cell; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| x |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| entry_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "mc4b. is_next_same_offset" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_next_same_offset_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_next_same_ltype_cell; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_next_same_offset_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "curr_expr", + [] + |), + [ + offset_diff_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "curr_expr", + [] + |), + [ + offset_diff_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + offset_diff_inv_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + offset_diff_inv_helper_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_next_same_offset_cell; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_next_same_ltype_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + offset_diff_inv_helper_cell; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| x |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| entry_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "mc5. offset sort" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "curr_expr", + [] + |), + [ + offset_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "curr_expr", + [] + |), + [ + offset_diff_cell; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + offset_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_next_same_ltype_cell; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| x |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| entry_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "mc6. eid sort" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + start_eid_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + eid_diff_cell; + M.read (| + meta + |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + end_eid_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + end_eid_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + start_eid_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_next_same_offset_cell; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| x |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + enabled_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| entry_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| + Value.String "mc7a. global must has init (because of mutability check)." + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_next_same_offset_cell; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + is_global_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + is_init_cell; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| x |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| entry_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "mc7b. init encode." |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_function (| + "specs::encode::init_memory_table::encode_init_memory_table_entry", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ + F + ], + [ F + ], + "curr_expr", + [] + |), + [ + is_stack_cell; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer + 0 + |)) + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F + ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ + F + ], + [ F + ], + "curr_expr", + [] + |), + [ + is_global_cell; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Global_discriminant" + |), + Value.Integer + 0 + |)) + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_heap_cell; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Heap_discriminant" + |), + Value.Integer + 0 + |)) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "curr_expr", + [] + |), + [ + offset_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_mutable; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + start_eid_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + init_encode_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_init_cell; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| x |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| entry_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::image_table::ImageTableConfig") + [ F ], + "init_memory_lookup", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]) + ] + |), + [ + M.read (| image_table |); + M.read (| meta |); + M.read (| Value.String "mc7c. imtable init" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ init_encode_cell; M.read (| meta |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| entry_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "mc8. vtype" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_i32_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_i64_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + enabled_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_heap_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_i32_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_i32_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| + Value.Integer 2 + |) + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU16Cell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + M.SubPointer.get_array_field (| + M.SubPointer.get_struct_record_field (| + value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u16_cells_le" + |), + M.alloc (| + Value.Integer 3 + |) + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_global_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_next_same_offset_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_i32_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + is_i32_cell; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| x |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| entry_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "mc10b. rest_mops" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_init_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + rest_mops_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + rest_mops_cell; + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_init_cell; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + rest_mops_cell; + M.read (| + meta + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + enabled_cell; + M.read (| + meta + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + rest_mops_cell; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| x |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| entry_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "mc10c. rest_mops decrease to zero" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + enabled_cell; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + rest_mops_cell; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| x |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| entry_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "mc11. mutable" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_init_cell; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_mutable; + M.read (| meta |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_mutable; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::mtable::allocator::MemoryTableCellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "next_expr", + [] + |), + [ + is_mutable; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_next_same_offset_cell; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| x |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + enabled_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| entry_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "mc12. lookup encode" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + enabled_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + encode_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_function (| + "specs::encode::memory_table::encode_memory_table_entry", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU32Cell") + [ F ], + "curr_expr", + [] + |), + [ + offset_cell; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_stack_cell; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer + 0 + |)) + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_global_cell; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Global_discriminant" + |), + Value.Integer + 0 + |)) + |)) + |) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_heap_cell; + M.read (| + meta + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Heap_discriminant" + |), + Value.Integer + 0 + |)) + ] + |) + ] + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + is_i32_cell; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "curr_expr", + [] + |), + [ + encode_cell; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| x |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| entry_sel |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig" + [ + ("entry_sel", M.read (| entry_sel |)); + ("enabled_cell", M.read (| enabled_cell |)); + ("is_stack_cell", M.read (| is_stack_cell |)); + ("is_heap_cell", M.read (| is_heap_cell |)); + ("is_global_cell", M.read (| is_global_cell |)); + ("is_next_same_ltype_cell", M.read (| is_next_same_ltype_cell |)); + ("is_next_same_offset_cell", M.read (| is_next_same_offset_cell |)); + ("is_mutable", M.read (| is_mutable |)); + ("is_i32_cell", M.read (| is_i32_cell |)); + ("is_i64_cell", M.read (| is_i64_cell |)); + ("is_init_cell", M.read (| is_init_cell |)); + ("start_eid_cell", M.read (| start_eid_cell |)); + ("end_eid_cell", M.read (| end_eid_cell |)); + ("eid_diff_cell", M.read (| eid_diff_cell |)); + ("rest_mops_cell", M.read (| rest_mops_cell |)); + ("offset_cell", M.read (| offset_cell |)); + ("offset_diff_cell", M.read (| offset_diff_cell |)); + ("offset_diff_inv_cell", M.read (| offset_diff_inv_cell |)); + ("offset_diff_inv_helper_cell", M.read (| offset_diff_inv_helper_cell |)); + ("value", M.read (| value |)); + ("init_encode_cell", M.read (| init_encode_cell |)); + ("encode_cell", M.read (| encode_cell |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure" (configure F). + End Impl_delphinus_zkwasm_circuits_mtable_MemoryTableConfig_F. + + Module Impl_delphinus_zkwasm_circuits_traits_ConfigureLookupTable_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_mtable_MemoryTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::mtable::MemoryTableConfig") [ F ]. + + (* + fn configure_in_table( + &self, + meta: &mut ConstraintSystem, + name: &'static str, + expr: impl FnOnce(&mut VirtualCells<'_, F>) -> Vec>, + ) { + meta.lookup_any(name, |meta| { + let mut expr = expr(meta); + expr.reverse(); + vec![ + ( + expr.pop().unwrap(), + self.start_eid_cell.expr(meta) * fixed_curr!(meta, self.entry_sel), + ), + ( + expr.pop().unwrap(), + self.end_eid_cell.expr(meta) * fixed_curr!(meta, self.entry_sel), + ), + ( + expr.pop().unwrap(), + self.encode_cell.expr(meta) * fixed_curr!(meta, self.entry_sel), + ), + ( + expr.pop().unwrap(), + self.value.expr(meta) * fixed_curr!(meta, self.entry_sel), + ), + ] + }); + } + *) + Definition configure_in_table (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_FnOnce__mut_VirtualCells_'___F___arrow_Vec_Expression_F__ ], + [ self; meta; name; expr ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let name := M.alloc (| name |) in + let expr := M.alloc (| expr |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "lookup_any", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| name |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let expr := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow_Vec_Expression_F__, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ M.read (| expr |); Value.Tuple [ M.read (| meta |) ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "reverse", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ expr ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + "pop", + [] + |), + [ expr ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "start_eid_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "entry_sel" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ]; + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + "pop", + [] + |), + [ expr ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "end_eid_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "entry_sel" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ]; + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + "pop", + [] + |), + [ expr ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "encode_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "entry_sel" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ]; + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + "pop", + [] + |), + [ expr ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "value" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::mtable::MemoryTableConfig", + "entry_sel" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ] + ] + |) + ] + |) + |)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::traits::ConfigureLookupTable" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure_in_table", InstanceField.Method (configure_in_table F)) ]. + End Impl_delphinus_zkwasm_circuits_traits_ConfigureLookupTable_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_mtable_MemoryTableConfig_F. + + (* StructRecord + { + name := "MemoryTableChip"; + ty_params := [ "F" ]; + fields := + [ + ("config", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::mtable::MemoryTableConfig") [ F ]); + ("maximal_available_rows", Ty.path "usize") + ]; + } *) + + Module Impl_delphinus_zkwasm_circuits_mtable_MemoryTableChip_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::mtable::MemoryTableChip") [ F ]. + + (* + pub(super) fn new(config: MemoryTableConfig, maximal_available_rows: usize) -> Self { + Self { + config, + maximal_available_rows: maximal_available_rows / MEMORY_TABLE_ENTRY_ROWS as usize + * MEMORY_TABLE_ENTRY_ROWS as usize, + } + } + *) + Definition new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ config; maximal_available_rows ] => + ltac:(M.monadic + (let config := M.alloc (| config |) in + let maximal_available_rows := M.alloc (| maximal_available_rows |) in + Value.StructRecord + "delphinus_zkwasm::circuits::mtable::MemoryTableChip" + [ + ("config", M.read (| config |)); + ("maximal_available_rows", + BinOp.Panic.mul (| + Integer.Usize, + BinOp.Panic.div (| + Integer.Usize, + M.read (| maximal_available_rows |), + M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::MEMORY_TABLE_ENTRY_ROWS" + |) + |)) + |), + M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::MEMORY_TABLE_ENTRY_ROWS" + |) + |)) + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "new" (new F). + End Impl_delphinus_zkwasm_circuits_mtable_MemoryTableChip_F. + End mtable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/mtable/utils.v b/CoqOfRust/zkWasm/circuits/mtable/utils.v new file mode 100644 index 000000000..e1a4bf72e --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/mtable/utils.v @@ -0,0 +1,81 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module mtable. + Module utils. + Definition value_WASM_BLOCK_BYTE_SIZE_SHIFT : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 3 |))). + + Definition value_WASM_BLOCK_BYTE_OFFSET_MASK : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 7 |))). + + Definition value_WASM_BLOCKS_PER_PAGE : Value.t := + M.run + ltac:(M.monadic + (M.alloc (| + BinOp.Panic.div (| + Integer.U32, + M.rust_cast + (M.read (| M.get_constant (| "specs::configure_table::WASM_BYTES_PER_PAGE" |) |)), + M.read (| M.get_constant (| "core::num::BITS" |) |) + |) + |))). + + Definition value_WASM_BLOCK_BYTE_SIZE : Value.t := + M.run + ltac:(M.monadic + (M.alloc (| + BinOp.Panic.shl (| + Value.Integer 1, + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::utils::WASM_BLOCK_BYTE_SIZE_SHIFT" + |) + |) + |) + |))). + + (* + pub(crate) fn block_from_address(address: u32) -> u32 { + address >> WASM_BLOCK_BYTE_SIZE_SHIFT + } + *) + Definition block_from_address (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ address ] => + ltac:(M.monadic + (let address := M.alloc (| address |) in + BinOp.Panic.shr (| + M.read (| address |), + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::utils::WASM_BLOCK_BYTE_SIZE_SHIFT" + |) + |) + |))) + | _, _ => M.impossible + end. + + (* + pub(crate) fn byte_offset_from_address(address: u32) -> u32 { + address & WASM_BLOCK_BYTE_OFFSET_MASK + } + *) + Definition byte_offset_from_address (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ address ] => + ltac:(M.monadic + (let address := M.alloc (| address |) in + BinOp.Pure.bit_and + (M.read (| address |)) + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::mtable::utils::WASM_BLOCK_BYTE_OFFSET_MASK" + |) + |)))) + | _, _ => M.impossible + end. + End utils. + End mtable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/post_image_table/trivial.v b/CoqOfRust/zkWasm/circuits/post_image_table/trivial.v new file mode 100644 index 000000000..0c76605d9 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/post_image_table/trivial.v @@ -0,0 +1,169 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module post_image_table. + (* StructRecord + { + name := "PostImageTableConfig"; + ty_params := [ "F" ]; + fields := [ ("_mark", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_post_image_table_PostImageTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::post_image_table::PostImageTableConfig") + [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::post_image_table::PostImageTableConfig" + [ + ("_mark", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::post_image_table::PostImageTableConfig", + "_mark" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_post_image_table_PostImageTableConfig_F. + + Module Impl_delphinus_zkwasm_circuits_post_image_table_PostImageTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::post_image_table::PostImageTableConfig") + [ F ]. + + (* + pub(in crate::circuits) fn configure( + _meta: &mut ConstraintSystem, + _memory_addr_sel: Option>, + _memory_table: &MemoryTableConfig, + _pre_image_table: &ImageTableConfig, + ) -> Self { + Self { _mark: PhantomData } + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ _meta; _memory_addr_sel; _memory_table; _pre_image_table ] => + ltac:(M.monadic + (let _meta := M.alloc (| _meta |) in + let _memory_addr_sel := M.alloc (| _memory_addr_sel |) in + let _memory_table := M.alloc (| _memory_table |) in + let _pre_image_table := M.alloc (| _pre_image_table |) in + Value.StructRecord + "delphinus_zkwasm::circuits::post_image_table::PostImageTableConfig" + [ ("_mark", Value.StructTuple "core::marker::PhantomData" []) ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure" (configure F). + End Impl_delphinus_zkwasm_circuits_post_image_table_PostImageTableConfig_F. + + (* StructRecord + { + name := "PostImageTableChip"; + ty_params := [ "F" ]; + fields := [ ("_mark", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) ]; + } *) + + Module Impl_delphinus_zkwasm_circuits_post_image_table_PostImageTableChip_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::post_image_table::PostImageTableChip") [ F ]. + + (* + pub(in crate::circuits) fn new(_config: PostImageTableConfig) -> Self { + Self { _mark: PhantomData } + } + *) + Definition new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ _config ] => + ltac:(M.monadic + (let _config := M.alloc (| _config |) in + Value.StructRecord + "delphinus_zkwasm::circuits::post_image_table::PostImageTableChip" + [ ("_mark", Value.StructTuple "core::marker::PhantomData" []) ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "new" (new F). + + (* + pub(in crate::circuits) fn assign( + self, + _layouter: impl Layouter, + _image_table_assigner: &ImageTableAssigner, + _post_image_table: ImageTableLayouter, + _rest_memory_finalized_count: u32, + _memory_finalized_set: HashSet<(LocationType, u32)>, + ) -> Result>, AssignedCell)>, Error> { + Ok(None) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Layouter_F_ ], + [ + self; + _layouter; + _image_table_assigner; + _post_image_table; + _rest_memory_finalized_count; + _memory_finalized_set + ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _layouter := M.alloc (| _layouter |) in + let _image_table_assigner := M.alloc (| _image_table_assigner |) in + let _post_image_table := M.alloc (| _post_image_table |) in + let _rest_memory_finalized_count := M.alloc (| _rest_memory_finalized_count |) in + let _memory_finalized_set := M.alloc (| _memory_finalized_set |) in + Value.StructTuple + "core::result::Result::Ok" + [ Value.StructTuple "core::option::Option::None" [] ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_circuits_post_image_table_PostImageTableChip_F. + End post_image_table. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/rtable.v b/CoqOfRust/zkWasm/circuits/rtable.v new file mode 100644 index 000000000..aa52c8a85 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/rtable.v @@ -0,0 +1,7125 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module rtable. + Definition value_POW_OP : Value.t := M.run ltac:(M.monadic (M.alloc (| Value.Integer 4 |))). + + (* StructRecord + { + name := "OpTable"; + ty_params := []; + fields := + [ + ("op", Ty.path "halo2_proofs::plonk::circuit::TableColumn"); + ("left", Ty.path "halo2_proofs::plonk::circuit::TableColumn"); + ("right", Ty.path "halo2_proofs::plonk::circuit::TableColumn"); + ("result", Ty.path "halo2_proofs::plonk::circuit::TableColumn") + ]; + } *) + + Module Impl_core_clone_Clone_for_delphinus_zkwasm_circuits_rtable_OpTable. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::circuits::rtable::OpTable". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::rtable::OpTable" + [ + ("op", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::circuit::TableColumn", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "op" + |) + ] + |)); + ("left", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::circuit::TableColumn", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "left" + |) + ] + |)); + ("right", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::circuit::TableColumn", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "right" + |) + ] + |)); + ("result", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::circuit::TableColumn", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "result" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_delphinus_zkwasm_circuits_rtable_OpTable. + + (* StructRecord + { + name := "RangeTableConfig"; + ty_params := [ "F" ]; + fields := + [ + ("common_range_col", Ty.path "halo2_proofs::plonk::circuit::TableColumn"); + ("u16_col", Ty.path "halo2_proofs::plonk::circuit::TableColumn"); + ("u8_col", Ty.path "halo2_proofs::plonk::circuit::TableColumn"); + ("op_table", Ty.path "delphinus_zkwasm::circuits::rtable::OpTable"); + ("_mark", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_rtable_RangeTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::rtable::RangeTableConfig") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::rtable::RangeTableConfig" + [ + ("common_range_col", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::circuit::TableColumn", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "common_range_col" + |) + ] + |)); + ("u16_col", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::circuit::TableColumn", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "u16_col" + |) + ] + |)); + ("u8_col", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "halo2_proofs::plonk::circuit::TableColumn", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "u8_col" + |) + ] + |)); + ("op_table", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "delphinus_zkwasm::circuits::rtable::OpTable", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |) + ] + |)); + ("_mark", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "_mark" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_rtable_RangeTableConfig_F. + + (* + pub fn pow_table_power_encode(power: T) -> T { + T::from_bn(&BigUint::from(POW_TABLE_POWER_START)) + power + } + *) + Definition pow_table_power_encode (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ T ], [ power ] => + ltac:(M.monadic + (let power := M.alloc (| power |) in + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Add", T, [ T ], "add", [] |), + [ + M.call_closure (| + M.get_trait_method (| "specs::encode::FromBn", T, [], "from_bn", [] |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::config::POW_TABLE_POWER_START" + |) + |) + ] + |) + |) + ] + |); + M.read (| power |) + ] + |))) + | _, _ => M.impossible + end. + + Module Impl_delphinus_zkwasm_circuits_rtable_RangeTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::rtable::RangeTableConfig") [ F ]. + + (* + pub fn configure(meta: &mut ConstraintSystem) -> Self { + // Shared by u8 lookup and bit table lookup + let u8_col_multiset = meta.lookup_table_column(); + + RangeTableConfig { + common_range_col: meta.lookup_table_column(), + u16_col: meta.lookup_table_column(), + u8_col: u8_col_multiset, + op_table: OpTable { + op: meta.lookup_table_column(), + left: u8_col_multiset, + right: meta.lookup_table_column(), + result: meta.lookup_table_column(), + }, + _mark: PhantomData, + } + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ meta ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + M.read (| + let u8_col_multiset := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "lookup_table_column", + [] + |), + [ M.read (| meta |) ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::rtable::RangeTableConfig" + [ + ("common_range_col", + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "lookup_table_column", + [] + |), + [ M.read (| meta |) ] + |)); + ("u16_col", + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "lookup_table_column", + [] + |), + [ M.read (| meta |) ] + |)); + ("u8_col", M.read (| u8_col_multiset |)); + ("op_table", + Value.StructRecord + "delphinus_zkwasm::circuits::rtable::OpTable" + [ + ("op", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "lookup_table_column", + [] + |), + [ M.read (| meta |) ] + |)); + ("left", M.read (| u8_col_multiset |)); + ("right", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "lookup_table_column", + [] + |), + [ M.read (| meta |) ] + |)); + ("result", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "lookup_table_column", + [] + |), + [ M.read (| meta |) ] + |)) + ]); + ("_mark", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure" (configure F). + + (* + pub fn configure_in_common_range( + &self, + meta: &mut ConstraintSystem, + key: &'static str, + expr: impl FnOnce(&mut VirtualCells<'_, F>) -> Expression, + ) { + meta.lookup(key, |meta| vec![(expr(meta), self.common_range_col)]); + } + *) + Definition configure_in_common_range (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_ ], + [ self; meta; key; expr ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let key := M.alloc (| key |) in + let expr := M.alloc (| expr |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "lookup", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "halo2_proofs::plonk::circuit::TableColumn" + ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| key |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "halo2_proofs::plonk::circuit::TableColumn" + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "halo2_proofs::plonk::circuit::TableColumn" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ + M.read (| expr |); + Value.Tuple [ M.read (| meta |) ] + ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "common_range_col" + |) + |) + ] + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure_in_common_range : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure_in_common_range" (configure_in_common_range F). + + (* + pub fn configure_in_u16_range( + &self, + meta: &mut ConstraintSystem, + key: &'static str, + expr: impl FnOnce(&mut VirtualCells<'_, F>) -> Expression, + ) { + meta.lookup(key, |meta| vec![(expr(meta), self.u16_col)]); + } + *) + Definition configure_in_u16_range (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_ ], + [ self; meta; key; expr ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let key := M.alloc (| key |) in + let expr := M.alloc (| expr |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "lookup", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "halo2_proofs::plonk::circuit::TableColumn" + ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| key |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "halo2_proofs::plonk::circuit::TableColumn" + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "halo2_proofs::plonk::circuit::TableColumn" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ + M.read (| expr |); + Value.Tuple [ M.read (| meta |) ] + ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "u16_col" + |) + |) + ] + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure_in_u16_range : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure_in_u16_range" (configure_in_u16_range F). + + (* + pub fn configure_in_u8_range( + &self, + meta: &mut ConstraintSystem, + key: &'static str, + expr: impl FnOnce(&mut VirtualCells<'_, F>) -> Expression, + ) { + meta.lookup(key, |meta| vec![(expr(meta), self.u8_col)]); + } + *) + Definition configure_in_u8_range (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_ ], + [ self; meta; key; expr ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let key := M.alloc (| key |) in + let expr := M.alloc (| expr |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "lookup", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "halo2_proofs::plonk::circuit::TableColumn" + ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| key |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "halo2_proofs::plonk::circuit::TableColumn" + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "halo2_proofs::plonk::circuit::TableColumn" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ + M.read (| expr |); + Value.Tuple [ M.read (| meta |) ] + ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "u8_col" + |) + |) + ] + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure_in_u8_range : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure_in_u8_range" (configure_in_u8_range F). + + (* + pub fn configure_in_op_table( + &self, + meta: &mut ConstraintSystem, + key: &'static str, + op: impl FnOnce(&mut VirtualCells<'_, F>) -> Expression, + left: impl FnOnce(&mut VirtualCells<'_, F>) -> Expression, + right: impl FnOnce(&mut VirtualCells<'_, F>) -> Expression, + result: impl FnOnce(&mut VirtualCells<'_, F>) -> Expression, + enable: impl Fn(&mut VirtualCells<'_, F>) -> Expression, + ) { + meta.lookup(key, |meta| { + vec![ + (enable(meta) * op(meta), self.op_table.op), + (enable(meta) * left(meta), self.op_table.left), + (enable(meta) * right(meta), self.op_table.right), + (enable(meta) * result(meta), self.op_table.result), + ] + }); + } + *) + Definition configure_in_op_table (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_; + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_'1; + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_'2; + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_'3; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_ + ], + [ self; meta; key; op; _ as left; _ as right; result; enable ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let key := M.alloc (| key |) in + let op := M.alloc (| op |) in + let left := M.alloc (| left |) in + let right := M.alloc (| right |) in + let result := M.alloc (| result |) in + let enable := M.alloc (| enable |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "lookup", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "halo2_proofs::plonk::circuit::TableColumn" + ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| key |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "halo2_proofs::plonk::circuit::TableColumn" + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "halo2_proofs::plonk::circuit::TableColumn" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + enable; + Value.Tuple + [ M.read (| meta |) ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ + M.read (| op |); + Value.Tuple + [ M.read (| meta |) ] + ] + |) + ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "op" + |) + |) + ]; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + enable; + Value.Tuple + [ M.read (| meta |) ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_'1, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ + M.read (| left |); + Value.Tuple + [ M.read (| meta |) ] + ] + |) + ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "left" + |) + |) + ]; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + enable; + Value.Tuple + [ M.read (| meta |) ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_'2, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ + M.read (| right |); + Value.Tuple + [ M.read (| meta |) ] + ] + |) + ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "right" + |) + |) + ]; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + enable; + Value.Tuple + [ M.read (| meta |) ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_'3, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ + M.read (| result |); + Value.Tuple + [ M.read (| meta |) ] + ] + |) + ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "result" + |) + |) + ] + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure_in_op_table : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure_in_op_table" (configure_in_op_table F). + + (* + pub fn configure_in_pow_set( + &self, + meta: &mut ConstraintSystem, + key: &'static str, + exp: impl FnOnce(&mut VirtualCells<'_, F>) -> Expression, + pow: impl FnOnce(&mut VirtualCells<'_, F>) -> Expression, + enable: impl Fn(&mut VirtualCells<'_, F>) -> Expression, + ) { + self.configure_in_op_table( + meta, + key, + |_| constant_from!(POW_OP), + |_| constant_from!(0), + |meta| exp(meta), + |meta| pow(meta), + enable, + ); + } + *) + Definition configure_in_pow_set (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_; + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_'1; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_ + ], + [ self; meta; key; exp; pow; enable ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let key := M.alloc (| key |) in + let exp := M.alloc (| exp |) in + let pow := M.alloc (| pow |) in + let enable := M.alloc (| enable |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::rtable::RangeTableConfig") + [ F ], + "configure_in_op_table", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_ + ] + |), + [ + M.read (| self |); + M.read (| meta |); + M.read (| key |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.get_constant (| + "delphinus_zkwasm::circuits::rtable::POW_OP" + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 0 |)) |) ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ M.read (| exp |); Value.Tuple [ M.read (| meta |) ] ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_'1, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ M.read (| pow |); Value.Tuple [ M.read (| meta |) ] ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| enable |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure_in_pow_set : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure_in_pow_set" (configure_in_pow_set F). + End Impl_delphinus_zkwasm_circuits_rtable_RangeTableConfig_F. + + (* StructRecord + { + name := "RangeTableChip"; + ty_params := [ "F" ]; + fields := + [ + ("config", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::rtable::RangeTableConfig") [ F ]) + ]; + } *) + + Module Impl_delphinus_zkwasm_circuits_rtable_RangeTableChip_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::rtable::RangeTableChip") [ F ]. + + (* + pub fn new(config: RangeTableConfig) -> Self { + RangeTableChip { config } + } + *) + Definition new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ config ] => + ltac:(M.monadic + (let config := M.alloc (| config |) in + Value.StructRecord + "delphinus_zkwasm::circuits::rtable::RangeTableChip" + [ ("config", M.read (| config |)) ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "new" (new F). + + (* + pub fn init(&self, layouter: impl Layouter, k: u32) -> Result<(), Error> { + layouter.assign_table( + || "common range table", + |table| { + for i in 0..common_range(k) { + table.assign_cell( + || "range table", + self.config.common_range_col, + i as usize, + || Ok(F::from(i as u64)), + )?; + } + Ok(()) + }, + )?; + + layouter.assign_table( + || "u16 range table", + |table| { + for i in 0..(1 << 16) { + table.assign_cell( + || "range table", + self.config.u16_col, + i, + || Ok(F::from(i as u64)), + )?; + } + Ok(()) + }, + )?; + + { + layouter.assign_table( + || "op lookup table", + |table| { + let mut offset = 0; + + for op in BitOp::iter() { + for left in 0..1u16 << 8 { + for right in 0u16..1 << 8 { + table.assign_cell( + || "range table", + self.config.op_table.op, + offset as usize, + || Ok(F::from(op as u64)), + )?; + + table.assign_cell( + || "range table", + self.config.op_table.left, + offset as usize, + || Ok(F::from(left as u64)), + )?; + + table.assign_cell( + || "range table", + self.config.op_table.right, + offset as usize, + || Ok(F::from(right as u64)), + )?; + + table.assign_cell( + || "range table", + self.config.op_table.result, + offset as usize, + || Ok(F::from(op.eval(left as u64, right as u64))), + )?; + + offset += 1; + } + } + } + + for left in 0..1u16 << 8 { + table.assign_cell( + || "range table", + self.config.op_table.op, + offset as usize, + || Ok(F::from(BitTableOp::Popcnt.index() as u64)), + )?; + + table.assign_cell( + || "range table", + self.config.op_table.left, + offset as usize, + || Ok(F::from(left as u64)), + )?; + + table.assign_cell( + || "range table", + self.config.op_table.right, + offset as usize, + || Ok(F::from(0)), + )?; + + table.assign_cell( + || "range table", + self.config.op_table.result, + offset as usize, + || Ok(F::from(left.count_ones() as u64)), + )?; + + offset += 1; + } + + assert_eq!(BitTableOp::Popcnt.index() + 1, POW_OP as usize); + + { + table.assign_cell( + || "range table", + self.config.op_table.op, + offset, + || Ok(F::from(POW_OP)), + )?; + + table.assign_cell( + || "range table", + self.config.op_table.left, + offset, + || Ok(F::zero()), + )?; + + table.assign_cell( + || "range table", + self.config.op_table.right, + offset, + || Ok(F::zero()), + )?; + + table.assign_cell( + || "range table", + self.config.op_table.result, + offset, + || Ok(F::zero()), + )?; + + offset += 1; + + for i in 0..POW_TABLE_POWER_START { + table.assign_cell( + || "range table", + self.config.op_table.op, + offset, + || Ok(F::from(POW_OP)), + )?; + + table.assign_cell( + || "range table", + self.config.op_table.left, + offset, + || Ok(F::zero()), + )?; + + table.assign_cell( + || "range table", + self.config.op_table.right, + offset, + || Ok(F::from(POW_TABLE_POWER_START + i)), + )?; + + table.assign_cell( + || "range table", + self.config.op_table.result, + offset, + || Ok(bn_to_field::(&(BigUint::from(1u64) << i))), + )?; + + offset += 1; + } + } + + Ok(()) + }, + )?; + } + + Ok(()) + } + *) + Definition init (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Layouter_F_ ], [ self; layouter; k ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let layouter := M.alloc (| layouter |) in + let k := M.alloc (| k |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::Layouter", + impl_Layouter_F_, + [ F ], + "assign_table", + [ + Ty.function + [ + Ty.tuple + [ Ty.apply (Ty.path "halo2_proofs::circuit::Table") [ F ] ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ]); + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + layouter; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| Value.String "common range table" |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let table := M.copy (| γ |) in + M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::config::common_range", + [] + |), + [ M.read (| k |) ] + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := + M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Table") + [ F ], + "assign_cell", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + table; + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "range table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::rtable::RangeTableChip", + "config" + |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "common_range_col" + |) + |); + M.rust_cast + (M.read (| + i + |)); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + i + |)) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::Layouter", + impl_Layouter_F_, + [ F ], + "assign_table", + [ + Ty.function + [ + Ty.tuple + [ Ty.apply (Ty.path "halo2_proofs::circuit::Table") [ F ] ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ]); + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + layouter; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| Value.String "u16 range table" |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let table := M.copy (| γ |) in + M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + BinOp.Panic.shl (| + Value.Integer 1, + Value.Integer 16 + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := + M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Table") + [ F ], + "assign_cell", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + table; + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "range table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::rtable::RangeTableChip", + "config" + |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "u16_col" + |) + |); + M.read (| + i + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + i + |)) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::Layouter", + impl_Layouter_F_, + [ F ], + "assign_table", + [ + Ty.function + [ + Ty.tuple + [ Ty.apply (Ty.path "halo2_proofs::circuit::Table") [ F ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ]); + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + layouter; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| Value.String "op lookup table" |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let table := M.copy (| γ |) in + M.read (| + let offset := M.alloc (| Value.Integer 0 |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.path "specs::itable::BitOpIter", + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "strum::IntoEnumIterator", + Ty.path "specs::itable::BitOp", + [], + "iter", + [] + |), + [] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.path + "specs::itable::BitOpIter", + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let op := + M.copy (| γ0_0 |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "u16" + ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + Value.Integer + 0); + ("end_", + BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 8 + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "u16" + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + left := + M.copy (| + γ0_0 + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "u16" + ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + Value.Integer + 0); + ("end_", + BinOp.Panic.shl (| + Value.Integer + 1, + Value.Integer + 8 + |)) + ] + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "u16" + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + right := + M.copy (| + γ0_0 + |) in + let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Table") + [ + F + ], + "assign_cell", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + table; + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "range table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::rtable::RangeTableChip", + "config" + |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "op" + |) + |); + M.read (| + M.use + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + op + |)) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Table") + [ + F + ], + "assign_cell", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + table; + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "range table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::rtable::RangeTableChip", + "config" + |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "left" + |) + |); + M.read (| + M.use + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + left + |)) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Table") + [ + F + ], + "assign_cell", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + table; + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "range table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::rtable::RangeTableChip", + "config" + |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "right" + |) + |); + M.read (| + M.use + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + right + |)) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Table") + [ + F + ], + "assign_cell", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + table; + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "range table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::rtable::RangeTableChip", + "config" + |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "result" + |) + |); + M.read (| + M.use + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::itable::BitOp", + "eval", + [] + |), + [ + op; + M.rust_cast + (M.read (| + left + |)); + M.rust_cast + (M.read (| + right + |)) + ] + |) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let + _ := + let + β := + offset in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| + β + |), + Value.Integer + 1 + |) + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "u16" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + BinOp.Panic.shl (| + Value.Integer 1, + Value.Integer 8 + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "u16" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let left := + M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Table") + [ F ], + "assign_cell", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + table; + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "range table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::rtable::RangeTableChip", + "config" + |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "op" + |) + |); + M.read (| + M.use + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::bit_table::BitTableOp", + "index", + [] + |), + [ + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::bit_table::BitTableOp::Popcnt" + [] + |) + ] + |)) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Table") + [ F ], + "assign_cell", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + table; + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "range table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::rtable::RangeTableChip", + "config" + |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "left" + |) + |); + M.read (| + M.use + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + left + |)) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Table") + [ F ], + "assign_cell", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + table; + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "range table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::rtable::RangeTableChip", + "config" + |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "right" + |) + |); + M.read (| + M.use + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + Value.Integer + 0 + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Table") + [ F ], + "assign_cell", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + table; + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "range table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::rtable::RangeTableChip", + "config" + |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "result" + |) + |); + M.read (| + M.use + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path + "u16", + "count_ones", + [] + |), + [ + M.read (| + left + |) + ] + |)) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let _ := + let β := offset in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::bit_table::BitTableOp", + "index", + [] + |), + [ + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::bit_table::BitTableOp::Popcnt" + [] + |) + ] + |), + Value.Integer 1 + |) + |); + M.alloc (| + M.rust_cast + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::rtable::POW_OP" + |) + |)) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| + M.read (| + left_val + |) + |)) + (M.read (| + M.read (| + right_val + |) + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ + Ty.path "usize"; + Ty.path "usize" + ] + |), + [ + M.read (| kind |); + M.read (| + left_val + |); + M.read (| + right_val + |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple [] + |))) + ] + |))) + ] + |) in + let _ := + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Table") + [ F ], + "assign_cell", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + table; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "range table" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::rtable::RangeTableChip", + "config" + |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "op" + |) + |); + M.read (| offset |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::rtable::POW_OP" + |) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Table") + [ F ], + "assign_cell", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + table; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "range table" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::rtable::RangeTableChip", + "config" + |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "left" + |) + |); + M.read (| offset |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Table") + [ F ], + "assign_cell", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + table; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "range table" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::rtable::RangeTableChip", + "config" + |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "right" + |) + |); + M.read (| offset |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Table") + [ F ], + "assign_cell", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]); + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ + table; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String + "range table" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::rtable::RangeTableChip", + "config" + |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "result" + |) + |); + M.read (| offset |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + let β := offset in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "u64" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::config::POW_TABLE_POWER_START" + |) + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "u64" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := + M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Table") + [ F ], + "assign_cell", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + table; + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "range table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::rtable::RangeTableChip", + "config" + |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "op" + |) + |); + M.read (| + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::rtable::POW_OP" + |) + |) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Table") + [ F ], + "assign_cell", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + table; + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "range table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::rtable::RangeTableChip", + "config" + |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "left" + |) + |); + M.read (| + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Table") + [ F ], + "assign_cell", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + table; + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "range table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::rtable::RangeTableChip", + "config" + |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "right" + |) + |); + M.read (| + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + BinOp.Panic.add (| + Integer.U64, + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::config::POW_TABLE_POWER_START" + |) + |), + M.read (| + i + |) + |) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Table") + [ F ], + "assign_cell", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + table; + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "range table" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::rtable::RangeTableChip", + "config" + |), + "delphinus_zkwasm::circuits::rtable::RangeTableConfig", + "op_table" + |), + "delphinus_zkwasm::circuits::rtable::OpTable", + "result" + |) + |); + M.read (| + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ + F + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "u64" + ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + Value.Integer + 1 + ] + |); + M.read (| + i + |) + ] + |) + |) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let _ := + let β := offset in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_init : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "init" (init F). + End Impl_delphinus_zkwasm_circuits_rtable_RangeTableChip_F. + End rtable. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/simulations/cell.v b/CoqOfRust/zkWasm/circuits/simulations/cell.v new file mode 100644 index 000000000..121444737 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/simulations/cell.v @@ -0,0 +1,27 @@ +Require Import CoqOfRust.CoqOfRust. +Require Import simulations.M. + +Require zkWasm.simulations.deps. + +Import simulations.M.Notations. + +(* define_cell!(AllocatedBitCell, F::one()); *) +Module AllocatedBitCell. + Parameter t : forall (F : Set) {_ : deps.FieldExt.Trait F}, Set. +End AllocatedBitCell. + +Module AllocatedU64CellWithFlagBitDyn. + Parameter t : forall (F : Set) {_ : deps.FieldExt.Trait F}, Set. +End AllocatedU64CellWithFlagBitDyn. + +Module AllocatedU64Cell. + Parameter t : forall (F : Set) {_ : deps.FieldExt.Trait F}, Set. +End AllocatedU64Cell. + +Module AllocatedCommonRangeCell. + Parameter t : forall (F : Set) {_ : deps.FieldExt.Trait F}, Set. +End AllocatedCommonRangeCell. + +Module AllocatedUnlimitedCell. + Parameter t : forall (F : Set) {_ : deps.FieldExt.Trait F}, Set. +End AllocatedUnlimitedCell. \ No newline at end of file diff --git a/CoqOfRust/zkWasm/circuits/traits.v b/CoqOfRust/zkWasm/circuits/traits.v new file mode 100644 index 000000000..4dec5d739 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/traits.v @@ -0,0 +1,9 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module traits. + (* Trait *) + (* Empty module 'ConfigureLookupTable' *) + End traits. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/utils/bit.v b/CoqOfRust/zkWasm/circuits/utils/bit.v new file mode 100644 index 000000000..cfaa5983d --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/utils/bit.v @@ -0,0 +1,670 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module utils. + Module bit. + (* StructRecord + { + name := "BitColumn"; + ty_params := [ "F" ]; + fields := + [ + ("col", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + ("_mark", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_utils_bit_BitColumn_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::utils::bit::BitColumn") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::utils::bit::BitColumn" + [ + ("col", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::bit::BitColumn", + "col" + |) + ] + |)); + ("_mark", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::bit::BitColumn", + "_mark" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_utils_bit_BitColumn_F. + + Module Impl_delphinus_zkwasm_circuits_utils_bit_BitColumn_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::utils::bit::BitColumn") [ F ]. + + (* + pub fn configure( + meta: &mut ConstraintSystem, + cols: &mut impl Iterator>, + enable: impl Fn(&mut VirtualCells<'_, F>) -> Expression, + ) -> Self { + let col = cols.next().unwrap(); + + meta.create_gate("bit column", |meta| { + vec![ + curr!(meta, col.clone()) + * (constant_from!(1) - curr!(meta, col.clone())) + * enable(meta), + ] + }); + + Self { + col, + _mark: PhantomData, + } + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ + impl_Iterator_Item___Column_Advice__; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_ + ], + [ meta; cols; enable ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + let cols := M.alloc (| cols |) in + let enable := M.alloc (| enable |) in + M.read (| + let col := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___Column_Advice__, + [], + "next", + [] + |), + [ M.read (| cols |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "bit column" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ], + [], + "clone", + [] + |), + [ col ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer 1 + |)) + |) + ] + |) + ]; + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Column") + [ + Ty.path + "halo2_proofs::plonk::circuit::Advice" + ], + [], + "clone", + [] + |), + [ col ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + enable; + Value.Tuple [ M.read (| meta |) ] + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::utils::bit::BitColumn" + [ + ("col", M.read (| col |)); + ("_mark", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure" (configure F). + + (* + pub fn assign(&self, ctx: &mut Context, value: bool) -> Result<(), Error> { + ctx.region.assign_advice( + || "bit value", + self.col, + ctx.offset, + || Ok(if value { F::one() } else { F::zero() }), + )?; + + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let value := M.alloc (| value |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "halo2_proofs::plonk::error::Error" ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| Value.String "bit value" |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::bit::BitColumn", + "col" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use value in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + |))) + ] + |) + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_circuits_utils_bit_BitColumn_F. + End bit. + End utils. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/utils/common_range.v b/CoqOfRust/zkWasm/circuits/utils/common_range.v new file mode 100644 index 000000000..b621e8585 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/utils/common_range.v @@ -0,0 +1,468 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module utils. + Module common_range. + (* StructRecord + { + name := "CommonRangeColumn"; + ty_params := [ "F" ]; + fields := + [ + ("col", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + ("_mark", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_utils_common_range_CommonRangeColumn_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::utils::common_range::CommonRangeColumn") + [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::utils::common_range::CommonRangeColumn" + [ + ("col", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::common_range::CommonRangeColumn", + "col" + |) + ] + |)); + ("_mark", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::common_range::CommonRangeColumn", + "_mark" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_utils_common_range_CommonRangeColumn_F. + + Module Impl_delphinus_zkwasm_circuits_utils_common_range_CommonRangeColumn_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::utils::common_range::CommonRangeColumn") + [ F ]. + + (* + pub fn configure( + meta: &mut ConstraintSystem, + cols: &mut impl Iterator>, + rtable: &RangeTableConfig, + enable: impl Fn(&mut VirtualCells<'_, F>) -> Expression, + ) -> Self { + let col = cols.next().unwrap(); + + rtable.configure_in_common_range(meta, "common range", |meta| { + curr!(meta, col) * enable(meta) + }); + + Self { + col, + _mark: PhantomData, + } + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ + impl_Iterator_Item___Column_Advice__; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_ + ], + [ meta; cols; rtable; enable ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + let cols := M.alloc (| cols |) in + let rtable := M.alloc (| rtable |) in + let enable := M.alloc (| enable |) in + M.read (| + let col := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___Column_Advice__, + [], + "next", + [] + |), + [ M.read (| cols |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::rtable::RangeTableConfig") + [ F ], + "configure_in_common_range", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]) + ] + |), + [ + M.read (| rtable |); + M.read (| meta |); + M.read (| Value.String "common range" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| col |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ enable; Value.Tuple [ M.read (| meta |) ] ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::utils::common_range::CommonRangeColumn" + [ + ("col", M.read (| col |)); + ("_mark", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure" (configure F). + + (* + pub fn assign(&self, ctx: &mut Context, value: u64) -> Result<(), Error> { + ctx.region.assign_advice( + || "common range value", + self.col, + ctx.offset, + || Ok(value.into()), + )?; + + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let value := M.alloc (| value |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "halo2_proofs::plonk::error::Error" ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| Value.String "common range value" |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::common_range::CommonRangeColumn", + "col" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| value |) ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_circuits_utils_common_range_CommonRangeColumn_F. + End common_range. + End utils. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/utils/image_table.v b/CoqOfRust/zkWasm/circuits/utils/image_table.v new file mode 100644 index 000000000..72aa33fae --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/utils/image_table.v @@ -0,0 +1,4327 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module utils. + Module image_table. + Definition value_STACK_CAPABILITY : Value.t := + M.run ltac:(M.monadic (M.get_constant (| "wasmi::runner::DEFAULT_VALUE_STACK_LIMIT" |))). + + Definition value_GLOBAL_CAPABILITY : Value.t := + M.run ltac:(M.monadic (M.get_constant (| "wasmi::runner::DEFAULT_VALUE_STACK_LIMIT" |))). + + Definition value_INIT_MEMORY_ENTRIES_OFFSET : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 40960 |))). + + (* StructRecord + { + name := "InitMemoryLayouter"; + ty_params := []; + fields := [ ("pages", Ty.path "u32") ]; + } *) + + Module Impl_delphinus_zkwasm_circuits_utils_image_table_InitMemoryLayouter. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::utils::image_table::InitMemoryLayouter". + + (* + fn for_each(self, mut f: impl FnMut((LocationType, u32))) { + for offset in 0..STACK_CAPABILITY { + f((LocationType::Stack, offset as u32)) + } + + for offset in 0..GLOBAL_CAPABILITY { + f((LocationType::Global, offset as u32)) + } + + for offset in 0..(self.pages * PAGE_ENTRIES) { + f((LocationType::Heap, offset)) + } + } + *) + Definition for_each (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ impl_FnMut__LocationType__u32__ ], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::utils::image_table::STACK_CAPABILITY" + |) + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnMut", + impl_FnMut__LocationType__u32__, + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "specs::mtable::LocationType"; + Ty.path "u32" + ] + ] + ], + "call_mut", + [] + |), + [ + f; + Value.Tuple + [ + Value.Tuple + [ + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + M.rust_cast (M.read (| offset |)) + ] + ] + ] + |) + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::utils::image_table::GLOBAL_CAPABILITY" + |) + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnMut", + impl_FnMut__LocationType__u32__, + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "specs::mtable::LocationType"; + Ty.path "u32" + ] + ] + ], + "call_mut", + [] + |), + [ + f; + Value.Tuple + [ + Value.Tuple + [ + Value.StructTuple + "specs::mtable::LocationType::Global" + []; + M.rust_cast (M.read (| offset |)) + ] + ] + ] + |) + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + BinOp.Panic.mul (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::circuits::utils::image_table::InitMemoryLayouter", + "pages" + |) + |), + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::image_table::PAGE_ENTRIES" + |) + |) + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnMut", + impl_FnMut__LocationType__u32__, + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "specs::mtable::LocationType"; + Ty.path "u32" + ] + ] + ], + "call_mut", + [] + |), + [ + f; + Value.Tuple + [ + Value.Tuple + [ + Value.StructTuple + "specs::mtable::LocationType::Heap" + []; + M.read (| offset |) + ] + ] + ] + |) + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_for_each : M.IsAssociatedFunction Self "for_each" for_each. + End Impl_delphinus_zkwasm_circuits_utils_image_table_InitMemoryLayouter. + + (* + pub fn image_table_offset_to_memory_location(offset: usize) -> (LocationType, u32) { + // Minus one for default lookup entry. + let mut offset = offset - INIT_MEMORY_ENTRIES_OFFSET - 1; + + if offset < STACK_CAPABILITY { + return (LocationType::Stack, offset as u32); + } + + offset -= STACK_CAPABILITY; + + if offset < GLOBAL_CAPABILITY { + return (LocationType::Global, offset as u32); + } + + offset -= GLOBAL_CAPABILITY; + return (LocationType::Heap, offset as u32); + } + *) + Definition image_table_offset_to_memory_location (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ offset ] => + ltac:(M.monadic + (let offset := M.alloc (| offset |) in + M.catch_return (| + ltac:(M.monadic + (M.never_to_any (| + M.read (| + let offset := + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + BinOp.Panic.sub (| + Integer.Usize, + M.read (| offset |), + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::utils::image_table::INIT_MEMORY_ENTRIES_OFFSET" + |) + |) + |), + Value.Integer 1 + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (M.read (| offset |)) + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::utils::image_table::STACK_CAPABILITY" + |) + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.Tuple + [ + Value.StructTuple "specs::mtable::LocationType::Stack" []; + M.rust_cast (M.read (| offset |)) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + let β := offset in + M.write (| + β, + BinOp.Panic.sub (| + Integer.Usize, + M.read (| β |), + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::utils::image_table::STACK_CAPABILITY" + |) + |) + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (M.read (| offset |)) + (M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::utils::image_table::GLOBAL_CAPABILITY" + |) + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.Tuple + [ + Value.StructTuple + "specs::mtable::LocationType::Global" + []; + M.rust_cast (M.read (| offset |)) + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + let β := offset in + M.write (| + β, + BinOp.Panic.sub (| + Integer.Usize, + M.read (| β |), + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::utils::image_table::GLOBAL_CAPABILITY" + |) + |) + |) + |) in + M.return_ (| + Value.Tuple + [ + Value.StructTuple "specs::mtable::LocationType::Heap" []; + M.rust_cast (M.read (| offset |)) + ] + |) + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* StructRecord + { + name := "ImageTableLayouter"; + ty_params := [ "T" ]; + fields := + [ + ("initialization_state", + Ty.apply (Ty.path "specs::state::InitializationState") [ T; T ]); + ("static_frame_entries", Ty.apply (Ty.path "array") [ Ty.tuple [ T; T ] ]); + ("instructions", + Ty.apply (Ty.path "alloc::vec::Vec") [ T; Ty.path "alloc::alloc::Global" ]); + ("br_table_entires", + Ty.apply (Ty.path "alloc::vec::Vec") [ T; Ty.path "alloc::alloc::Global" ]); + ("padding_entires", + Ty.apply (Ty.path "alloc::vec::Vec") [ T; Ty.path "alloc::alloc::Global" ]); + ("init_memory_entries", + Ty.apply (Ty.path "alloc::vec::Vec") [ T; Ty.path "alloc::alloc::Global" ]) + ]; + } *) + + Module Impl_core_fmt_Debug_where_core_fmt_Debug_T_for_delphinus_zkwasm_circuits_utils_image_table_ImageTableLayouter_T. + Definition Self (T : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ T ]. + + (* Debug *) + Definition fmt (T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self T in + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + let names := + M.alloc (| + M.alloc (| + Value.Array + [ + M.read (| Value.String "initialization_state" |); + M.read (| Value.String "static_frame_entries" |); + M.read (| Value.String "instructions" |); + M.read (| Value.String "br_table_entires" |); + M.read (| Value.String "padding_entires" |); + M.read (| Value.String "init_memory_entries" |) + ] + |) + |) in + let values := + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "initialization_state" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "static_frame_entries" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "instructions" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "br_table_entires" + |)); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "padding_entires" + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "init_memory_entries" + |) + |)) + ] + |)) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_fields_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "ImageTableLayouter" |); + (* Unsize *) M.pointer_coercion (M.read (| names |)); + M.read (| values |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (T : Ty.t), + M.IsTraitInstance + "core::fmt::Debug" + (Self T) + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method (fmt T)) ]. + End Impl_core_fmt_Debug_where_core_fmt_Debug_T_for_delphinus_zkwasm_circuits_utils_image_table_ImageTableLayouter_T. + + (* StructRecord + { + name := "ImageTableAssigner"; + ty_params := []; + fields := + [ + ("heap_capability", Ty.path "u32"); + ("initialization_state_offset", Ty.path "usize"); + ("static_frame_entries_offset", Ty.path "usize"); + ("instruction_offset", Ty.path "usize"); + ("br_table_offset", Ty.path "usize"); + ("padding_offset", Ty.path "usize"); + ("init_memory_offset", Ty.path "usize") + ]; + } *) + + Module Impl_core_clone_Clone_for_delphinus_zkwasm_circuits_utils_image_table_ImageTableAssigner. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + M.match_operator (| + Value.DeclaredButUndefined, + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + Value.DeclaredButUndefined, + [ fun γ => ltac:(M.monadic (M.read (| self |))) ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_delphinus_zkwasm_circuits_utils_image_table_ImageTableAssigner. + + Module Impl_core_marker_Copy_for_delphinus_zkwasm_circuits_utils_image_table_ImageTableAssigner. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner". + + Axiom Implements : + M.IsTraitInstance + "core::marker::Copy" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_marker_Copy_for_delphinus_zkwasm_circuits_utils_image_table_ImageTableAssigner. + + Module Impl_delphinus_zkwasm_circuits_utils_image_table_ImageTableAssigner. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner". + + (* + pub fn new(instruction_number: usize, br_table_number: usize, pages_capability: u32) -> Self { + let initialization_state_offset = 0; + let static_frame_entries_offset = + initialization_state_offset + InitializationState::::field_count(); + let instruction_offset = static_frame_entries_offset + STATIC_FRAME_ENTRY_IMAGE_TABLE_ENTRY; + let br_table_offset = instruction_offset + instruction_number; + let padding_offset = br_table_offset + br_table_number; + let init_memory_offset = INIT_MEMORY_ENTRIES_OFFSET; + + assert!( + padding_offset <= init_memory_offset, + "The number of instructions of the image({}) is too large", + instruction_number + br_table_number + ); + + Self { + heap_capability: pages_capability * PAGE_ENTRIES, + + initialization_state_offset, + static_frame_entries_offset, + instruction_offset, + br_table_offset, + padding_offset, + init_memory_offset, + } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ instruction_number; br_table_number; pages_capability ] => + ltac:(M.monadic + (let instruction_number := M.alloc (| instruction_number |) in + let br_table_number := M.alloc (| br_table_number |) in + let pages_capability := M.alloc (| pages_capability |) in + M.read (| + let initialization_state_offset := M.alloc (| Value.Integer 0 |) in + let static_frame_entries_offset := + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.read (| initialization_state_offset |), + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "specs::state::InitializationState") + [ Ty.path "u32"; Ty.path "num_bigint::biguint::BigUint" ], + "field_count", + [] + |), + [] + |) + |) + |) in + let instruction_offset := + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.read (| static_frame_entries_offset |), + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::jtable::STATIC_FRAME_ENTRY_IMAGE_TABLE_ENTRY" + |) + |) + |) + |) in + let br_table_offset := + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.read (| instruction_offset |), + M.read (| instruction_number |) + |) + |) in + let padding_offset := + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.read (| br_table_offset |), + M.read (| br_table_number |) + |) + |) in + let init_memory_offset := + M.copy (| + M.get_constant (| + "delphinus_zkwasm::circuits::utils::image_table::INIT_MEMORY_ENTRIES_OFFSET" + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.le + (M.read (| padding_offset |)) + (M.read (| init_memory_offset |))) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic_fmt", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "The number of instructions of the image(" + |); + M.read (| Value.String ") is too large" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ + M.alloc (| + BinOp.Panic.add (| + Integer.Usize, + M.read (| instruction_number |), + M.read (| br_table_number |) + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner" + [ + ("heap_capability", + BinOp.Panic.mul (| + Integer.U32, + M.read (| pages_capability |), + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::image_table::PAGE_ENTRIES" + |) + |) + |)); + ("initialization_state_offset", M.read (| initialization_state_offset |)); + ("static_frame_entries_offset", M.read (| static_frame_entries_offset |)); + ("instruction_offset", M.read (| instruction_offset |)); + ("br_table_offset", M.read (| br_table_offset |)); + ("padding_offset", M.read (| padding_offset |)); + ("init_memory_offset", M.read (| init_memory_offset |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + + (* + pub fn exec_initialization_state( + &self, + mut initialization_state_handler: impl FnMut(usize) -> Result, Error>, + ) -> Result, Error> { + initialization_state_handler(self.initialization_state_offset) + } + *) + Definition exec_initialization_state (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ T; Error; impl_FnMut_usize__arrow_Result_InitializationState_T__T___Error_ ], + [ self; initialization_state_handler ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let initialization_state_handler := M.alloc (| initialization_state_handler |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnMut", + impl_FnMut_usize__arrow_Result_InitializationState_T__T___Error_, + [ Ty.tuple [ Ty.path "usize" ] ], + "call_mut", + [] + |), + [ + initialization_state_handler; + Value.Tuple + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner", + "initialization_state_offset" + |) + |) + ] + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_exec_initialization_state : + M.IsAssociatedFunction Self "exec_initialization_state" exec_initialization_state. + + (* + pub fn exec_static_frame_entries( + &self, + mut static_frame_entries_handler: impl FnMut( + usize, + ) -> Result< + [(T, T); STATIC_FRAME_ENTRY_NUMBER], + Error, + >, + ) -> Result<[(T, T); STATIC_FRAME_ENTRY_NUMBER], Error> { + static_frame_entries_handler(self.static_frame_entries_offset) + } + *) + Definition exec_static_frame_entries (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ T; Error; impl_FnMut_usize__arrow_Result___T__T___STATIC_FRAME_ENTRY_NUMBER___Error_ + ], + [ self; static_frame_entries_handler ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let static_frame_entries_handler := M.alloc (| static_frame_entries_handler |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnMut", + impl_FnMut_usize__arrow_Result___T__T___STATIC_FRAME_ENTRY_NUMBER___Error_, + [ Ty.tuple [ Ty.path "usize" ] ], + "call_mut", + [] + |), + [ + static_frame_entries_handler; + Value.Tuple + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner", + "static_frame_entries_offset" + |) + |) + ] + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_exec_static_frame_entries : + M.IsAssociatedFunction Self "exec_static_frame_entries" exec_static_frame_entries. + + (* + pub fn exec_instruction( + &self, + mut instruction_handler: impl FnMut(usize) -> Result, Error>, + ) -> Result, Error> { + instruction_handler(self.instruction_offset) + } + *) + Definition exec_instruction (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ T; Error; impl_FnMut_usize__arrow_Result_Vec_T___Error_ ], + [ self; instruction_handler ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let instruction_handler := M.alloc (| instruction_handler |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnMut", + impl_FnMut_usize__arrow_Result_Vec_T___Error_, + [ Ty.tuple [ Ty.path "usize" ] ], + "call_mut", + [] + |), + [ + instruction_handler; + Value.Tuple + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner", + "instruction_offset" + |) + |) + ] + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_exec_instruction : + M.IsAssociatedFunction Self "exec_instruction" exec_instruction. + + (* + pub fn exec_br_table_entires( + &self, + mut br_table_handler: impl FnMut(usize) -> Result, Error>, + ) -> Result, Error> { + br_table_handler(self.br_table_offset) + } + *) + Definition exec_br_table_entires (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ T; Error; impl_FnMut_usize__arrow_Result_Vec_T___Error_ ], + [ self; br_table_handler ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let br_table_handler := M.alloc (| br_table_handler |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnMut", + impl_FnMut_usize__arrow_Result_Vec_T___Error_, + [ Ty.tuple [ Ty.path "usize" ] ], + "call_mut", + [] + |), + [ + br_table_handler; + Value.Tuple + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner", + "br_table_offset" + |) + |) + ] + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_exec_br_table_entires : + M.IsAssociatedFunction Self "exec_br_table_entires" exec_br_table_entires. + + (* + pub fn exec_padding_entires( + &self, + mut padding_handler: impl FnMut(usize, usize) -> Result, Error>, + ) -> Result, Error> { + padding_handler(self.padding_offset, self.init_memory_offset) + } + *) + Definition exec_padding_entires (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ T; Error; impl_FnMut_usize__usize__arrow_Result_Vec_T___Error_ ], + [ self; padding_handler ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let padding_handler := M.alloc (| padding_handler |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnMut", + impl_FnMut_usize__usize__arrow_Result_Vec_T___Error_, + [ Ty.tuple [ Ty.path "usize"; Ty.path "usize" ] ], + "call_mut", + [] + |), + [ + padding_handler; + Value.Tuple + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner", + "padding_offset" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner", + "init_memory_offset" + |) + |) + ] + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_exec_padding_entires : + M.IsAssociatedFunction Self "exec_padding_entires" exec_padding_entires. + + (* + pub fn exec_init_memory_entries( + &self, + mut init_memory_entries_handler: impl FnMut(usize) -> Result, Error>, + ) -> Result, Error> { + init_memory_entries_handler(self.init_memory_offset) + } + *) + Definition exec_init_memory_entries (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ T; Error; impl_FnMut_usize__arrow_Result_Vec_T___Error_ ], + [ self; init_memory_entries_handler ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let init_memory_entries_handler := M.alloc (| init_memory_entries_handler |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnMut", + impl_FnMut_usize__arrow_Result_Vec_T___Error_, + [ Ty.tuple [ Ty.path "usize" ] ], + "call_mut", + [] + |), + [ + init_memory_entries_handler; + Value.Tuple + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner", + "init_memory_offset" + |) + |) + ] + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_exec_init_memory_entries : + M.IsAssociatedFunction Self "exec_init_memory_entries" exec_init_memory_entries. + + (* + pub fn exec( + &self, + initialization_state_handler: impl FnMut(usize) -> Result, Error>, + static_frame_entries_handler: impl FnMut( + usize, + ) + -> Result<[(T, T); STATIC_FRAME_ENTRY_NUMBER], Error>, + instruction_handler: impl FnMut(usize) -> Result, Error>, + br_table_handler: impl FnMut(usize) -> Result, Error>, + padding_handler: impl FnMut(usize, usize) -> Result, Error>, + init_memory_entries_handler: impl FnMut(usize) -> Result, Error>, + ) -> Result, Error> { + let initialization_state = self.exec_initialization_state(initialization_state_handler)?; + let static_frame_entries = self.exec_static_frame_entries(static_frame_entries_handler)?; + let instructions = self.exec_instruction(instruction_handler)?; + let br_table_entires = self.exec_br_table_entires(br_table_handler)?; + let padding_entires = self.exec_padding_entires(padding_handler)?; + let init_memory_entries = self.exec_init_memory_entries(init_memory_entries_handler)?; + + Ok(ImageTableLayouter { + initialization_state, + static_frame_entries, + instructions, + br_table_entires, + padding_entires, + init_memory_entries, + }) + } + *) + Definition exec (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ + T; + Error; + impl_FnMut_usize__arrow_Result_InitializationState_T__T___Error_; + impl_FnMut_usize__arrow_Result___T__T___STATIC_FRAME_ENTRY_NUMBER___Error_; + impl_FnMut_usize__arrow_Result_Vec_T___Error_; + impl_FnMut_usize__arrow_Result_Vec_T___Error_'1; + impl_FnMut_usize__usize__arrow_Result_Vec_T___Error_; + impl_FnMut_usize__arrow_Result_Vec_T___Error_'2 + ], + [ + self; + initialization_state_handler; + static_frame_entries_handler; + instruction_handler; + br_table_handler; + padding_handler; + init_memory_entries_handler + ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let initialization_state_handler := M.alloc (| initialization_state_handler |) in + let static_frame_entries_handler := M.alloc (| static_frame_entries_handler |) in + let instruction_handler := M.alloc (| instruction_handler |) in + let br_table_handler := M.alloc (| br_table_handler |) in + let padding_handler := M.alloc (| padding_handler |) in + let init_memory_entries_handler := M.alloc (| init_memory_entries_handler |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let initialization_state := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "specs::state::InitializationState") [ T; T ]; + Error + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner", + "exec_initialization_state", + [ + T; + Error; + impl_FnMut_usize__arrow_Result_InitializationState_T__T___Error_ + ] + |), + [ M.read (| self |); M.read (| initialization_state_handler |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ T ]; + Error + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "core::convert::Infallible"; Error ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let static_frame_entries := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.apply (Ty.path "array") [ Ty.tuple [ T; T ] ]; Error ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner", + "exec_static_frame_entries", + [ + T; + Error; + impl_FnMut_usize__arrow_Result___T__T___STATIC_FRAME_ENTRY_NUMBER___Error_ + ] + |), + [ M.read (| self |); M.read (| static_frame_entries_handler |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ T ]; + Error + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "core::convert::Infallible"; Error ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let instructions := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ T; Ty.path "alloc::alloc::Global" ]; + Error + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner", + "exec_instruction", + [ T; Error; impl_FnMut_usize__arrow_Result_Vec_T___Error_ ] + |), + [ M.read (| self |); M.read (| instruction_handler |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ T ]; + Error + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "core::convert::Infallible"; Error ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let br_table_entires := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ T; Ty.path "alloc::alloc::Global" ]; + Error + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner", + "exec_br_table_entires", + [ T; Error; impl_FnMut_usize__arrow_Result_Vec_T___Error_'1 ] + |), + [ M.read (| self |); M.read (| br_table_handler |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ T ]; + Error + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "core::convert::Infallible"; Error ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let padding_entires := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ T; Ty.path "alloc::alloc::Global" ]; + Error + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner", + "exec_padding_entires", + [ T; Error; impl_FnMut_usize__usize__arrow_Result_Vec_T___Error_ + ] + |), + [ M.read (| self |); M.read (| padding_handler |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ T ]; + Error + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "core::convert::Infallible"; Error ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let init_memory_entries := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ T; Ty.path "alloc::alloc::Global" ]; + Error + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner", + "exec_init_memory_entries", + [ T; Error; impl_FnMut_usize__arrow_Result_Vec_T___Error_'2 ] + |), + [ M.read (| self |); M.read (| init_memory_entries_handler |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ T ]; + Error + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "core::convert::Infallible"; Error ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter" + [ + ("initialization_state", M.read (| initialization_state |)); + ("static_frame_entries", M.read (| static_frame_entries |)); + ("instructions", M.read (| instructions |)); + ("br_table_entires", M.read (| br_table_entires |)); + ("padding_entires", M.read (| padding_entires |)); + ("init_memory_entries", M.read (| init_memory_entries |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_exec : M.IsAssociatedFunction Self "exec" exec. + End Impl_delphinus_zkwasm_circuits_utils_image_table_ImageTableAssigner. + + (* + pub(crate) fn encode_compilation_table_values( + k: u32, + itable: &InstructionTable, + br_table: &BrTable, + elem_table: &ElemTable, + static_frame_entries: &[StaticFrameEntry; STATIC_FRAME_ENTRY_NUMBER], + initialization_state: &InitializationState, + init_memory_table: &InitMemoryTable, + ) -> ImageTableLayouter { + let page_capability = compute_maximal_pages(k); + + let initialization_state_handler = + |_| Ok(initialization_state.map(|v| F::from(( *v) as u64), |v| bn_to_field(v))); + + let static_frame_entries_handler = |_| { + let mut cells = vec![]; + + for entry in static_frame_entries.as_ref() { + cells.push((F::from(entry.enable as u64), bn_to_field(&entry.encode()))); + } + + Ok(cells.try_into().expect(&format!( + "The number of static frame entries should be {}", + STATIC_FRAME_ENTRY_NUMBER + ))) + }; + + let instruction_handler = |_| { + let mut cells = vec![]; + + cells.push(bn_to_field( + &ImageTableEncoder::Instruction.encode(BigUint::from(0u64)), + )); + + for e in itable.iter() { + cells.push(bn_to_field( + &ImageTableEncoder::Instruction.encode(e.encode.clone()), + )); + } + + Ok(cells) + }; + + let br_table_handler = |_| { + let mut cells = vec![]; + + cells.push(bn_to_field( + &ImageTableEncoder::BrTable.encode(BigUint::from(0u64)), + )); + + for e in br_table.entries() { + cells.push(bn_to_field(&ImageTableEncoder::BrTable.encode(e.encode()))); + } + + for e in elem_table.entries() { + cells.push(bn_to_field(&ImageTableEncoder::BrTable.encode(e.encode()))); + } + + Ok(cells) + }; + + let padding_handler = |start, end| Ok(vec![F::zero(); end - start]); + + let init_memory_entries_handler = |_| { + let mut cells = vec![]; + + cells.push(bn_to_field( + &ImageTableEncoder::InitMemory.encode(BigUint::from(0u64)), + )); + + let layouter = InitMemoryLayouter { + pages: page_capability, + }; + + layouter.for_each(|(ltype, offset)| { + if let Some(entry) = init_memory_table.try_find(ltype, offset) { + cells.push(bn_to_field::( + &ImageTableEncoder::InitMemory.encode(entry.encode()), + )); + } else if ltype == LocationType::Heap { + let entry = InitMemoryTableEntry { + ltype, + is_mutable: true, + offset, + vtype: VarType::I64, + value: 0, + eid: 0, + }; + + cells.push(bn_to_field::( + &ImageTableEncoder::InitMemory.encode(entry.encode()), + )); + } else { + cells.push(bn_to_field::( + &ImageTableEncoder::InitMemory.encode(BigUint::from(0u64)), + )); + } + }); + + Ok(cells) + }; + + let assigner = ImageTableAssigner::new( + itable.len() + 1, + br_table.entries().len() + elem_table.entries().len() + 1, + page_capability, + ); + + let layouter = assigner + .exec::<_, Error>( + initialization_state_handler, + static_frame_entries_handler, + instruction_handler, + br_table_handler, + padding_handler, + init_memory_entries_handler, + ) + .unwrap(); + + layouter + } + *) + Definition encode_compilation_table_values (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], + [ + k; + itable; + br_table; + elem_table; + static_frame_entries; + initialization_state; + init_memory_table + ] => + ltac:(M.monadic + (let k := M.alloc (| k |) in + let itable := M.alloc (| itable |) in + let br_table := M.alloc (| br_table |) in + let elem_table := M.alloc (| elem_table |) in + let static_frame_entries := M.alloc (| static_frame_entries |) in + let initialization_state := M.alloc (| initialization_state |) in + let init_memory_table := M.alloc (| init_memory_table |) in + M.read (| + let page_capability := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::image_table::compute_maximal_pages", + [] + |), + [ M.read (| k |) ] + |) + |) in + let initialization_state_handler := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "specs::state::InitializationState") + [ Ty.path "u32"; Ty.path "num_bigint::biguint::BigUint" + ], + "map", + [ + F; + Ty.function + [ + Ty.tuple + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ] + ] + F; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "num_bigint::biguint::BigUint" ] + ] + ] + F + ] + |), + [ + M.read (| initialization_state |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let v := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| M.read (| v |) |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let v := M.copy (| γ |) in + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ M.read (| v |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let static_frame_entries_handler := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let cells := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.tuple [ F; F ]; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::jtable::StaticFrameEntry" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.apply + (Ty.path "array") + [ Ty.path "specs::jtable::StaticFrameEntry" ], + [ + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::jtable::StaticFrameEntry" + ] + ], + "as_ref", + [] + |), + [ M.read (| static_frame_entries |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "specs::jtable::StaticFrameEntry" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let entry := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ F; F ]; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + cells; + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + entry + |), + "specs::jtable::StaticFrameEntry", + "enable" + |) + |)) + ] + |); + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::jtable::StaticFrameEntry", + "encode", + [] + |), + [ + M.read (| + entry + |) + ] + |) + |) + ] + |) + ] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "array") [ Ty.tuple [ F; F ] ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ F; F ]; + Ty.path "alloc::alloc::Global" + ] + ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::TryInto", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ F; F ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.apply (Ty.path "array") [ Ty.tuple [ F; F ] ] + ], + "try_into", + [] + |), + [ M.read (| cells |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "alloc::string::String", + [], + "deref", + [] + |), + [ + let res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "The number of static frame entries should be " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ + M.get_constant (| + "specs::jtable::STATIC_FRAME_ENTRY_NUMBER" + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let instruction_handler := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let cells := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + cells; + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::encode::image_table::ImageTableEncoder", + "encode", + [ Ty.path "num_bigint::biguint::BigUint" ] + |), + [ + M.alloc (| + Value.StructTuple + "specs::encode::image_table::ImageTableEncoder::Instruction" + [] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 0 ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.associated, + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::InstructionTable", + "iter", + [] + |), + [ M.read (| itable |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.associated, + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let e := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + cells; + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::encode::image_table::ImageTableEncoder", + "encode", + [ + Ty.path + "num_bigint::biguint::BigUint" + ] + |), + [ + M.alloc (| + Value.StructTuple + "specs::encode::image_table::ImageTableEncoder::Instruction" + [] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path + "num_bigint::biguint::BigUint", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + e + |), + "specs::itable::InstructionTableEntry", + "encode" + |) + ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ M.read (| cells |) ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let br_table_handler := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let cells := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + cells; + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::encode::image_table::ImageTableEncoder", + "encode", + [ Ty.path "num_bigint::biguint::BigUint" ] + |), + [ + M.alloc (| + Value.StructTuple + "specs::encode::image_table::ImageTableEncoder::BrTable" + [] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 0 ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::brtable::BrTableEntry"; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::brtable::BrTable", + "entries", + [] + |), + [ M.read (| br_table |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "specs::brtable::BrTableEntry" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let e := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + cells; + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::encode::image_table::ImageTableEncoder", + "encode", + [ + Ty.path + "num_bigint::biguint::BigUint" + ] + |), + [ + M.alloc (| + Value.StructTuple + "specs::encode::image_table::ImageTableEncoder::BrTable" + [] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::brtable::BrTableEntry", + "encode", + [] + |), + [ M.read (| e |) ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::brtable::ElemEntry"; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::brtable::ElemTable", + "entries", + [] + |), + [ M.read (| elem_table |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "specs::brtable::ElemEntry" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let e := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + cells; + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::encode::image_table::ImageTableEncoder", + "encode", + [ + Ty.path + "num_bigint::biguint::BigUint" + ] + |), + [ + M.alloc (| + Value.StructTuple + "specs::encode::image_table::ImageTableEncoder::BrTable" + [] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::brtable::ElemEntry", + "encode", + [] + |), + [ M.read (| e |) ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ M.read (| cells |) ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let padding_handler := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let start := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let end_ := M.copy (| γ |) in + Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_function (| "alloc::vec::from_elem", [ F ] |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |); + BinOp.Panic.sub (| + Integer.Usize, + M.read (| end_ |), + M.read (| start |) + |) + ] + |) + ])) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let init_memory_entries_handler := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let cells := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + cells; + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::encode::image_table::ImageTableEncoder", + "encode", + [ Ty.path "num_bigint::biguint::BigUint" ] + |), + [ + M.alloc (| + Value.StructTuple + "specs::encode::image_table::ImageTableEncoder::InitMemory" + [] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ Value.Integer 0 ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + let layouter := + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::utils::image_table::InitMemoryLayouter" + [ ("pages", M.read (| page_capability |)) ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::utils::image_table::InitMemoryLayouter", + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.path "specs::mtable::LocationType"; + Ty.path "u32" + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.read (| layouter |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let ltype := M.copy (| γ0_0 |) in + let offset := M.copy (| γ0_1 |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::imtable::InitMemoryTable", + "try_find", + [] + |), + [ + M.read (| + init_memory_table + |); + M.read (| ltype |); + M.read (| offset |) + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let entry := + M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + cells; + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::encode::image_table::ImageTableEncoder", + "encode", + [ + Ty.path + "num_bigint::biguint::BigUint" + ] + |), + [ + M.alloc (| + Value.StructTuple + "specs::encode::image_table::ImageTableEncoder::InitMemory" + [] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::imtable::InitMemoryTableEntry", + "encode", + [] + |), + [ + M.read (| + entry + |) + ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "specs::mtable::LocationType", + [ + Ty.path + "specs::mtable::LocationType" + ], + "eq", + [] + |), + [ + ltype; + M.alloc (| + Value.StructTuple + "specs::mtable::LocationType::Heap" + [] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let entry := + M.alloc (| + Value.StructRecord + "specs::imtable::InitMemoryTableEntry" + [ + ("ltype", + M.read (| + ltype + |)); + ("is_mutable", + Value.Bool + true); + ("offset", + M.read (| + offset + |)); + ("vtype", + Value.StructTuple + "specs::mtable::VarType::I64" + []); + ("value", + Value.Integer + 0); + ("eid", + Value.Integer + 0) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + cells; + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::encode::image_table::ImageTableEncoder", + "encode", + [ + Ty.path + "num_bigint::biguint::BigUint" + ] + |), + [ + M.alloc (| + Value.StructTuple + "specs::encode::image_table::ImageTableEncoder::InitMemory" + [] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::imtable::InitMemoryTableEntry", + "encode", + [] + |), + [ + entry + ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + cells; + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::encode::image_table::ImageTableEncoder", + "encode", + [ + Ty.path + "num_bigint::biguint::BigUint" + ] + |), + [ + M.alloc (| + Value.StructTuple + "specs::encode::image_table::ImageTableEncoder::InitMemory" + [] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path + "num_bigint::biguint::BigUint", + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + Value.Integer + 0 + ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ M.read (| cells |) ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let assigner := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner", + "new", + [] + |), + [ + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::InstructionTable", + "len", + [] + |), + [ M.read (| itable |) ] + |), + Value.Integer 1 + |); + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::brtable::BrTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::brtable::BrTable", + "entries", + [] + |), + [ M.read (| br_table |) ] + |) + ] + |), + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::brtable::ElemEntry"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::brtable::ElemTable", + "entries", + [] + |), + [ M.read (| elem_table |) ] + |) + ] + |) + |), + Value.Integer 1 + |); + M.read (| page_capability |) + ] + |) + |) in + let layouter := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ F ]; + Ty.path "anyhow::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner", + "exec", + [ + F; + Ty.path "anyhow::Error"; + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "specs::state::InitializationState") [ F; F ]; + Ty.path "anyhow::Error" + ]); + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "array") [ Ty.tuple [ F; F ] ]; + Ty.path "anyhow::Error" + ]); + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "anyhow::Error" + ]); + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "anyhow::Error" + ]); + Ty.function + [ Ty.tuple [ Ty.path "usize"; Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "anyhow::Error" + ]); + Ty.function + [ Ty.tuple [ Ty.path "usize" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "anyhow::Error" + ]) + ] + |), + [ + assigner; + M.read (| initialization_state_handler |); + M.read (| static_frame_entries_handler |); + M.read (| instruction_handler |); + M.read (| br_table_handler |); + M.read (| padding_handler |); + M.read (| init_memory_entries_handler |) + ] + |) + ] + |) + |) in + layouter + |))) + | _, _ => M.impossible + end. + + (* Trait *) + (* Empty module 'EncodeImageTable' *) + + Module Impl_delphinus_zkwasm_circuits_utils_image_table_EncodeImageTable_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_specs_slice_Slice. + Definition Self (F : Ty.t) : Ty.t := Ty.path "specs::slice::Slice". + + (* + fn encode_pre_compilation_table_values(&self, k: u32) -> ImageTableLayouter { + encode_compilation_table_values( + k, + &self.itable, + &self.br_table, + &self.elem_table, + &self.static_jtable, + &self.initialization_state, + &self.imtable, + ) + } + *) + Definition encode_pre_compilation_table_values + (F : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; k ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let k := M.alloc (| k |) in + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::image_table::encode_compilation_table_values", + [ F ] + |), + [ + M.read (| k |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ Ty.path "specs::itable::InstructionTable"; Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::slice::Slice", + "itable" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ Ty.path "specs::brtable::BrTable"; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::slice::Slice", + "br_table" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ Ty.path "specs::brtable::ElemTable"; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::slice::Slice", + "elem_table" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply (Ty.path "array") [ Ty.path "specs::jtable::StaticFrameEntry" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::slice::Slice", + "static_jtable" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ Ty.path "u32"; Ty.path "num_bigint::biguint::BigUint" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::slice::Slice", + "initialization_state" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ Ty.path "specs::imtable::InitMemoryTable"; Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::slice::Slice", + "imtable" + |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn encode_post_compilation_table_values(&self, k: u32) -> ImageTableLayouter { + encode_compilation_table_values( + k, + &self.itable, + &self.br_table, + &self.elem_table, + &self.static_jtable, + &self.post_initialization_state, + &self.post_imtable, + ) + } + *) + Definition encode_post_compilation_table_values + (F : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; k ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let k := M.alloc (| k |) in + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::image_table::encode_compilation_table_values", + [ F ] + |), + [ + M.read (| k |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ Ty.path "specs::itable::InstructionTable"; Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::slice::Slice", + "itable" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ Ty.path "specs::brtable::BrTable"; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::slice::Slice", + "br_table" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ Ty.path "specs::brtable::ElemTable"; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::slice::Slice", + "elem_table" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply (Ty.path "array") [ Ty.path "specs::jtable::StaticFrameEntry" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::slice::Slice", + "static_jtable" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ Ty.path "u32"; Ty.path "num_bigint::biguint::BigUint" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::slice::Slice", + "post_initialization_state" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ Ty.path "specs::imtable::InitMemoryTable"; Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::slice::Slice", + "post_imtable" + |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::utils::image_table::EncodeImageTable" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("encode_pre_compilation_table_values", + InstanceField.Method (encode_pre_compilation_table_values F)); + ("encode_post_compilation_table_values", + InstanceField.Method (encode_post_compilation_table_values F)) + ]. + End Impl_delphinus_zkwasm_circuits_utils_image_table_EncodeImageTable_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_specs_slice_Slice. + + Module Impl_delphinus_zkwasm_circuits_utils_image_table_ImageTableLayouter_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ F ]. + + (* + pub fn plain(&self) -> Vec { + let mut buf = vec![]; + + buf.append(&mut self.initialization_state.plain()); + buf.append( + &mut self + .static_frame_entries + .map(|(enable, fid)| vec![enable, fid]) + .into_iter() + .collect::>>() + .concat(), + ); + buf.append(&mut self.instructions.clone()); + buf.append(&mut self.br_table_entires.clone()); + buf.append(&mut self.padding_entires.clone()); + buf.append(&mut self.init_memory_entries.clone()); + + buf + } + *) + Definition plain (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let buf := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + "append", + [] + |), + [ + buf; + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "specs::state::InitializationState") [ F; F ], + "plain", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "initialization_state" + |) + ] + |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + "append", + [] + |), + [ + buf; + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ] + ], + "concat", + [ F ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ] + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.tuple [ F; F ] ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.tuple [ F; F ] ] ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ]); + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "static_frame_entries" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let enable := M.copy (| γ0_0 |) in + let fid := M.copy (| γ0_1 |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ F ], + "into_vec", + [ Ty.path "alloc::alloc::Global" + ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.read (| + enable + |); + M.read (| fid |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |) + ] + |) + ] + |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + "append", + [] + |), + [ + buf; + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "instructions" + |) + ] + |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + "append", + [] + |), + [ + buf; + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "br_table_entires" + |) + ] + |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + "append", + [] + |), + [ + buf; + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "padding_entires" + |) + ] + |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ], + "append", + [] + |), + [ + buf; + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "init_memory_entries" + |) + ] + |) + |) + ] + |) + |) in + buf + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_plain : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "plain" (plain F). + End Impl_delphinus_zkwasm_circuits_utils_image_table_ImageTableLayouter_F. + End image_table. + End utils. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/utils/mod.v b/CoqOfRust/zkWasm/circuits/utils/mod.v new file mode 100644 index 000000000..c675e61df --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/utils/mod.v @@ -0,0 +1,464 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module utils. + (* StructRecord + { + name := "Context"; + ty_params := [ "F" ]; + fields := + [ + ("region", + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ]; + Ty.path "alloc::alloc::Global" + ]); + ("offset", Ty.path "usize"); + ("records", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ]) + ]; + } *) + + Module Impl_delphinus_zkwasm_circuits_utils_Context_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::utils::Context") [ F ]. + + (* + pub fn new(region: &Region<'a, F>) -> Self { + Self { + region: Box::new(region.clone()), + offset: 0usize, + records: vec![], + } + } + *) + Definition new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ region ] => + ltac:(M.monadic + (let region := M.alloc (| region |) in + Value.StructRecord + "delphinus_zkwasm::circuits::utils::Context" + [ + ("region", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + [], + "clone", + [] + |), + [ M.read (| region |) ] + |) + ] + |)); + ("offset", Value.Integer 0); + ("records", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "new" (new F). + + (* + pub fn next(&mut self) { + self.offset += 1; + } + *) + Definition next (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let _ := + let β := + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) in + M.write (| + β, + BinOp.Panic.add (| Integer.Usize, M.read (| β |), Value.Integer 1 |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_next : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "next" (next F). + + (* + pub fn step(&mut self, step: usize) { + self.offset += step; + } + *) + Definition step (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; step ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let step := M.alloc (| step |) in + M.read (| + let _ := + let β := + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) in + M.write (| + β, + BinOp.Panic.add (| Integer.Usize, M.read (| β |), M.read (| step |) |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_step : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "step" (step F). + + (* + pub fn reset(&mut self) { + self.offset = 0; + self.records.clear(); + } + *) + Definition reset (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |), + Value.Integer 0 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ], + "clear", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::Context", + "records" + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_reset : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "reset" (reset F). + + (* + pub fn push(&mut self) { + self.records.push(self.offset) + } + *) + Definition push (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::Context", + "records" + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_push : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "push" (push F). + + (* + pub fn pop(&mut self) { + self.offset = self.records.pop().unwrap(); + } + *) + Definition pop (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |), + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "usize"; Ty.path "alloc::alloc::Global" ], + "pop", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::Context", + "records" + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_pop : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "pop" (pop F). + End Impl_delphinus_zkwasm_circuits_utils_Context_F. + + (* + pub fn field_to_bn(f: &F) -> BigUint { + let mut bytes: Vec = Vec::new(); + f.write(&mut bytes).unwrap(); + BigUint::from_bytes_le(&bytes[..]) + } + *) + Definition field_to_bn (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ f ] => + ltac:(M.monadic + (let f := M.alloc (| f |) in + M.read (| + let bytes := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::fields::BaseExt", + F, + [], + "write", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ] + ] + |), + [ M.read (| f |); bytes ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "num_bigint::biguint::BigUint", + "from_bytes_le", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index", + [] + |), + [ bytes; Value.StructTuple "core::ops::range::RangeFull" [] ] + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + (* + pub fn bn_to_field(bn: &BigUint) -> F { + let mut bytes = bn.to_bytes_le(); + bytes.resize(32, 0); + let mut bytes = &bytes[..]; + F::read(&mut bytes).unwrap() + } + *) + Definition bn_to_field (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ F ], [ bn ] => + ltac:(M.monadic + (let bn := M.alloc (| bn |) in + M.read (| + let bytes := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "num_bigint::biguint::BigUint", + "to_bytes_le", + [] + |), + [ M.read (| bn |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ], + "resize", + [] + |), + [ bytes; Value.Integer 32; Value.Integer 0 ] + |) + |) in + let bytes := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index", + [] + |), + [ bytes; Value.StructTuple "core::ops::range::RangeFull" [] ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::result::Result") [ F; Ty.path "std::io::error::Error" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "pairing_bn256::arithmetic::fields::BaseExt", + F, + [], + "read", + [ Ty.apply (Ty.path "&") [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ] ] + |), + [ bytes ] + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + End utils. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/utils/row_diff.v b/CoqOfRust/zkWasm/circuits/utils/row_diff.v new file mode 100644 index 000000000..e2ec80f5c --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/utils/row_diff.v @@ -0,0 +1,1671 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module utils. + Module row_diff. + (* StructRecord + { + name := "RowDiffConfig"; + ty_params := [ "F" ]; + fields := + [ + ("data", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + ("same", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + ("inv", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + ("distance", Ty.path "i32"); + ("_mark", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_utils_row_diff_RowDiffConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::utils::row_diff::RowDiffConfig") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::utils::row_diff::RowDiffConfig" + [ + ("data", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::row_diff::RowDiffConfig", + "data" + |) + ] + |)); + ("same", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::row_diff::RowDiffConfig", + "same" + |) + ] + |)); + ("inv", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::row_diff::RowDiffConfig", + "inv" + |) + ] + |)); + ("distance", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "i32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::row_diff::RowDiffConfig", + "distance" + |) + ] + |)); + ("_mark", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::row_diff::RowDiffConfig", + "_mark" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_utils_row_diff_RowDiffConfig_F. + + Module Impl_delphinus_zkwasm_circuits_utils_row_diff_RowDiffConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::utils::row_diff::RowDiffConfig") [ F ]. + + (* + pub fn configure( + key: &'static str, + meta: &mut ConstraintSystem, + cols: &mut impl Iterator>, + distance: i32, + enable: impl FnOnce(&mut VirtualCells<'_, F>) -> Expression, + ) -> Self { + let data = cols.next().unwrap(); + let same = cols.next().unwrap(); + let inv = cols.next().unwrap(); + + meta.enable_equality(same); + + meta.create_gate(key, |meta| { + let enable = enable(meta); + let diff = curr!(meta, data) - nextn!(meta, data, -distance); + let inv = curr!(meta, inv); + let same = curr!(meta, same); + vec![ + diff.clone() * inv.clone() + same.clone() - constant_from!(1), + diff * same, + ] + .into_iter() + .map(|x| x * enable.clone()) + .collect::>>() + }); + + RowDiffConfig { + data, + same, + inv, + distance, + _mark: PhantomData, + } + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ + impl_Iterator_Item___Column_Advice__; + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_ + ], + [ key; meta; cols; distance; enable ] => + ltac:(M.monadic + (let key := M.alloc (| key |) in + let meta := M.alloc (| meta |) in + let cols := M.alloc (| cols |) in + let distance := M.alloc (| distance |) in + let enable := M.alloc (| enable |) in + M.read (| + let data := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___Column_Advice__, + [], + "next", + [] + |), + [ M.read (| cols |) ] + |) + ] + |) + |) in + let same := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___Column_Advice__, + [], + "next", + [] + |), + [ M.read (| cols |) ] + |) + ] + |) + |) in + let inv := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___Column_Advice__, + [], + "next", + [] + |), + [ M.read (| cols |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "enable_equality", + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ] + |), + [ M.read (| meta |); M.read (| same |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "create_gate", + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| key |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let enable := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::FnOnce", + impl_FnOnce__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call_once", + [] + |), + [ + M.read (| enable |); + Value.Tuple [ M.read (| meta |) ] + ] + |) + |) in + let diff := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| data |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| data |); + Value.StructTuple + "halo2_proofs::poly::Rotation" + [ + UnOp.Panic.neg (| + Integer.I32, + M.read (| distance |) + |) + ] + ] + |) + ] + |) + |) in + let inv := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| inv |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + |) in + let same := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| same |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "map", + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ] + (Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ diff ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ inv ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ same ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer + 1 + |)) + |) + ] + |) + ] + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| diff |); + M.read (| same |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let x := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.read (| x |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [], + "clone", + [] + |), + [ enable ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::utils::row_diff::RowDiffConfig" + [ + ("data", M.read (| data |)); + ("same", M.read (| same |)); + ("inv", M.read (| inv |)); + ("distance", M.read (| distance |)); + ("_mark", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure" (configure F). + + (* + pub fn assign( + &self, + ctx: &mut Context, + offset_force: Option, + data: F, + diff: F, + ) -> Result<(), Error> { + let offset = if offset_force.is_some() { + offset_force.unwrap() + } else { + ctx.offset + }; + + ctx.region + .assign_advice(|| "row diff data", self.data, offset, || Ok(data))?; + + ctx.region.assign_advice( + || "row diff inv", + self.inv, + offset, + || Ok(diff.invert().unwrap_or(F::zero())), + )?; + + if offset < self.distance as usize { + ctx.region.assign_advice_from_constant( + || "row diff same", + self.same, + offset, + F::zero(), + )?; + } else { + ctx.region.assign_advice( + || "row diff same", + self.same, + offset, + || { + Ok(if diff.is_zero().into() { + F::one() + } else { + F::zero() + }) + }, + )?; + } + + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; offset_force; data; diff ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let offset_force := M.alloc (| offset_force |) in + let data := M.alloc (| data |) in + let diff := M.alloc (| diff |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let offset := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "usize" ], + "is_some", + [] + |), + [ offset_force ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ], + "unwrap", + [] + |), + [ M.read (| offset_force |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |))) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "halo2_proofs::plonk::error::Error" ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| Value.String "row diff data" |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::row_diff::RowDiffConfig", + "data" + |) + |); + M.read (| offset |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ M.read (| data |) ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "halo2_proofs::plonk::error::Error" ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| Value.String "row diff inv" |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::row_diff::RowDiffConfig", + "inv" + |) + |); + M.read (| offset |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "subtle::CtOption") + [ F ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "invert", + [] + |), + [ diff ] + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.lt + (M.read (| offset |)) + (M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::row_diff::RowDiffConfig", + "distance" + |) + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::circuit::Region") + [ F ], + "assign_advice_from_constant", + [ + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String "row diff same" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::row_diff::RowDiffConfig", + "same" + |) + |); + M.read (| offset |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::circuit::Region") + [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String "row diff same" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::row_diff::RowDiffConfig", + "same" + |) + |); + M.read (| offset |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "subtle::Choice", + [ Ty.path "bool" + ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "is_zero", + [] + |), + [ diff ] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "one", + [] + |), + [] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + |))) + ] + |) + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_circuits_utils_row_diff_RowDiffConfig_F. + End row_diff. + End utils. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/utils/step_status.v b/CoqOfRust/zkWasm/circuits/utils/step_status.v new file mode 100644 index 000000000..6d63b904c --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/utils/step_status.v @@ -0,0 +1,228 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module utils. + Module step_status. + (* StructRecord + { + name := "Status"; + ty_params := []; + fields := + [ + ("eid", Ty.path "u32"); + ("fid", Ty.path "u32"); + ("iid", Ty.path "u32"); + ("sp", Ty.path "u32"); + ("last_jump_eid", Ty.path "u32"); + ("allocated_memory_pages", Ty.path "u32"); + ("rest_mops", Ty.path "u32"); + ("jops", Ty.path "num_bigint::biguint::BigUint"); + ("host_public_inputs", Ty.path "u32"); + ("context_in_index", Ty.path "u32"); + ("context_out_index", Ty.path "u32"); + ("external_host_call_call_index", Ty.path "u32"); + ("itable", Ty.apply (Ty.path "&") [ Ty.path "specs::itable::InstructionTable" ]) + ]; + } *) + + Module Impl_core_clone_Clone_for_delphinus_zkwasm_circuits_utils_step_status_Status. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::circuits::utils::step_status::Status". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::utils::step_status::Status" + [ + ("eid", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + ] + |)); + ("fid", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "fid" + |) + ] + |)); + ("iid", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "iid" + |) + ] + |)); + ("sp", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + ] + |)); + ("last_jump_eid", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "last_jump_eid" + |) + ] + |)); + ("allocated_memory_pages", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "allocated_memory_pages" + |) + ] + |)); + ("rest_mops", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "rest_mops" + |) + ] + |)); + ("jops", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "num_bigint::biguint::BigUint", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "jops" + |) + ] + |)); + ("host_public_inputs", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "host_public_inputs" + |) + ] + |)); + ("context_in_index", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "context_in_index" + |) + ] + |)); + ("context_out_index", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "context_out_index" + |) + ] + |)); + ("external_host_call_call_index", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "external_host_call_call_index" + |) + ] + |)); + ("itable", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "&") [ Ty.path "specs::itable::InstructionTable" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "itable" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_delphinus_zkwasm_circuits_utils_step_status_Status. + + (* StructRecord + { + name := "StepStatus"; + ty_params := []; + fields := + [ + ("current", + Ty.apply + (Ty.path "&") + [ Ty.path "delphinus_zkwasm::circuits::utils::step_status::Status" ]); + ("next", + Ty.apply + (Ty.path "&") + [ Ty.path "delphinus_zkwasm::circuits::utils::step_status::Status" ]); + ("configure_table", + Ty.apply (Ty.path "&") [ Ty.path "specs::configure_table::ConfigureTable" ]) + ]; + } *) + End step_status. + End utils. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/utils/table_entry.v b/CoqOfRust/zkWasm/circuits/utils/table_entry.v new file mode 100644 index 000000000..19bfa30ca --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/utils/table_entry.v @@ -0,0 +1,3361 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module utils. + Module table_entry. + (* StructRecord + { + name := "MemoryWritingEntry"; + ty_params := []; + fields := + [ + ("index", Ty.path "usize"); + ("entry", Ty.path "specs::mtable::MemoryTableEntry"); + ("end_eid", Ty.path "u32") + ]; + } *) + + Module Impl_core_clone_Clone_for_delphinus_zkwasm_circuits_utils_table_entry_MemoryWritingEntry. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + [ + ("index", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "usize", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "index" + |) + ] + |)); + ("entry", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "specs::mtable::MemoryTableEntry", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |) + ] + |)); + ("end_eid", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "end_eid" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_delphinus_zkwasm_circuits_utils_table_entry_MemoryWritingEntry. + + Module Impl_core_fmt_Debug_for_delphinus_zkwasm_circuits_utils_table_entry_MemoryWritingEntry. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "MemoryWritingEntry" |); + M.read (| Value.String "index" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "index" + |)); + M.read (| Value.String "entry" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |)); + M.read (| Value.String "end_eid" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "end_eid" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_delphinus_zkwasm_circuits_utils_table_entry_MemoryWritingEntry. + + Module underscore. + Module Impl_serde_ser_Serialize_for_delphinus_zkwasm_circuits_utils_table_entry_MemoryWritingEntry. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry". + + (* Serialize *) + Definition serialize (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ __S ], [ self; __serializer ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let __serializer := M.alloc (| __serializer |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let __serde_state := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.associated ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "serde::ser::Serializer", + __S, + [], + "serialize_struct", + [] + |), + [ + M.read (| __serializer |); + M.read (| Value.String "MemoryWritingEntry" |); + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.rust_cast (Value.Bool false), + Value.Integer 1 + |), + Value.Integer 1 + |), + Value.Integer 1 + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.associated ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.associated + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.associated ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "serde::ser::SerializeStruct", + Ty.associated, + [], + "serialize_field", + [ Ty.path "usize" ] + |), + [ + __serde_state; + M.read (| Value.String "index" |); + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "index" + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.associated ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "core::convert::Infallible"; Ty.associated + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.associated ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "serde::ser::SerializeStruct", + Ty.associated, + [], + "serialize_field", + [ Ty.path "specs::mtable::MemoryTableEntry" ] + |), + [ + __serde_state; + M.read (| Value.String "entry" |); + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.associated ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "core::convert::Infallible"; Ty.associated + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.associated ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "serde::ser::SerializeStruct", + Ty.associated, + [], + "serialize_field", + [ Ty.path "u32" ] + |), + [ + __serde_state; + M.read (| Value.String "end_eid" |); + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "end_eid" + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.associated; Ty.associated ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "core::convert::Infallible"; Ty.associated + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "serde::ser::SerializeStruct", + Ty.associated, + [], + "end", + [] + |), + [ M.read (| __serde_state |) ] + |) + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "serde::ser::Serialize" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("serialize", InstanceField.Method serialize) ]. + End Impl_serde_ser_Serialize_for_delphinus_zkwasm_circuits_utils_table_entry_MemoryWritingEntry. + Module Impl_serde_ser_Serialize_for_delphinus_zkwasm_circuits_utils_table_entry_MemoryWritingTable. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable". + + (* Serialize *) + Definition serialize (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ __S ], [ self; __serializer ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let __serializer := M.alloc (| __serializer |) in + M.call_closure (| + M.get_trait_method (| + "serde::ser::Serializer", + __S, + [], + "serialize_newtype_struct", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.read (| __serializer |); + M.read (| Value.String "MemoryWritingTable" |); + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable", + 0 + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "serde::ser::Serialize" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("serialize", InstanceField.Method serialize) ]. + End Impl_serde_ser_Serialize_for_delphinus_zkwasm_circuits_utils_table_entry_MemoryWritingTable. + End underscore. + + Module Impl_delphinus_zkwasm_circuits_utils_table_entry_MemoryWritingEntry. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry". + + (* + fn is_same_memory_address(&self, other: &Self) -> bool { + self.entry.is_same_location(&other.entry) + } + *) + Definition is_same_memory_address (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; other ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let other := M.alloc (| other |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::mtable::MemoryTableEntry", + "is_same_location", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |); + M.SubPointer.get_struct_record_field (| + M.read (| other |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_is_same_memory_address : + M.IsAssociatedFunction Self "is_same_memory_address" is_same_memory_address. + End Impl_delphinus_zkwasm_circuits_utils_table_entry_MemoryWritingEntry. + + (* StructTuple + { + name := "MemoryWritingTable"; + ty_params := []; + fields := + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry"; + Ty.path "alloc::alloc::Global" + ] + ]; + } *) + + Module Impl_core_fmt_Debug_for_delphinus_zkwasm_circuits_utils_table_entry_MemoryWritingTable. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "MemoryWritingTable" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable", + 0 + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_delphinus_zkwasm_circuits_utils_table_entry_MemoryWritingTable. + + + Module Impl_delphinus_zkwasm_circuits_utils_table_entry_MemoryWritingTable. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable". + + (* + pub(crate) fn count_rest_memory_finalize_ops(&self) -> (u32, HashSet<(LocationType, u32)>) { + let mut count = 0u32; + let mut set = HashSet::default(); + + let mut iter = self.0.iter().peekable(); + + while let Some(entry) = iter.next() { + if entry.entry.atype == AccessType::Write + && iter.peek().map_or(true, |next_entry| { + !next_entry.entry.is_same_location(&entry.entry) + }) + { + set.insert((entry.entry.ltype, entry.entry.offset)); + count += 1; + } + } + + (count, set) + } + *) + Definition count_rest_memory_finalize_ops (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let count := M.alloc (| Value.Integer 0 |) in + let set := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.tuple [ Ty.path "specs::mtable::LocationType"; Ty.path "u32" ]; + Ty.path "std::hash::random::RandomState" + ], + [], + "default", + [] + |), + [] + |) + |) in + let iter := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ], + [], + "peekable", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable", + 0 + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.loop (| + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::peekable::Peekable") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let entry := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::AccessType", + [ Ty.path "specs::mtable::AccessType" ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "atype" + |); + M.alloc (| + Value.StructTuple + "specs::mtable::AccessType::Write" + [] + |) + ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ] + ], + "map_or", + [ + Ty.path "bool"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::iter::adapters::peekable::Peekable") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ], + "peek", + [] + |), + [ iter ] + |); + Value.Bool true; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let next_entry := + M.copy (| γ |) in + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::mtable::MemoryTableEntry", + "is_same_location", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + M.read (| + next_entry + |) + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |); + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |) + ] + |)))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ + Ty.tuple + [ + Ty.path "specs::mtable::LocationType"; + Ty.path "u32" + ]; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + set; + Value.Tuple + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "ltype" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "offset" + |) + |) + ] + ] + |) + |) in + let _ := + let β := count in + M.write (| + β, + BinOp.Panic.add (| + Integer.U32, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + let _ := + M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |) in + M.alloc (| Value.Tuple [] |) + |) + |) + |))) + ] + |))) + |) in + M.alloc (| Value.Tuple [ M.read (| count |); M.read (| set |) ] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_count_rest_memory_finalize_ops : + M.IsAssociatedFunction + Self + "count_rest_memory_finalize_ops" + count_rest_memory_finalize_ops. + + (* + pub fn from(k: u32, value: MTable) -> Self { + let maximal_eid = if cfg!(feature = "continuation") { + u32::MAX + } else { + common_range_max(k) + }; + let mut index = 0; + + let mut entries: Vec = value + .entries() + .iter() + .filter_map(|entry| { + if entry.atype != AccessType::Read { + let entry = Some(MemoryWritingEntry { + index, + entry: entry.clone(), + end_eid: maximal_eid, + }); + + index += 1; + + entry + } else { + None + } + }) + .collect(); + + let entries_next = entries.clone(); + let next_iter = entries_next.iter().skip(1); + + entries.iter_mut().zip(next_iter).for_each(|(curr, next)| { + if curr.is_same_memory_address(next) { + curr.end_eid = next.entry.eid; + } + }); + + // FIXME: create_memory_table pushed a lot of meaningless Stack init. Fix it elegantly. + let entries = entries + .into_iter() + .filter(|entry| entry.entry.eid != entry.end_eid) + .collect(); + + MemoryWritingTable(entries) + } + *) + Definition from (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ k; value ] => + ltac:(M.monadic + (let k := M.alloc (| k |) in + let value := M.alloc (| value |) in + M.read (| + let maximal_eid := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use (M.alloc (| Value.Bool false |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.get_constant (| "core::num::MAX" |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::config::common_range_max", + [] + |), + [ M.read (| k |) ] + |) + |))) + ] + |) + |) in + let index := M.alloc (| Value.Integer 0 |) in + let entries := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "specs::mtable::MemoryTableEntry" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "specs::mtable::MemoryTableEntry" ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "specs::mtable::MemoryTableEntry" ], + [], + "filter_map", + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "specs::mtable::MemoryTableEntry" ] + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::mtable::MemoryTableEntry" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::mtable::MTable", + "entries", + [] + |), + [ value ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let entry := M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::AccessType", + [ + Ty.path + "specs::mtable::AccessType" + ], + "ne", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "specs::mtable::MemoryTableEntry", + "atype" + |); + M.alloc (| + Value.StructTuple + "specs::mtable::AccessType::Read" + [] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let entry := + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + [ + ("index", M.read (| index |)); + ("entry", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path + "specs::mtable::MemoryTableEntry", + [], + "clone", + [] + |), + [ M.read (| entry |) ] + |)); + ("end_eid", + M.read (| maximal_eid |)) + ] + ] + |) in + let _ := + let β := index in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |) in + entry)); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let entries_next := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ entries ] + |) + |) in + let next_iter := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ], + [], + "skip", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ entries_next ] + |) + ] + |); + Value.Integer 1 + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ]; + Ty.apply + (Ty.path "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ] + ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ]; + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::IterMut") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::iter::adapters::skip::Skip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ], + "iter_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ entries ] + |) + ] + |); + M.read (| next_iter |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let curr := M.copy (| γ0_0 |) in + let next := M.copy (| γ0_1 |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "is_same_memory_address", + [] + |), + [ M.read (| curr |); M.read (| next |) ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.read (| curr |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "end_eid" + |), + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| next |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "eid" + |) + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let entries := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry"; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ] + ] + (Ty.path "bool") + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "filter", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| entries |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let entry := M.copy (| γ |) in + BinOp.Pure.ne + (M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "eid" + |) + |)) + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "end_eid" + |) + |)))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable" + [ M.read (| entries |) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_from : M.IsAssociatedFunction Self "from" from. + (* + fn build_lookup_mapping(&self) -> BTreeMap<(LocationType, u32), Vec<(u32, u32)>> { + let mut mapping = BTreeMap::<_, Vec<(u32, u32)>>::new(); + + for entry in &self.0 { + let ltype = entry.entry.ltype; + let offset = entry.entry.offset; + let start_eid = entry.entry.eid; + let end_eid = entry.end_eid; + + if let Some(entries) = mapping.get_mut(&(ltype, offset)) { + entries.push((start_eid, end_eid)); + } else { + mapping.insert((ltype, offset), vec![(start_eid, end_eid)]); + } + } + + mapping + } + *) + Definition build_lookup_mapping (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let mapping := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.tuple [ Ty.path "specs::mtable::LocationType"; Ty.path "u32" ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry"; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable", + 0 + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let entry := M.copy (| γ0_0 |) in + let ltype := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "ltype" + |) + |) in + let offset := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "offset" + |) + |) in + let start_eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "entry" + |), + "specs::mtable::MemoryTableEntry", + "eid" + |) + |) in + let end_eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingEntry", + "end_eid" + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.tuple + [ + Ty.path + "specs::mtable::LocationType"; + Ty.path "u32" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "get_mut", + [ + Ty.tuple + [ + Ty.path + "specs::mtable::LocationType"; + Ty.path "u32" + ] + ] + |), + [ + mapping; + M.alloc (| + Value.Tuple + [ + M.read (| ltype |); + M.read (| offset |) + ] + |) + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let entries := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.read (| entries |); + Value.Tuple + [ + M.read (| start_eid |); + M.read (| end_eid |) + ] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.tuple + [ + Ty.path + "specs::mtable::LocationType"; + Ty.path "u32" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" + ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + mapping; + Value.Tuple + [ + M.read (| ltype |); + M.read (| offset |) + ]; + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.read (| + start_eid + |); + M.read (| end_eid |) + ] + ] + |) + ] + |) + |)) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + mapping + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_build_lookup_mapping : + M.IsAssociatedFunction Self "build_lookup_mapping" build_lookup_mapping. + + (* + pub fn write_json(&self, dir: Option) { + fn write_file(folder: &PathBuf, filename: &str, buf: &String) { + let mut folder = folder.clone(); + folder.push(filename); + let mut fd = std::fs::File::create(folder.as_path()).unwrap(); + folder.pop(); + + fd.write(buf.as_bytes()).unwrap(); + } + + let mtable = serde_json::to_string_pretty(self).unwrap(); + + let dir = dir.unwrap_or(env::current_dir().unwrap()); + write_file(&dir, "memory_writing_table.json", &mtable); + } + *) + Definition write_json (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; dir ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let dir := M.alloc (| dir |) in + M.read (| + let mtable := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "alloc::string::String"; Ty.path "serde_json::error::Error" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_function (| + "serde_json::ser::to_string_pretty", + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable" + ] + |), + [ M.read (| self |) ] + |) + ] + |) + |) in + let dir := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.path "std::path::PathBuf" ], + "unwrap_or", + [] + |), + [ + M.read (| dir |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "std::path::PathBuf"; Ty.path "std::io::error::Error" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_function (| "std::env::current_dir", [] |), + [] + |) + ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| Self, "write_file.write_json", [] |), + [ dir; M.read (| Value.String "memory_writing_table.json" |); mtable ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_write_json : M.IsAssociatedFunction Self "write_json" write_json. + End Impl_delphinus_zkwasm_circuits_utils_table_entry_MemoryWritingTable. + + + (* StructRecord + { + name := "MemoryRWEntry"; + ty_params := []; + fields := + [ + ("entry", Ty.path "specs::mtable::MemoryTableEntry"); + ("start_eid", Ty.path "u32"); + ("end_eid", Ty.path "u32") + ]; + } *) + + Module Impl_core_fmt_Debug_for_delphinus_zkwasm_circuits_utils_table_entry_MemoryRWEntry. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "MemoryRWEntry" |); + M.read (| Value.String "entry" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "entry" + |)); + M.read (| Value.String "start_eid" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |)); + M.read (| Value.String "end_eid" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_delphinus_zkwasm_circuits_utils_table_entry_MemoryRWEntry. + + (* StructRecord + { + name := "EventTableEntryWithMemoryInfo"; + ty_params := []; + fields := + [ + ("eentry", Ty.path "specs::etable::EventTableEntry"); + ("memory_rw_entires", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_core_fmt_Debug_for_delphinus_zkwasm_circuits_utils_table_entry_EventTableEntryWithMemoryInfo. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "EventTableEntryWithMemoryInfo" |); + M.read (| Value.String "eentry" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |)); + M.read (| Value.String "memory_rw_entires" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_delphinus_zkwasm_circuits_utils_table_entry_EventTableEntryWithMemoryInfo. + + (* StructTuple + { + name := "EventTableWithMemoryInfo"; + ty_params := []; + fields := + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo"; + Ty.path "alloc::alloc::Global" + ] + ]; + } *) + + Module Impl_core_fmt_Debug_for_delphinus_zkwasm_circuits_utils_table_entry_EventTableWithMemoryInfo. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::utils::table_entry::EventTableWithMemoryInfo". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "EventTableWithMemoryInfo" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableWithMemoryInfo", + 0 + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_delphinus_zkwasm_circuits_utils_table_entry_EventTableWithMemoryInfo. + + Module Impl_delphinus_zkwasm_circuits_utils_table_entry_EventTableWithMemoryInfo. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::circuits::utils::table_entry::EventTableWithMemoryInfo". + + (* + pub(in crate::circuits) fn new( + event_table: &EventTable, + memory_writing_table: &MemoryWritingTable, + ) -> Self { + let lookup = memory_writing_table.build_lookup_mapping(); + + let lookup_mtable_eid = |(eid, ltype, offset, is_writing)| { + let records = lookup.get(&(ltype, offset)).unwrap(); + + if is_writing { + let idx = records + .binary_search_by(|(start_eid, _)| start_eid.cmp(eid)) + .unwrap(); + records[idx] + } else { + let idx = records + .binary_search_by(|(start_eid, end_eid)| { + if eid <= start_eid { + Ordering::Greater + } else if eid > end_eid { + Ordering::Less + } else { + Ordering::Equal + } + }) + .unwrap(); + + records[idx] + } + }; + + EventTableWithMemoryInfo( + event_table + .entries() + .iter() + .map(|eentry| EventTableEntryWithMemoryInfo { + eentry: eentry.clone(), + memory_rw_entires: memory_event_of_step(eentry) + .iter() + .map(|mentry| { + let (start_eid, end_eid) = lookup_mtable_eid(( + &eentry.eid, + mentry.ltype, + mentry.offset, + mentry.atype == AccessType::Write, + )); + + MemoryRWEntry { + entry: mentry.clone(), + start_eid, + end_eid, + } + }) + .collect(), + }) + .collect(), + ) + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ event_table; memory_writing_table ] => + ltac:(M.monadic + (let event_table := M.alloc (| event_table |) in + let memory_writing_table := M.alloc (| memory_writing_table |) in + M.read (| + let lookup := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable", + "build_lookup_mapping", + [] + |), + [ M.read (| memory_writing_table |) ] + |) + |) in + let lookup_mtable_eid := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let γ0_2 := M.SubPointer.get_tuple_field (| γ, 2 |) in + let γ0_3 := M.SubPointer.get_tuple_field (| γ, 3 |) in + let eid := M.copy (| γ0_0 |) in + let ltype := M.copy (| γ0_1 |) in + let offset := M.copy (| γ0_2 |) in + let is_writing := M.copy (| γ0_3 |) in + M.read (| + let records := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.tuple + [ + Ty.path "specs::mtable::LocationType"; + Ty.path "u32" + ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "get", + [ + Ty.tuple + [ + Ty.path "specs::mtable::LocationType"; + Ty.path "u32" + ] + ] + |), + [ + lookup; + M.alloc (| + Value.Tuple + [ M.read (| ltype |); M.read (| offset |) ] + |) + ] + |) + ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use is_writing in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let idx := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "usize" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ] + ], + "binary_search_by", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ] + ] + ] + ] + (Ty.path "core::cmp::Ordering") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| records |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let start_eid := + M.alloc (| γ1_0 |) in + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path "u32", + [], + "cmp", + [] + |), + [ + M.read (| + start_eid + |); + M.read (| eid |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ M.read (| records |); M.read (| idx |) ] + |))); + fun γ => + ltac:(M.monadic + (let idx := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "usize"; Ty.path "usize" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" ] + ], + "binary_search_by", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path "u32"; + Ty.path "u32" + ] + ] + ] + ] + (Ty.path "core::cmp::Ordering") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ Ty.path "u32"; Ty.path "u32" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| records |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let start_eid := + M.alloc (| γ1_0 |) in + let end_eid := + M.alloc (| γ1_1 |) in + M.read (| + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "u32" + ], + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "u32" + ] + ], + "le", + [] + |), + [ + eid; + M.alloc (| + M.read (| + start_eid + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + Value.StructTuple + "core::cmp::Ordering::Greater" + [] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "u32" + ], + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "u32" + ] + ], + "gt", + [] + |), + [ + eid; + M.alloc (| + M.read (| + end_eid + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + Value.StructTuple + "core::cmp::Ordering::Less" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::cmp::Ordering::Equal" + [] + |))) + ] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple [ Ty.path "u32"; Ty.path "u32" ]; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ M.read (| records |); M.read (| idx |) ] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::circuits::utils::table_entry::EventTableWithMemoryInfo" + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "specs::etable::EventTableEntry" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "specs::etable::EventTableEntry" ] + ] + ] + (Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo") + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "specs::etable::EventTableEntry" ], + [], + "map", + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "specs::etable::EventTableEntry" ] + ] + ] + (Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo") + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::etable::EventTableEntry" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::etable::EventTableEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::etable::EventTable", + "entries", + [] + |), + [ M.read (| event_table |) ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let eentry := M.copy (| γ |) in + Value.StructRecord + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo" + [ + ("eentry", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "specs::etable::EventTableEntry", + [], + "clone", + [] + |), + [ M.read (| eentry |) ] + |)); + ("memory_rw_entires", + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "specs::mtable::MemoryTableEntry" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "specs::mtable::MemoryTableEntry" + ] + ] + ] + (Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry") + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "specs::mtable::MemoryTableEntry" + ], + [], + "map", + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "specs::mtable::MemoryTableEntry" + ] + ] + ] + (Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry") + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "specs::mtable::MemoryTableEntry" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::mtable::MemoryTableEntry"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::runtime::memory_event_of_step", + [] + |), + [ M.read (| eentry |) ] + |) + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let mentry := + M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "u32" + ]; + Ty.path + "specs::mtable::LocationType"; + Ty.path + "u32"; + Ty.path + "bool" + ] + ] + ] + (Ty.tuple + [ + Ty.path + "u32"; + Ty.path + "u32" + ]), + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "u32" + ]; + Ty.path + "specs::mtable::LocationType"; + Ty.path + "u32"; + Ty.path + "bool" + ] + ] + ], + "call", + [] + |), + [ + lookup_mtable_eid; + Value.Tuple + [ + Value.Tuple + [ + M.SubPointer.get_struct_record_field (| + M.read (| + eentry + |), + "specs::etable::EventTableEntry", + "eid" + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + mentry + |), + "specs::mtable::MemoryTableEntry", + "ltype" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + mentry + |), + "specs::mtable::MemoryTableEntry", + "offset" + |) + |); + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "specs::mtable::AccessType", + [ + Ty.path + "specs::mtable::AccessType" + ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + mentry + |), + "specs::mtable::MemoryTableEntry", + "atype" + |); + M.alloc (| + Value.StructTuple + "specs::mtable::AccessType::Write" + [] + |) + ] + |) + ] + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + start_eid := + M.copy (| + γ0_0 + |) in + let end_eid := + M.copy (| + γ0_1 + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry" + [ + ("entry", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path + "specs::mtable::MemoryTableEntry", + [], + "clone", + [] + |), + [ + M.read (| + mentry + |) + ] + |)); + ("start_eid", + M.read (| + start_eid + |)); + ("end_eid", + M.read (| + end_eid + |)) + ] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |)) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + End Impl_delphinus_zkwasm_circuits_utils_table_entry_EventTableWithMemoryInfo. + End table_entry. + End utils. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/utils/u16.v b/CoqOfRust/zkWasm/circuits/utils/u16.v new file mode 100644 index 000000000..e1fb0a6b3 --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/utils/u16.v @@ -0,0 +1,458 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module utils. + Module u16. + (* StructRecord + { + name := "U16Column"; + ty_params := [ "F" ]; + fields := + [ + ("col", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + ("_mark", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_utils_u16_U16Column_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::utils::u16::U16Column") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::utils::u16::U16Column" + [ + ("col", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::u16::U16Column", + "col" + |) + ] + |)); + ("_mark", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::u16::U16Column", + "_mark" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_utils_u16_U16Column_F. + + Module Impl_delphinus_zkwasm_circuits_utils_u16_U16Column_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::utils::u16::U16Column") [ F ]. + + (* + pub fn configure( + meta: &mut ConstraintSystem, + cols: &mut impl Iterator>, + rtable: &RangeTableConfig, + enable: impl Fn(&mut VirtualCells<'_, F>) -> Expression, + ) -> Self { + let col = cols.next().unwrap(); + + rtable.configure_in_u16_range(meta, "u16", |meta| curr!(meta, col) * enable(meta)); + + Self { + col, + _mark: PhantomData, + } + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ + impl_Iterator_Item___Column_Advice__; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_ + ], + [ meta; cols; rtable; enable ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + let cols := M.alloc (| cols |) in + let rtable := M.alloc (| rtable |) in + let enable := M.alloc (| enable |) in + M.read (| + let col := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___Column_Advice__, + [], + "next", + [] + |), + [ M.read (| cols |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::rtable::RangeTableConfig") + [ F ], + "configure_in_u16_range", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]) + ] + |), + [ + M.read (| rtable |); + M.read (| meta |); + M.read (| Value.String "u16" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| col |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ enable; Value.Tuple [ M.read (| meta |) ] ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::utils::u16::U16Column" + [ + ("col", M.read (| col |)); + ("_mark", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure" (configure F). + + (* + pub fn assign(&self, ctx: &mut Context, value: u64) -> Result<(), Error> { + ctx.region + .assign_advice(|| "u16 value", self.col, ctx.offset, || Ok(value.into()))?; + + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let value := M.alloc (| value |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "halo2_proofs::plonk::error::Error" ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| Value.String "u16 value" |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::u16::U16Column", + "col" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| value |) ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_circuits_utils_u16_U16Column_F. + End u16. + End utils. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/utils/u8.v b/CoqOfRust/zkWasm/circuits/utils/u8.v new file mode 100644 index 000000000..6e963c9ef --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/utils/u8.v @@ -0,0 +1,458 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module utils. + Module u8. + (* StructRecord + { + name := "U8Column"; + ty_params := [ "F" ]; + fields := + [ + ("col", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + ("_mark", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_utils_u8_U8Column_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::utils::u8::U8Column") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::utils::u8::U8Column" + [ + ("col", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::u8::U8Column", + "col" + |) + ] + |)); + ("_mark", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::u8::U8Column", + "_mark" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_utils_u8_U8Column_F. + + Module Impl_delphinus_zkwasm_circuits_utils_u8_U8Column_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::utils::u8::U8Column") [ F ]. + + (* + pub fn configure( + meta: &mut ConstraintSystem, + cols: &mut impl Iterator>, + rtable: &RangeTableConfig, + enable: impl Fn(&mut VirtualCells<'_, F>) -> Expression, + ) -> Self { + let col = cols.next().unwrap(); + + rtable.configure_in_u8_range(meta, "u8", |meta| curr!(meta, col) * enable(meta)); + + Self { + col, + _mark: PhantomData, + } + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ + impl_Iterator_Item___Column_Advice__; + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_ + ], + [ meta; cols; rtable; enable ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + let cols := M.alloc (| cols |) in + let rtable := M.alloc (| rtable |) in + let enable := M.alloc (| enable |) in + M.read (| + let col := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___Column_Advice__, + [], + "next", + [] + |), + [ M.read (| cols |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::rtable::RangeTableConfig") + [ F ], + "configure_in_u8_range", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]) + ] + |), + [ + M.read (| rtable |); + M.read (| meta |); + M.read (| Value.String "u8" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| col |); + M.call_closure (| + M.get_associated_function (| + Ty.path "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn__mut_VirtualCells_'___F___arrow_Expression_F_, + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ enable; Value.Tuple [ M.read (| meta |) ] ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::utils::u8::U8Column" + [ + ("col", M.read (| col |)); + ("_mark", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure" (configure F). + + (* + pub fn assign(&self, ctx: &mut Context, value: u64) -> Result<(), Error> { + ctx.region + .assign_advice(|| "u8 value", self.col, ctx.offset, || Ok(value.into()))?; + + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let value := M.alloc (| value |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::circuit::Region") [ F ], + "assign_advice", + [ + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "core::result::Result") + [ F; Ty.path "halo2_proofs::plonk::error::Error" ]); + F; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "region" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| Value.String "u8 value" |))) + ] + |) + | _ => M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::utils::u8::U8Column", + "col" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| ctx |), + "delphinus_zkwasm::circuits::utils::Context", + "offset" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| value |) ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_circuits_utils_u8_U8Column_F. + End u8. + End utils. +End circuits. diff --git a/CoqOfRust/zkWasm/circuits/zkwasm_circuit/mod.v b/CoqOfRust/zkWasm/circuits/zkwasm_circuit/mod.v new file mode 100644 index 000000000..32131481d --- /dev/null +++ b/CoqOfRust/zkWasm/circuits/zkwasm_circuit/mod.v @@ -0,0 +1,29521 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module circuits. + Module zkwasm_circuit. + Definition value_VAR_COLUMNS : Value.t := + M.run + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use (M.alloc (| Value.Bool false |)) in + let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| Value.Integer 58 |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Integer 50 |))) + ] + |))). + + Definition value_RESERVE_ROWS : Value.t := + M.run + ltac:(M.monadic (M.get_constant (| "delphinus_zkwasm::circuits::bit_table::STEP_SIZE" |))). + + (* StructRecord + { + name := "AssignedCells"; + ty_params := [ "F" ]; + fields := + [ + ("pre_image_table_cells", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] ] + ] + ]; + Ty.path "alloc::alloc::Global" + ]); + ("post_image_table_cells", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] + ] + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ]); + ("mtable_rest_mops", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] ] + ]; + Ty.path "alloc::alloc::Global" + ]); + ("rest_memory_finalize_ops_cell", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] ] + ] + ]; + Ty.path "alloc::alloc::Global" + ]); + ("etable_cells", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ]); + ("rest_jops_cell_in_frame_table", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] ] + ]; + Ty.path "alloc::alloc::Global" + ]); + ("static_frame_entry_in_frame_table", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ]; + Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] + ] + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_core_default_Default_where_core_default_Default_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_zkwasm_circuit_AssignedCells_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells") [ F ]. + + (* Default *) + Definition default (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [] => + ltac:(M.monadic + (Value.StructRecord + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells" + [ + ("pre_image_table_cells", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "default", + [] + |), + [] + |)); + ("post_image_table_cells", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "default", + [] + |), + [] + |)); + ("mtable_rest_mops", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "default", + [] + |), + [] + |)); + ("rest_memory_finalize_ops_cell", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "default", + [] + |), + [] + |)); + ("etable_cells", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "default", + [] + |), + [] + |)); + ("rest_jops_cell_in_frame_table", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "default", + [] + |), + [] + |)); + ("static_frame_entry_in_frame_table", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "default", + [] + |), + [] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::default::Default" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("default", InstanceField.Method (default F)) ]. + End Impl_core_default_Default_where_core_default_Default_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_zkwasm_circuit_AssignedCells_F. + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_zkwasm_circuit_AssignedCells_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells" + [ + ("pre_image_table_cells", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "pre_image_table_cells" + |) + ] + |)); + ("post_image_table_cells", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "post_image_table_cells" + |) + ] + |)); + ("mtable_rest_mops", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "mtable_rest_mops" + |) + ] + |)); + ("rest_memory_finalize_ops_cell", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "rest_memory_finalize_ops_cell" + |) + ] + |)); + ("etable_cells", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "etable_cells" + |) + ] + |)); + ("rest_jops_cell_in_frame_table", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "rest_jops_cell_in_frame_table" + |) + ] + |)); + ("static_frame_entry_in_frame_table", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "static_frame_entry_in_frame_table" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_zkwasm_circuit_AssignedCells_F. + + (* StructRecord + { + name := "ZkWasmCircuitConfig"; + ty_params := [ "F" ]; + fields := + [ + ("rtable", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::rtable::RangeTableConfig") [ F ]); + ("image_table", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::image_table::ImageTableConfig") [ F ]); + ("post_image_table", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::post_image_table::PostImageTableConfig") + [ F ]); + ("mtable", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::mtable::MemoryTableConfig") [ F ]); + ("jtable", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::jtable::JumpTableConfig") [ F ]); + ("etable", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::etable::EventTableConfig") [ F ]); + ("bit_table", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableConfig") [ F ]); + ("external_host_call_table", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig") + [ F ]); + ("context_helper_table", + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig") + [ F ]); + ("foreign_table_from_zero_index", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]); + ("max_available_rows", Ty.path "usize"); + ("circuit_maximal_pages", Ty.path "u32"); + ("k", Ty.path "u32") + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_zkwasm_circuit_ZkWasmCircuitConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig") [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig" + [ + ("rtable", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::rtable::RangeTableConfig") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "rtable" + |) + ] + |)); + ("image_table", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::image_table::ImageTableConfig") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "image_table" + |) + ] + |)); + ("post_image_table", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::post_image_table::PostImageTableConfig") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "post_image_table" + |) + ] + |)); + ("mtable", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::mtable::MemoryTableConfig") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "mtable" + |) + ] + |)); + ("jtable", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "jtable" + |) + ] + |)); + ("etable", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::EventTableConfig") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "etable" + |) + ] + |)); + ("bit_table", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableConfig") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "bit_table" + |) + ] + |)); + ("external_host_call_table", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "external_host_call_table" + |) + ] + |)); + ("context_helper_table", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig") + [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "context_helper_table" + |) + ] + |)); + ("foreign_table_from_zero_index", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "foreign_table_from_zero_index" + |) + ] + |)); + ("max_available_rows", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "usize", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "max_available_rows" + |) + ] + |)); + ("circuit_maximal_pages", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "circuit_maximal_pages" + |) + ] + |)); + ("k", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "u32", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "k" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_circuits_zkwasm_circuit_ZkWasmCircuitConfig_F. + + Module Impl_halo2_proofs_plonk_circuit_Circuit_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_ZkWasmCircuit_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::ZkWasmCircuit") [ F ]. + + (* type Config = ZkWasmCircuitConfig; *) + Definition _Config (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig") [ F ]. + + (* type FloorPlanner = FlatFloorPlanner; *) + Definition _FloorPlanner (F : Ty.t) : Ty.t := + Ty.path "halo2_proofs::circuit::floor_planner::flat::FlatFloorPlanner". + + (* + fn without_witnesses(&self) -> Self { + ZkWasmCircuit::new( + self.k, + // fill slice like circuit_without_witness + Slice { + itable: self.slice.itable.clone(), + br_table: self.slice.br_table.clone(), + elem_table: self.slice.elem_table.clone(), + configure_table: self.slice.configure_table.clone(), + static_jtable: self.slice.static_jtable.clone(), + + etable: Arc::new(EventTable::default()), + frame_table: Arc::new(JumpTable::default()), + + imtable: self.slice.imtable.clone(), + post_imtable: self.slice.imtable.clone(), + + initialization_state: self.slice.initialization_state.clone(), + post_initialization_state: self.slice.initialization_state.clone(), + + is_last_slice: self.slice.is_last_slice, + }, + ) + .unwrap() + } + *) + Definition without_witnesses (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "delphinus_zkwasm::circuits::ZkWasmCircuit") [ F ]; + Ty.path "delphinus_zkwasm::error::BuildingCircuitError" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "delphinus_zkwasm::circuits::ZkWasmCircuit") [ F ], + "new", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "k" + |) + |); + Value.StructRecord + "specs::slice::Slice" + [ + ("itable", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::itable::InstructionTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "itable" + |) + ] + |)); + ("br_table", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ Ty.path "specs::brtable::BrTable"; Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "br_table" + |) + ] + |)); + ("elem_table", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::brtable::ElemTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "elem_table" + |) + ] + |)); + ("configure_table", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::configure_table::ConfigureTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "configure_table" + |) + ] + |)); + ("static_jtable", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::jtable::StaticFrameEntry" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "static_jtable" + |) + ] + |)); + ("etable", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::etable::EventTable"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.path "specs::etable::EventTable", + [], + "default", + [] + |), + [] + |) + ] + |)); + ("frame_table", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ Ty.path "specs::jtable::JumpTable"; Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.path "specs::jtable::JumpTable", + [], + "default", + [] + |), + [] + |) + ] + |)); + ("imtable", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::imtable::InitMemoryTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "imtable" + |) + ] + |)); + ("post_imtable", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::imtable::InitMemoryTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "imtable" + |) + ] + |)); + ("initialization_state", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ Ty.path "u32"; Ty.path "num_bigint::biguint::BigUint" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "initialization_state" + |) + ] + |)); + ("post_initialization_state", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ Ty.path "u32"; Ty.path "num_bigint::biguint::BigUint" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "initialization_state" + |) + ] + |)); + ("is_last_slice", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "is_last_slice" + |) + |)) + ] + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn configure(meta: &mut ConstraintSystem) -> Self::Config { + let k = zkwasm_k(); + + /* + * Allocate a column to enable assign_advice_from_constant. + */ + { + let constants = meta.fixed_column(); + meta.enable_constant(constants); + meta.enable_equality(constants); + } + + let memory_addr_sel = if cfg!(feature = "continuation") { + Some(meta.fixed_column()) + } else { + None + }; + + let foreign_table_from_zero_index = meta.fixed_column(); + + let mut cols = [(); VAR_COLUMNS].map(|_| meta.advice_column()).into_iter(); + + let rtable = RangeTableConfig::configure(meta); + let image_table = ImageTableConfig::configure(meta, memory_addr_sel); + let mtable = MemoryTableConfig::configure(meta, k, &mut cols, &rtable, &image_table); + let post_image_table = + PostImageTableConfig::configure(meta, memory_addr_sel, &mtable, &image_table); + let jtable = JumpTableConfig::configure(meta, &mut cols); + let external_host_call_table = ExternalHostCallTableConfig::configure(meta); + let bit_table = BitTableConfig::configure(meta, &rtable); + + let wasm_input_helper_table = + WasmInputHelperTableConfig::configure(meta, foreign_table_from_zero_index); + let context_helper_table = + ContextContHelperTableConfig::configure(meta, foreign_table_from_zero_index); + + let mut foreign_table_configs: BTreeMap<_, Box<(dyn ForeignTableConfig)>> = + BTreeMap::new(); + foreign_table_configs.insert( + WASM_INPUT_FOREIGN_TABLE_KEY, + Box::new(wasm_input_helper_table.clone()), + ); + foreign_table_configs.insert( + CONTEXT_FOREIGN_TABLE_KEY, + Box::new(context_helper_table.clone()), + ); + + let etable = EventTableConfig::configure( + meta, + k, + &mut cols, + &rtable, + &image_table, + &mtable, + &jtable, + &bit_table, + &external_host_call_table, + &foreign_table_configs, + ); + + assert_eq!(cols.count(), 0); + + let max_available_rows = (1 << k) - (meta.blinding_factors() + 1 + RESERVE_ROWS); + debug!("max_available_rows: {:?}", max_available_rows); + + let circuit_maximal_pages = compute_maximal_pages(k); + info!( + "Circuit K: {} supports up to {} pages.", + k, circuit_maximal_pages + ); + + Self::Config { + rtable, + image_table, + post_image_table, + mtable, + jtable, + etable, + bit_table, + external_host_call_table, + context_helper_table, + foreign_table_from_zero_index, + + max_available_rows, + circuit_maximal_pages, + + k, + } + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ meta ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + M.read (| + let k := + M.alloc (| + M.call_closure (| + M.get_function (| "delphinus_zkwasm::circuits::config::zkwasm_k", [] |), + [] + |) + |) in + let _ := + let constants := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "fixed_column", + [] + |), + [ M.read (| meta |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "enable_constant", + [] + |), + [ M.read (| meta |); M.read (| constants |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "enable_equality", + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ] + ] + |), + [ M.read (| meta |); M.read (| constants |) ] + |) + |) in + M.alloc (| Value.Tuple [] |) in + let memory_addr_sel := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use (M.alloc (| Value.Bool false |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "fixed_column", + [] + |), + [ M.read (| meta |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "core::option::Option::None" [] |))) + ] + |) + |) in + let foreign_table_from_zero_index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "fixed_column", + [] + |), + [ M.read (| meta |) ] + |) + |) in + let cols := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "array") [ Ty.tuple [] ], + "map", + [ + Ty.function + [ Ty.tuple [ Ty.tuple [] ] ] + (Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ] + |), + [ + repeat (Value.Tuple []) 50; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "advice_column", + [] + |), + [ M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let rtable := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::rtable::RangeTableConfig") + [ F ], + "configure", + [] + |), + [ M.read (| meta |) ] + |) + |) in + let image_table := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::image_table::ImageTableConfig") + [ F ], + "configure", + [] + |), + [ M.read (| meta |); M.read (| memory_addr_sel |) ] + |) + |) in + let mtable := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::mtable::MemoryTableConfig") + [ F ], + "configure", + [ + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ] + ] + |), + [ M.read (| meta |); M.read (| k |); cols; rtable; image_table ] + |) + |) in + let post_image_table := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::post_image_table::PostImageTableConfig") + [ F ], + "configure", + [] + |), + [ M.read (| meta |); M.read (| memory_addr_sel |); mtable; image_table ] + |) + |) in + let jtable := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::jtable::JumpTableConfig") + [ F ], + "configure", + [ + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ] + ] + |), + [ M.read (| meta |); cols ] + |) + |) in + let external_host_call_table := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallTableConfig") + [ F ], + "configure", + [] + |), + [ M.read (| meta |) ] + |) + |) in + let bit_table := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableConfig") + [ F ], + "configure", + [] + |), + [ M.read (| meta |); rtable ] + |) + |) in + let wasm_input_helper_table := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::circuits::WasmInputHelperTableConfig") + [ F ], + "configure", + [] + |), + [ M.read (| meta |); M.read (| foreign_table_from_zero_index |) ] + |) + |) in + let context_helper_table := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig") + [ F ], + "configure", + [] + |), + [ M.read (| meta |); M.read (| foreign_table_from_zero_index |) ] + |) + |) in + let foreign_table_configs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + foreign_table_configs; + M.read (| + M.get_constant (| + "delphinus_zkwasm::foreign::wasm_input_helper::circuits::WASM_INPUT_FOREIGN_TABLE_KEY" + |) + |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::circuits::WasmInputHelperTableConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::circuits::WasmInputHelperTableConfig") + [ F ], + [], + "clone", + [] + |), + [ wasm_input_helper_table ] + |) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.apply (Ty.path "&") [ Ty.path "str" ]; + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::foreign::ForeignTableConfig::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + foreign_table_configs; + M.read (| + M.get_constant (| + "delphinus_zkwasm::foreign::context::circuits::CONTEXT_FOREIGN_TABLE_KEY" + |) + |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig") + [ F ], + [], + "clone", + [] + |), + [ context_helper_table ] + |) + ] + |)) + ] + |) + |) in + let etable := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::EventTableConfig") + [ F ], + "configure", + [ + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ] + ] + |), + [ + M.read (| meta |); + M.read (| k |); + cols; + rtable; + image_table; + mtable; + jtable; + bit_table; + external_host_call_table; + foreign_table_configs + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::array::iter::IntoIter") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ], + [], + "count", + [] + |), + [ M.read (| cols |) ] + |) + |); + M.alloc (| Value.Integer 0 |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let max_available_rows := + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + BinOp.Panic.shl (| Value.Integer 1, M.read (| k |) |), + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") + [ F ], + "blinding_factors", + [] + |), + [ M.read (| meta |) ] + |), + Value.Integer 1 + |), + M.read (| + M.get_constant (| + "delphinus_zkwasm::circuits::zkwasm_circuit::RESERVE_ROWS" + |) + |) + |) + |) + |) in + let _ := + let lvl := M.alloc (| Value.StructTuple "log::Level::Debug" [] |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ lvl; M.get_constant (| "log::STATIC_MAX_LEVEL" |) ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ + lvl; + M.alloc (| + M.call_closure (| + M.get_function (| "log::max_level", [] |), + [] + |) + |) + ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| "log::__private_api::log", [ Ty.tuple [] ] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ M.read (| Value.String "max_available_rows: " |) ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ Ty.path "usize" ] + |), + [ max_available_rows ] + |) + ] + |)) + ] + |); + M.read (| lvl |); + M.alloc (| + Value.Tuple + [ + M.read (| + Value.String "delphinus_zkwasm::circuits::zkwasm_circuit" + |); + M.read (| + Value.String "delphinus_zkwasm::circuits::zkwasm_circuit" + |); + M.read (| + Value.String + "crates/zkwasm/src/circuits/zkwasm_circuit/mod.rs" + |) + ] + |); + Value.Integer 199; + Value.Tuple [] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let circuit_maximal_pages := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::image_table::compute_maximal_pages", + [] + |), + [ M.read (| k |) ] + |) + |) in + let _ := + let lvl := M.alloc (| Value.StructTuple "log::Level::Info" [] |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ lvl; M.get_constant (| "log::STATIC_MAX_LEVEL" |) ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ + lvl; + M.alloc (| + M.call_closure (| + M.get_function (| "log::max_level", [] |), + [] + |) + |) + ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| "log::__private_api::log", [ Ty.tuple [] ] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "Circuit K: " |); + M.read (| Value.String " supports up to " |); + M.read (| Value.String " pages." |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "u32" ] + |), + [ k ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "u32" ] + |), + [ circuit_maximal_pages ] + |) + ] + |)) + ] + |); + M.read (| lvl |); + M.alloc (| + Value.Tuple + [ + M.read (| + Value.String "delphinus_zkwasm::circuits::zkwasm_circuit" + |); + M.read (| + Value.String "delphinus_zkwasm::circuits::zkwasm_circuit" + |); + M.read (| + Value.String + "crates/zkwasm/src/circuits/zkwasm_circuit/mod.rs" + |) + ] + |); + Value.Integer 202; + Value.Tuple [] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig" + [ + ("rtable", M.read (| rtable |)); + ("image_table", M.read (| image_table |)); + ("post_image_table", M.read (| post_image_table |)); + ("mtable", M.read (| mtable |)); + ("jtable", M.read (| jtable |)); + ("etable", M.read (| etable |)); + ("bit_table", M.read (| bit_table |)); + ("external_host_call_table", M.read (| external_host_call_table |)); + ("context_helper_table", M.read (| context_helper_table |)); + ("foreign_table_from_zero_index", M.read (| foreign_table_from_zero_index |)); + ("max_available_rows", M.read (| max_available_rows |)); + ("circuit_maximal_pages", M.read (| circuit_maximal_pages |)); + ("k", M.read (| k |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + fn synthesize(&self, config: Self::Config, layouter: impl Layouter) -> Result<(), Error> { + let assign_timer = start_timer!(|| "Assign"); + + let rchip = RangeTableChip::new(config.rtable); + let image_chip = ImageTableChip::new(config.image_table); + let post_image_chip = PostImageTableChip::new(config.post_image_table); + let mchip = MemoryTableChip::new(config.mtable, config.max_available_rows); + let frame_table_chip = JumpTableChip::new(config.jtable, config.max_available_rows); + let echip = EventTableChip::new( + config.etable, + compute_slice_capability(self.k) as usize, + config.max_available_rows, + ); + let bit_chip = BitTableChip::new(config.bit_table, config.max_available_rows); + let external_host_call_chip = + ExternalHostCallChip::new(config.external_host_call_table, config.max_available_rows); + let context_chip = ContextContHelperTableChip::new(config.context_helper_table); + + let image_table_assigner = ImageTableAssigner::new( + // Add one for default lookup value + self.slice.itable.len() + 1, + self.slice.br_table.entries().len() + self.slice.elem_table.entries().len() + 1, + config.circuit_maximal_pages, + ); + + let memory_writing_table: MemoryWritingTable = MemoryWritingTable::from( + config.k, + self.slice.create_memory_table(memory_event_of_step), + ); + + let etable = exec_with_profile!( + || "Prepare memory info for etable", + EventTableWithMemoryInfo::new(&self.slice.etable, &memory_writing_table,) + ); + + let assigned_cells = AssignedCells::default(); + + let layouter_cloned = layouter.clone(); + let assigned_cells_cloned = assigned_cells.clone(); + + rayon::scope(move |s| { + let memory_writing_table = Arc::new(memory_writing_table); + let etable = Arc::new(etable); + + let _layouter = layouter.clone(); + s.spawn(move |_| { + exec_with_profile!( + || "Init range chip", + rchip.init(_layouter, config.k).unwrap() + ); + }); + + let _layouter = layouter.clone(); + s.spawn(move |_| { + exec_with_profile!( + || "Init foreign table index", + _layouter + .assign_region( + || "foreign helper", + |region| { + for offset in 0..foreign_table_enable_lines(config.k) { + region.assign_fixed( + || "foreign table from zero index", + config.foreign_table_from_zero_index, + offset, + || Ok(F::from(offset as u64)), + )?; + } + + Ok(()) + }, + ) + .unwrap() + ); + }); + + let _layouter = layouter.clone(); + let _etable = etable.clone(); + s.spawn(move |_| { + exec_with_profile!( + || "Assign bit table", + bit_chip + .assign(_layouter, _etable.filter_bit_table_entries()) + .unwrap() + ); + }); + + let _layouter = layouter.clone(); + s.spawn(move |_| { + exec_with_profile!( + || "Assign external host call table", + external_host_call_chip + .assign( + _layouter, + &self.slice.etable.filter_external_host_call_table(), + ) + .unwrap() + ); + }); + + let _layouter = layouter.clone(); + s.spawn(move |_| { + exec_with_profile!( + || "Assign context cont chip", + context_chip + .assign( + _layouter, + &self.slice.etable.get_context_inputs(), + &self.slice.etable.get_context_outputs() + ) + .unwrap() + ); + }); + + let _layouter = layouter.clone(); + let _assigned_cells = assigned_cells.clone(); + s.spawn(move |_| { + let pre_image_table = self.slice.encode_pre_compilation_table_values(config.k); + + let cells = exec_with_profile!( + || "Assign pre image table chip", + image_chip + .assign(_layouter, &image_table_assigner, pre_image_table) + .unwrap() + ); + + *_assigned_cells.pre_image_table_cells.lock().unwrap() = Some(cells); + }); + + let _layouter = layouter.clone(); + let _assigned_cells = assigned_cells.clone(); + let _memory_writing_table = memory_writing_table.clone(); + s.spawn(move |_| { + let post_image_table: ImageTableLayouter = + self.slice.encode_post_compilation_table_values(config.k); + + let (rest_memory_writing_ops, memory_finalized_set) = + _memory_writing_table.count_rest_memory_finalize_ops(); + + let cells = post_image_chip + .assign( + _layouter, + &image_table_assigner, + post_image_table, + rest_memory_writing_ops, + memory_finalized_set, + ) + .unwrap(); + + *_assigned_cells.post_image_table_cells.lock().unwrap() = Some(cells); + }); + + let _layouter = layouter.clone(); + let _assigned_cells = assigned_cells.clone(); + s.spawn(move |_| { + exec_with_profile!(|| "Assign frame table", { + let (rest_jops_cell, static_frame_entry_cells) = frame_table_chip + .assign( + _layouter, + &self.slice.static_jtable, + &self.slice.frame_table, + ) + .unwrap(); + + *_assigned_cells + .rest_jops_cell_in_frame_table + .lock() + .unwrap() = Some(rest_jops_cell); + *_assigned_cells + .static_frame_entry_in_frame_table + .lock() + .unwrap() = Some(static_frame_entry_cells); + }); + }); + + let _layouter = layouter.clone(); + let _assigned_cells = assigned_cells.clone(); + s.spawn(move |_| { + exec_with_profile!(|| "Assign mtable", { + let (rest_mops, rest_memory_finalize_ops_cell) = + mchip.assign(_layouter, &memory_writing_table).unwrap(); + + *_assigned_cells.mtable_rest_mops.lock().unwrap() = Some(rest_mops); + *_assigned_cells + .rest_memory_finalize_ops_cell + .lock() + .unwrap() = Some(rest_memory_finalize_ops_cell); + }); + }); + + let _layouter = layouter.clone(); + let _assigned_cells = assigned_cells.clone(); + s.spawn(move |_| { + exec_with_profile!(|| "Assign etable", { + let cells = echip + .assign( + _layouter, + &self.slice.itable, + &etable, + &self.slice.configure_table, + &self.slice.initialization_state, + &self.slice.post_initialization_state, + self.slice.is_last_slice, + ) + .unwrap(); + + *_assigned_cells.etable_cells.lock().unwrap() = Some(cells); + }); + }); + }); + + macro_rules! into_inner { + ($arc:ident) => { + let $arc = Arc::try_unwrap(assigned_cells_cloned.$arc) + .unwrap() + .into_inner() + .unwrap() + .unwrap(); + }; + } + + into_inner!(static_frame_entry_in_frame_table); + into_inner!(etable_cells); + into_inner!(mtable_rest_mops); + into_inner!(rest_memory_finalize_ops_cell); + into_inner!(pre_image_table_cells); + into_inner!(post_image_table_cells); + into_inner!(rest_jops_cell_in_frame_table); + /* + * Permutation between chips + * + */ + layouter_cloned.assign_region( + || "permutation between tables", + |region| { + // 1. static frame entries + // 1.1. between frame table and pre image table + for (left, right) in static_frame_entry_in_frame_table + .iter() + .zip(pre_image_table_cells.static_frame_entries.iter()) + { + // enable + region.constrain_equal(left.0.cell(), right.0.cell())?; + // entry + region.constrain_equal(left.1.cell(), right.1.cell())?; + } + + // 1.2 (if continuation) between frame table and post image table + if let Some((post_image_table_cells, _)) = post_image_table_cells.as_ref() { + for (left, right) in static_frame_entry_in_frame_table + .iter() + .zip(post_image_table_cells.static_frame_entries.iter()) + { + // enable + region.constrain_equal(left.0.cell(), right.0.cell())?; + // entry + region.constrain_equal(left.1.cell(), right.1.cell())?; + } + } + + // 2. rest jops + // 2.1 (if not continuation) rest_jops between event chip and frame chip + if let Some(rest_jops_in_event_chip) = etable_cells.rest_jops.as_ref() { + region.constrain_equal( + rest_jops_in_event_chip.cell(), + rest_jops_cell_in_frame_table.cell(), + )?; + } + + // 2.2 (if continuation and last slice circuit) rest_jops between post image chip and frame chip + #[cfg(feature = "continuation")] + if self.slice.is_last_slice { + if let Some((assigned_post_image_table_cells, _)) = + post_image_table_cells.as_ref() + { + region.constrain_equal( + assigned_post_image_table_cells + .initialization_state + .jops + .cell(), + rest_jops_cell_in_frame_table.cell(), + )?; + } + } + + // 3. rest_mops between event chip and memory chip + region.constrain_equal(etable_cells.rest_mops.cell(), mtable_rest_mops.cell())?; + + // 4. (if continuation) memory finalized count between memory chip and post image chip + if let Some((_, rest_memory_finalized_ops_in_post_image_table)) = + post_image_table_cells.as_ref() + { + region.constrain_equal( + rest_memory_finalized_ops_in_post_image_table.cell(), + rest_memory_finalize_ops_cell.as_ref().unwrap().cell(), + )?; + } + + // 5. initialization state + // 5.1 between event chip and pre image chip + etable_cells + .pre_initialization_state + .zip_for_each(&pre_image_table_cells.initialization_state, |l, r| { + region.constrain_equal(l.cell(), r.cell()) + })?; + + // 5.2 (if continuation) between event chip and post image chip + if let Some((post_image_table_cells, _)) = post_image_table_cells.as_ref() { + etable_cells + .post_initialization_state + .zip_for_each(&post_image_table_cells.initialization_state, |l, r| { + region.constrain_equal(l.cell(), r.cell()) + })?; + } + + // 6. fixed part(instructions, br_tables, padding) within pre image chip and post image chip + if let Some((post_image_table_cells, _)) = post_image_table_cells.as_ref() { + for (l, r) in pre_image_table_cells + .instructions + .iter() + .zip(post_image_table_cells.instructions.iter()) + { + region.constrain_equal(l.cell(), r.cell())?; + } + + for (l, r) in pre_image_table_cells + .br_table_entires + .iter() + .zip(post_image_table_cells.br_table_entires.iter()) + { + region.constrain_equal(l.cell(), r.cell())?; + } + + for (l, r) in pre_image_table_cells + .padding_entires + .iter() + .zip(post_image_table_cells.padding_entires.iter()) + { + region.constrain_equal(l.cell(), r.cell())?; + } + } + + Ok(()) + }, + )?; + + end_timer!(assign_timer); + + Ok(()) + } + *) + Definition synthesize (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Layouter_F_ ], [ self; config; layouter ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let config := M.alloc (| config |) in + let layouter := M.alloc (| layouter |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let assign_timer := + M.copy (| + let msg := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]), + [ Ty.tuple [] ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic (M.read (| Value.String "Assign" |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + Value.Tuple [] + ] + |) + |) in + let start_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [], + "yellow", + [] + |), + [ M.read (| Value.String "Start:" |) ] + |) + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| "ark_std::perf_trace::inner::NUM_INDENT" |) + |); + Value.Integer 0; + Value.StructTuple "core::sync::atomic::Ordering::Relaxed" [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| "ark_std::perf_trace::inner::compute_indent", [] |), + [ M.read (| indent_amount |) ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| "std::io::stdio::_print", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "" |); + M.read (| Value.String "" |); + M.read (| Value.String " " |); + M.read (| Value.String " +" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "alloc::string::String" ] + |), + [ indent ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "colored::ColoredString" ] + |), + [ start_info ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ msg ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 0; + Value.UnicodeChar 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple "core::fmt::rt::Count::Implied" [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 1; + Value.UnicodeChar 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ Value.Integer 8 ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 2; + Value.UnicodeChar 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple "core::fmt::rt::Count::Implied" [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| "ark_std::perf_trace::inner::NUM_INDENT" |) + |); + Value.Integer 1; + Value.StructTuple "core::sync::atomic::Ordering::Relaxed" [] + ] + |) + |) in + M.alloc (| + Value.StructRecord + "ark_std::perf_trace::inner::TimerInfo" + [ + ("msg", + M.call_closure (| + M.get_trait_method (| + "alloc::string::ToString", + Ty.path "str", + [], + "to_string", + [] + |), + [ M.read (| msg |) ] + |)); + ("time", + M.call_closure (| + M.get_associated_function (| + Ty.path "std::time::Instant", + "now", + [] + |), + [] + |)) + ] + |) + |) in + let rchip := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::rtable::RangeTableChip") + [ F ], + "new", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "rtable" + |) + |) + ] + |) + |) in + let image_chip := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::image_table::ImageTableChip") + [ F ], + "new", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "image_table" + |) + |) + ] + |) + |) in + let post_image_chip := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::post_image_table::PostImageTableChip") + [ F ], + "new", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "post_image_table" + |) + |) + ] + |) + |) in + let mchip := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::mtable::MemoryTableChip") + [ F ], + "new", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "mtable" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "max_available_rows" + |) + |) + ] + |) + |) in + let frame_table_chip := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::jtable::JumpTableChip") + [ F ], + "new", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "jtable" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "max_available_rows" + |) + |) + ] + |) + |) in + let echip := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::etable::EventTableChip") + [ F ], + "new", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "etable" + |) + |); + M.rust_cast + (M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::compute_slice_capability", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "k" + |) + |) + ] + |)); + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "max_available_rows" + |) + |) + ] + |) + |) in + let bit_chip := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::bit_table::BitTableChip") + [ F ], + "new", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "bit_table" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "max_available_rows" + |) + |) + ] + |) + |) in + let external_host_call_chip := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallChip") + [ F ], + "new", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "external_host_call_table" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "max_available_rows" + |) + |) + ] + |) + |) in + let context_chip := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::context::circuits::assign::ContextContHelperTableChip") + [ F ], + "new", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "context_helper_table" + |) + |) + ] + |) + |) in + let image_table_assigner := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableAssigner", + "new", + [] + |), + [ + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::InstructionTable", + "len", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::itable::InstructionTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "itable" + |) + ] + |) + ] + |), + Value.Integer 1 + |); + BinOp.Panic.add (| + Integer.Usize, + BinOp.Panic.add (| + Integer.Usize, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::brtable::BrTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::brtable::BrTable", + "entries", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::brtable::BrTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "br_table" + |) + ] + |) + ] + |) + ] + |), + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::brtable::ElemEntry"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::brtable::ElemTable", + "entries", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::brtable::ElemTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "elem_table" + |) + ] + |) + ] + |) + ] + |) + |), + Value.Integer 1 + |); + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "circuit_maximal_pages" + |) + |) + ] + |) + |) in + let memory_writing_table := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable", + "from", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "k" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::slice::Slice", + "create_memory_table", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |); + (* ReifyFnPointer *) + M.pointer_coercion + (M.get_function (| + "delphinus_zkwasm::runtime::memory_event_of_step", + [] + |)) + ] + |) + ] + |) + |) in + let etable := + M.copy (| + let timer := + M.copy (| + let msg := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]), + [ Ty.tuple [] ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String "Prepare memory info for etable" + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + Value.Tuple [] + ] + |) + |) in + let start_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [], + "yellow", + [] + |), + [ M.read (| Value.String "Start:" |) ] + |) + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| "ark_std::perf_trace::inner::NUM_INDENT" |) + |); + Value.Integer 0; + Value.StructTuple "core::sync::atomic::Ordering::Relaxed" [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| + "ark_std::perf_trace::inner::compute_indent", + [] + |), + [ M.read (| indent_amount |) ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| "std::io::stdio::_print", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "" |); + M.read (| Value.String "" |); + M.read (| Value.String " " |); + M.read (| Value.String " +" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "alloc::string::String" ] + |), + [ indent ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "colored::ColoredString" ] + |), + [ start_info ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ msg ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 0; + Value.UnicodeChar 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 1; + Value.UnicodeChar 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ Value.Integer 8 ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 2; + Value.UnicodeChar 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| "ark_std::perf_trace::inner::NUM_INDENT" |) + |); + Value.Integer 1; + Value.StructTuple "core::sync::atomic::Ordering::Relaxed" [] + ] + |) + |) in + M.alloc (| + Value.StructRecord + "ark_std::perf_trace::inner::TimerInfo" + [ + ("msg", + M.call_closure (| + M.get_trait_method (| + "alloc::string::ToString", + Ty.path "str", + [], + "to_string", + [] + |), + [ M.read (| msg |) ] + |)); + ("time", + M.call_closure (| + M.get_associated_function (| + Ty.path "std::time::Instant", + "now", + [] + |), + [] + |)) + ] + |) + |) in + let r := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableWithMemoryInfo", + "new", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::etable::EventTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "etable" + |) + ] + |); + memory_writing_table + ] + |) + |) in + let _ := + let _ := + let time := + M.copy (| + M.SubPointer.get_struct_record_field (| + timer, + "ark_std::perf_trace::inner::TimerInfo", + "time" + |) + |) in + let final_time := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "std::time::Instant", + "elapsed", + [] + |), + [ time ] + |) + |) in + let final_time := + M.copy (| + let secs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::time::Duration", + "as_secs", + [] + |), + [ final_time ] + |) + |) in + let millis := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::time::Duration", + "subsec_millis", + [] + |), + [ final_time ] + |) + |) in + let micros := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path "core::time::Duration", + "subsec_micros", + [] + |), + [ final_time ] + |), + Value.Integer 1000 + |) + |) in + let nanos := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path "core::time::Duration", + "subsec_nanos", + [] + |), + [ final_time ] + |), + Value.Integer 1000 + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne (M.read (| secs |)) (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "alloc::string::String", + [], + "deref", + [] + |), + [ + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "" |); + M.read (| Value.String "." |); + M.read (| Value.String "s" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "u64" ] + |), + [ secs ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "u32" ] + |), + [ millis ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 0; + Value.UnicodeChar 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 1; + Value.UnicodeChar 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ Value.Integer 3 ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| millis |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "alloc::string::String", + [], + "deref", + [] + |), + [ + let res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String "" + |); + M.read (| + Value.String "." + |); + M.read (| + Value.String "ms" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "u32" ] + |), + [ millis ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "u32" ] + |), + [ micros ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ Value.Integer 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| micros |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path "&") + [ Ty.path "str" ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "alloc::string::String", + [], + "deref", + [] + |), + [ + let res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + (String.String + "181" + "s") + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ micros ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ nanos ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path "&") + [ Ty.path "str" ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "alloc::string::String", + [], + "deref", + [] + |), + [ + let res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "ns" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_nanos", + [] + |), + [ + final_time + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + |) in + let end_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [], + "green", + [] + |), + [ M.read (| Value.String "End:" |) ] + |) + ] + |) + |) in + let message := + M.copy (| + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "" |); + M.read (| Value.String " " |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "alloc::string::String" ] + |), + [ + M.SubPointer.get_struct_record_field (| + timer, + "ark_std::perf_trace::inner::TimerInfo", + "msg" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]), + [ Ty.tuple [] ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String "" + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + Value.Tuple [] + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::sync::atomic::AtomicUsize", + "fetch_sub", + [] + |), + [ + M.read (| + M.get_constant (| "ark_std::perf_trace::inner::NUM_INDENT" |) + |); + Value.Integer 1; + Value.StructTuple "core::sync::atomic::Ordering::Relaxed" [] + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| "ark_std::perf_trace::inner::NUM_INDENT" |) + |); + Value.Integer 0; + Value.StructTuple "core::sync::atomic::Ordering::Relaxed" [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| + "ark_std::perf_trace::inner::compute_indent", + [] + |), + [ M.read (| indent_amount |) ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| "std::io::stdio::_print", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "" |); + M.read (| Value.String "" |); + M.read (| Value.String " " |); + M.read (| Value.String "" |); + M.read (| Value.String " +" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "alloc::string::String" ] + |), + [ indent ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "colored::ColoredString" ] + |), + [ end_info ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "alloc::string::String" ] + |), + [ message ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "colored::ColoredString" ] + |), + [ final_time ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "from_usize", + [] + |), + [ + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + Value.Integer 75, + M.read (| indent_amount |) + |) + |) + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 0; + Value.UnicodeChar 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 1; + Value.UnicodeChar 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ Value.Integer 8 ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 2; + Value.UnicodeChar 46; + Value.StructTuple + "core::fmt::rt::Alignment::Left" + []; + Value.Integer 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Param" + [ Value.Integer 4 ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 3; + Value.UnicodeChar 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) in + M.alloc (| Value.Tuple [] |) in + M.alloc (| Value.Tuple [] |) in + r + |) in + let assigned_cells := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells") + [ F ], + [], + "default", + [] + |), + [] + |) + |) in + let layouter_cloned := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + impl_Layouter_F_, + [], + "clone", + [] + |), + [ layouter ] + |) + |) in + let assigned_cells_cloned := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells") + [ F ], + [], + "clone", + [] + |), + [ assigned_cells ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "rayon_core::scope::scope", + [ + Ty.function + [ + Ty.tuple + [ Ty.apply (Ty.path "&") [ Ty.path "rayon_core::scope::Scope" ] ] + ] + (Ty.tuple []); + Ty.tuple [] + ] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let s := M.copy (| γ |) in + M.read (| + let memory_writing_table := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| memory_writing_table |) ] + |) + |) in + let etable := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableWithMemoryInfo"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| etable |) ] + |) + |) in + let _layouter := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + impl_Layouter_F_, + [], + "clone", + [] + |), + [ layouter ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "rayon_core::scope::Scope", + "spawn", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "rayon_core::scope::Scope" + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.read (| s |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let _ := + let timer := + M.copy (| + let msg := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]), + [ Ty.tuple [] ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "Init range chip" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + Value.Tuple [] + ] + |) + |) in + let start_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path + "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "yellow", + [] + |), + [ + M.read (| + Value.String + "Start:" + |) + ] + |) + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer + 0; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| + "ark_std::perf_trace::inner::compute_indent", + [] + |), + [ + M.read (| + indent_amount + |) + ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "std::io::stdio::_print", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + indent + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + start_info + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + msg + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 8 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 2; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer 1; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) in + M.alloc (| + Value.StructRecord + "ark_std::perf_trace::inner::TimerInfo" + [ + ("msg", + M.call_closure (| + M.get_trait_method (| + "alloc::string::ToString", + Ty.path + "str", + [], + "to_string", + [] + |), + [ + M.read (| + msg + |) + ] + |)); + ("time", + M.call_closure (| + M.get_associated_function (| + Ty.path + "std::time::Instant", + "now", + [] + |), + [] + |)) + ] + |) + |) in + let r := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::rtable::RangeTableChip") + [ F ], + "init", + [ + impl_Layouter_F_ + ] + |), + [ + rchip; + M.read (| + _layouter + |); + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "k" + |) + |) + ] + |) + ] + |) + |) in + let _ := + let _ := + let time := + M.copy (| + M.SubPointer.get_struct_record_field (| + timer, + "ark_std::perf_trace::inner::TimerInfo", + "time" + |) + |) in + let final_time := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "std::time::Instant", + "elapsed", + [] + |), + [ time ] + |) + |) in + let final_time := + M.copy (| + let secs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "as_secs", + [] + |), + [ final_time ] + |) + |) in + let millis := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_millis", + [] + |), + [ final_time ] + |) + |) in + let micros := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_micros", + [] + |), + [ final_time + ] + |), + Value.Integer + 1000 + |) + |) in + let nanos := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_nanos", + [] + |), + [ final_time + ] + |), + Value.Integer + 1000 + |) + |) in + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.read (| + secs + |)) + (Value.Integer + 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + "s" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u64" + ] + |), + [ + secs + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + millis + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| + millis + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + "ms" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + millis + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + micros + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| + micros + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + (String.String + "181" + "s") + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + micros + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + nanos + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "ns" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_nanos", + [] + |), + [ + final_time + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + |) in + let end_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path + "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "green", + [] + |), + [ + M.read (| + Value.String + "End:" + |) + ] + |) + ] + |) + |) in + let message := + M.copy (| + let res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + timer, + "ark_std::perf_trace::inner::TimerInfo", + "msg" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]), + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + Value.Tuple + [] + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_sub", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer 1; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer + 0; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| + "ark_std::perf_trace::inner::compute_indent", + [] + |), + [ + M.read (| + indent_amount + |) + ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "std::io::stdio::_print", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + indent + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + end_info + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + message + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + final_time + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "from_usize", + [] + |), + [ + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + Value.Integer + 75, + M.read (| + indent_amount + |) + |) + |) + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 8 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 2; + Value.UnicodeChar + 46; + Value.StructTuple + "core::fmt::rt::Alignment::Left" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Param" + [ + Value.Integer + 4 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 3; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) in + M.alloc (| + Value.Tuple [] + |) in + M.alloc (| + Value.Tuple [] + |) in + r in + M.alloc (| Value.Tuple [] |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _layouter := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + impl_Layouter_F_, + [], + "clone", + [] + |), + [ layouter ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "rayon_core::scope::Scope", + "spawn", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "rayon_core::scope::Scope" + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.read (| s |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let _ := + let timer := + M.copy (| + let msg := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]), + [ Ty.tuple [] ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "Init foreign table index" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + Value.Tuple [] + ] + |) + |) in + let start_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path + "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "yellow", + [] + |), + [ + M.read (| + Value.String + "Start:" + |) + ] + |) + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer + 0; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| + "ark_std::perf_trace::inner::compute_indent", + [] + |), + [ + M.read (| + indent_amount + |) + ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "std::io::stdio::_print", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + indent + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + start_info + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + msg + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 8 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 2; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer 1; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) in + M.alloc (| + Value.StructRecord + "ark_std::perf_trace::inner::TimerInfo" + [ + ("msg", + M.call_closure (| + M.get_trait_method (| + "alloc::string::ToString", + Ty.path + "str", + [], + "to_string", + [] + |), + [ + M.read (| + msg + |) + ] + |)); + ("time", + M.call_closure (| + M.get_associated_function (| + Ty.path + "std::time::Instant", + "now", + [] + |), + [] + |)) + ] + |) + |) in + let r := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::Layouter", + impl_Layouter_F_, + [ F ], + "assign_region", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ + F + ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + Ty.tuple []; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + _layouter; + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "foreign helper" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (let + region := + M.copy (| + γ + |) in + M.read (| + let + _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "usize" + ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", + Value.Integer + 0); + ("end_", + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::foreign::foreign_table_enable_lines", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "k" + |) + |) + ] + |)) + ] + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + iter := + M.copy (| + γ + |) in + M.loop (| + ltac:(M.monadic + (let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ + Ty.path + "usize" + ], + [], + "next", + [] + |), + [ + iter + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let + offset := + M.copy (| + γ0_0 + |) in + let + _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ + F + ], + "assign_fixed", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + region + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "foreign table from zero index" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "foreign_table_from_zero_index" + |) + |); + M.read (| + offset + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + offset + |)) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun + γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + |))) + ] + |)) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.Tuple + [] + ] + |) + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |) in + let _ := + let _ := + let time := + M.copy (| + M.SubPointer.get_struct_record_field (| + timer, + "ark_std::perf_trace::inner::TimerInfo", + "time" + |) + |) in + let final_time := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "std::time::Instant", + "elapsed", + [] + |), + [ time ] + |) + |) in + let final_time := + M.copy (| + let secs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "as_secs", + [] + |), + [ final_time ] + |) + |) in + let millis := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_millis", + [] + |), + [ final_time ] + |) + |) in + let micros := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_micros", + [] + |), + [ final_time + ] + |), + Value.Integer + 1000 + |) + |) in + let nanos := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_nanos", + [] + |), + [ final_time + ] + |), + Value.Integer + 1000 + |) + |) in + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.read (| + secs + |)) + (Value.Integer + 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + "s" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u64" + ] + |), + [ + secs + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + millis + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| + millis + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + "ms" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + millis + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + micros + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| + micros + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + (String.String + "181" + "s") + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + micros + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + nanos + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "ns" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_nanos", + [] + |), + [ + final_time + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + |) in + let end_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path + "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "green", + [] + |), + [ + M.read (| + Value.String + "End:" + |) + ] + |) + ] + |) + |) in + let message := + M.copy (| + let res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + timer, + "ark_std::perf_trace::inner::TimerInfo", + "msg" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]), + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + Value.Tuple + [] + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_sub", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer 1; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer + 0; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| + "ark_std::perf_trace::inner::compute_indent", + [] + |), + [ + M.read (| + indent_amount + |) + ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "std::io::stdio::_print", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + indent + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + end_info + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + message + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + final_time + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "from_usize", + [] + |), + [ + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + Value.Integer + 75, + M.read (| + indent_amount + |) + |) + |) + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 8 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 2; + Value.UnicodeChar + 46; + Value.StructTuple + "core::fmt::rt::Alignment::Left" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Param" + [ + Value.Integer + 4 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 3; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) in + M.alloc (| + Value.Tuple [] + |) in + M.alloc (| + Value.Tuple [] + |) in + r in + M.alloc (| Value.Tuple [] |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _layouter := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + impl_Layouter_F_, + [], + "clone", + [] + |), + [ layouter ] + |) + |) in + let _etable := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableWithMemoryInfo"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ etable ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "rayon_core::scope::Scope", + "spawn", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "rayon_core::scope::Scope" + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.read (| s |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let _ := + let timer := + M.copy (| + let msg := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]), + [ Ty.tuple [] ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "Assign bit table" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + Value.Tuple [] + ] + |) + |) in + let start_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path + "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "yellow", + [] + |), + [ + M.read (| + Value.String + "Start:" + |) + ] + |) + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer + 0; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| + "ark_std::perf_trace::inner::compute_indent", + [] + |), + [ + M.read (| + indent_amount + |) + ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "std::io::stdio::_print", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + indent + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + start_info + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + msg + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 8 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 2; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer 1; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) in + M.alloc (| + Value.StructRecord + "ark_std::perf_trace::inner::TimerInfo" + [ + ("msg", + M.call_closure (| + M.get_trait_method (| + "alloc::string::ToString", + Ty.path + "str", + [], + "to_string", + [] + |), + [ + M.read (| + msg + |) + ] + |)); + ("time", + M.call_closure (| + M.get_associated_function (| + Ty.path + "std::time::Instant", + "now", + [] + |), + [] + |)) + ] + |) + |) in + let r := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::bit_table::BitTableChip") + [ F ], + "assign", + [ + impl_Layouter_F_ + ] + |), + [ + bit_chip; + M.read (| + _layouter + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::bit_table::BitTableTrait", + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableWithMemoryInfo", + [], + "filter_bit_table_entries", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::sync::Arc") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableWithMemoryInfo"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ _etable + ] + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + let _ := + let time := + M.copy (| + M.SubPointer.get_struct_record_field (| + timer, + "ark_std::perf_trace::inner::TimerInfo", + "time" + |) + |) in + let final_time := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "std::time::Instant", + "elapsed", + [] + |), + [ time ] + |) + |) in + let final_time := + M.copy (| + let secs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "as_secs", + [] + |), + [ final_time ] + |) + |) in + let millis := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_millis", + [] + |), + [ final_time ] + |) + |) in + let micros := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_micros", + [] + |), + [ final_time + ] + |), + Value.Integer + 1000 + |) + |) in + let nanos := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_nanos", + [] + |), + [ final_time + ] + |), + Value.Integer + 1000 + |) + |) in + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.read (| + secs + |)) + (Value.Integer + 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + "s" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u64" + ] + |), + [ + secs + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + millis + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| + millis + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + "ms" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + millis + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + micros + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| + micros + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + (String.String + "181" + "s") + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + micros + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + nanos + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "ns" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_nanos", + [] + |), + [ + final_time + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + |) in + let end_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path + "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "green", + [] + |), + [ + M.read (| + Value.String + "End:" + |) + ] + |) + ] + |) + |) in + let message := + M.copy (| + let res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + timer, + "ark_std::perf_trace::inner::TimerInfo", + "msg" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]), + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + Value.Tuple + [] + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_sub", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer 1; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer + 0; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| + "ark_std::perf_trace::inner::compute_indent", + [] + |), + [ + M.read (| + indent_amount + |) + ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "std::io::stdio::_print", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + indent + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + end_info + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + message + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + final_time + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "from_usize", + [] + |), + [ + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + Value.Integer + 75, + M.read (| + indent_amount + |) + |) + |) + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 8 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 2; + Value.UnicodeChar + 46; + Value.StructTuple + "core::fmt::rt::Alignment::Left" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Param" + [ + Value.Integer + 4 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 3; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) in + M.alloc (| + Value.Tuple [] + |) in + M.alloc (| + Value.Tuple [] + |) in + r in + M.alloc (| Value.Tuple [] |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _layouter := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + impl_Layouter_F_, + [], + "clone", + [] + |), + [ layouter ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "rayon_core::scope::Scope", + "spawn", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "rayon_core::scope::Scope" + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.read (| s |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let _ := + let timer := + M.copy (| + let msg := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]), + [ Ty.tuple [] ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "Assign external host call table" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + Value.Tuple [] + ] + |) + |) in + let start_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path + "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "yellow", + [] + |), + [ + M.read (| + Value.String + "Start:" + |) + ] + |) + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer + 0; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| + "ark_std::perf_trace::inner::compute_indent", + [] + |), + [ + M.read (| + indent_amount + |) + ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "std::io::stdio::_print", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + indent + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + start_info + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + msg + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 8 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 2; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer 1; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) in + M.alloc (| + Value.StructRecord + "ark_std::perf_trace::inner::TimerInfo" + [ + ("msg", + M.call_closure (| + M.get_trait_method (| + "alloc::string::ToString", + Ty.path + "str", + [], + "to_string", + [] + |), + [ + M.read (| + msg + |) + ] + |)); + ("time", + M.call_closure (| + M.get_associated_function (| + Ty.path + "std::time::Instant", + "now", + [] + |), + [] + |)) + ] + |) + |) in + let r := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::external_host_call_table::ExternalHostCallChip") + [ F ], + "assign", + [ + impl_Layouter_F_ + ] + |), + [ + M.read (| + external_host_call_chip + |); + M.read (| + _layouter + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::etable::EventTable", + "filter_external_host_call_table", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::sync::Arc") + [ + Ty.path + "specs::etable::EventTable"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "etable" + |) + ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + let _ := + let _ := + let time := + M.copy (| + M.SubPointer.get_struct_record_field (| + timer, + "ark_std::perf_trace::inner::TimerInfo", + "time" + |) + |) in + let final_time := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "std::time::Instant", + "elapsed", + [] + |), + [ time ] + |) + |) in + let final_time := + M.copy (| + let secs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "as_secs", + [] + |), + [ final_time ] + |) + |) in + let millis := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_millis", + [] + |), + [ final_time ] + |) + |) in + let micros := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_micros", + [] + |), + [ final_time + ] + |), + Value.Integer + 1000 + |) + |) in + let nanos := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_nanos", + [] + |), + [ final_time + ] + |), + Value.Integer + 1000 + |) + |) in + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.read (| + secs + |)) + (Value.Integer + 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + "s" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u64" + ] + |), + [ + secs + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + millis + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| + millis + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + "ms" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + millis + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + micros + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| + micros + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + (String.String + "181" + "s") + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + micros + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + nanos + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "ns" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_nanos", + [] + |), + [ + final_time + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + |) in + let end_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path + "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "green", + [] + |), + [ + M.read (| + Value.String + "End:" + |) + ] + |) + ] + |) + |) in + let message := + M.copy (| + let res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + timer, + "ark_std::perf_trace::inner::TimerInfo", + "msg" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]), + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + Value.Tuple + [] + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_sub", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer 1; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer + 0; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| + "ark_std::perf_trace::inner::compute_indent", + [] + |), + [ + M.read (| + indent_amount + |) + ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "std::io::stdio::_print", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + indent + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + end_info + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + message + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + final_time + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "from_usize", + [] + |), + [ + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + Value.Integer + 75, + M.read (| + indent_amount + |) + |) + |) + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 8 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 2; + Value.UnicodeChar + 46; + Value.StructTuple + "core::fmt::rt::Alignment::Left" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Param" + [ + Value.Integer + 4 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 3; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) in + M.alloc (| + Value.Tuple [] + |) in + M.alloc (| + Value.Tuple [] + |) in + r in + M.alloc (| Value.Tuple [] |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _layouter := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + impl_Layouter_F_, + [], + "clone", + [] + |), + [ layouter ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "rayon_core::scope::Scope", + "spawn", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "rayon_core::scope::Scope" + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.read (| s |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let _ := + let timer := + M.copy (| + let msg := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]), + [ Ty.tuple [] ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "Assign context cont chip" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + Value.Tuple [] + ] + |) + |) in + let start_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path + "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "yellow", + [] + |), + [ + M.read (| + Value.String + "Start:" + |) + ] + |) + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer + 0; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| + "ark_std::perf_trace::inner::compute_indent", + [] + |), + [ + M.read (| + indent_amount + |) + ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "std::io::stdio::_print", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + indent + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + start_info + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + msg + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 8 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 2; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer 1; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) in + M.alloc (| + Value.StructRecord + "ark_std::perf_trace::inner::TimerInfo" + [ + ("msg", + M.call_closure (| + M.get_trait_method (| + "alloc::string::ToString", + Ty.path + "str", + [], + "to_string", + [] + |), + [ + M.read (| + msg + |) + ] + |)); + ("time", + M.call_closure (| + M.get_associated_function (| + Ty.path + "std::time::Instant", + "now", + [] + |), + [] + |)) + ] + |) + |) in + let r := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::context::circuits::assign::ContextContHelperTableChip") + [ F ], + "assign", + [ + impl_Layouter_F_ + ] + |), + [ + context_chip; + M.read (| + _layouter + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::foreign::context::circuits::assign::ExtractContextFromTrace", + Ty.path + "specs::etable::EventTable", + [], + "get_context_inputs", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::sync::Arc") + [ + Ty.path + "specs::etable::EventTable"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "etable" + |) + ] + |) + ] + |) + |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::foreign::context::circuits::assign::ExtractContextFromTrace", + Ty.path + "specs::etable::EventTable", + [], + "get_context_outputs", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::sync::Arc") + [ + Ty.path + "specs::etable::EventTable"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "etable" + |) + ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + let _ := + let _ := + let time := + M.copy (| + M.SubPointer.get_struct_record_field (| + timer, + "ark_std::perf_trace::inner::TimerInfo", + "time" + |) + |) in + let final_time := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "std::time::Instant", + "elapsed", + [] + |), + [ time ] + |) + |) in + let final_time := + M.copy (| + let secs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "as_secs", + [] + |), + [ final_time ] + |) + |) in + let millis := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_millis", + [] + |), + [ final_time ] + |) + |) in + let micros := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_micros", + [] + |), + [ final_time + ] + |), + Value.Integer + 1000 + |) + |) in + let nanos := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_nanos", + [] + |), + [ final_time + ] + |), + Value.Integer + 1000 + |) + |) in + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.read (| + secs + |)) + (Value.Integer + 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + "s" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u64" + ] + |), + [ + secs + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + millis + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| + millis + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + "ms" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + millis + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + micros + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| + micros + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + (String.String + "181" + "s") + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + micros + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + nanos + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "ns" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_nanos", + [] + |), + [ + final_time + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + |) in + let end_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path + "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "green", + [] + |), + [ + M.read (| + Value.String + "End:" + |) + ] + |) + ] + |) + |) in + let message := + M.copy (| + let res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + timer, + "ark_std::perf_trace::inner::TimerInfo", + "msg" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]), + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + Value.Tuple + [] + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_sub", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer 1; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer + 0; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| + "ark_std::perf_trace::inner::compute_indent", + [] + |), + [ + M.read (| + indent_amount + |) + ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "std::io::stdio::_print", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + indent + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + end_info + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + message + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + final_time + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "from_usize", + [] + |), + [ + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + Value.Integer + 75, + M.read (| + indent_amount + |) + |) + |) + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 8 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 2; + Value.UnicodeChar + 46; + Value.StructTuple + "core::fmt::rt::Alignment::Left" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Param" + [ + Value.Integer + 4 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 3; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) in + M.alloc (| + Value.Tuple [] + |) in + M.alloc (| + Value.Tuple [] + |) in + r in + M.alloc (| Value.Tuple [] |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _layouter := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + impl_Layouter_F_, + [], + "clone", + [] + |), + [ layouter ] + |) + |) in + let _assigned_cells := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells") + [ F ], + [], + "clone", + [] + |), + [ assigned_cells ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "rayon_core::scope::Scope", + "spawn", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "rayon_core::scope::Scope" + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.read (| s |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let pre_image_table := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::utils::image_table::EncodeImageTable", + Ty.path + "specs::slice::Slice", + [ F ], + "encode_pre_compilation_table_values", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |); + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "k" + |) + |) + ] + |) + |) in + let cells := + M.copy (| + let timer := + M.copy (| + let msg := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]), + [ Ty.tuple [] + ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match + γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "Assign pre image table chip" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + Value.Tuple [] + ] + |) + |) in + let start_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path + "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "yellow", + [] + |), + [ + M.read (| + Value.String + "Start:" + |) + ] + |) + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer + 0; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| + "ark_std::perf_trace::inner::compute_indent", + [] + |), + [ + M.read (| + indent_amount + |) + ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "std::io::stdio::_print", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + indent + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + start_info + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + msg + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 8 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 2; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer + 1; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) in + M.alloc (| + Value.StructRecord + "ark_std::perf_trace::inner::TimerInfo" + [ + ("msg", + M.call_closure (| + M.get_trait_method (| + "alloc::string::ToString", + Ty.path + "str", + [], + "to_string", + [] + |), + [ + M.read (| + msg + |) + ] + |)); + ("time", + M.call_closure (| + M.get_associated_function (| + Ty.path + "std::time::Instant", + "now", + [] + |), + [] + |)) + ] + |) + |) in + let r := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::image_table::ImageTableChip") + [ F ], + "assign", + [ + impl_Layouter_F_ + ] + |), + [ + image_chip; + M.read (| + _layouter + |); + image_table_assigner; + M.read (| + pre_image_table + |) + ] + |) + ] + |) + |) in + let _ := + let _ := + let time := + M.copy (| + M.SubPointer.get_struct_record_field (| + timer, + "ark_std::perf_trace::inner::TimerInfo", + "time" + |) + |) in + let final_time := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "std::time::Instant", + "elapsed", + [] + |), + [ time ] + |) + |) in + let final_time := + M.copy (| + let secs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "as_secs", + [] + |), + [ final_time + ] + |) + |) in + let millis := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_millis", + [] + |), + [ final_time + ] + |) + |) in + let micros := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_micros", + [] + |), + [ + final_time + ] + |), + Value.Integer + 1000 + |) + |) in + let nanos := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_nanos", + [] + |), + [ + final_time + ] + |), + Value.Integer + 1000 + |) + |) in + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.read (| + secs + |)) + (Value.Integer + 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + "s" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u64" + ] + |), + [ + secs + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + millis + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| + millis + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + "ms" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + millis + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + micros + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun + γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| + micros + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + (String.String + "181" + "s") + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + micros + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + nanos + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "ns" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_nanos", + [] + |), + [ + final_time + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + |) in + let end_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path + "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "green", + [] + |), + [ + M.read (| + Value.String + "End:" + |) + ] + |) + ] + |) + |) in + let message := + M.copy (| + let res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + timer, + "ark_std::perf_trace::inner::TimerInfo", + "msg" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]), + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + Value.Tuple + [] + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_sub", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer + 1; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer + 0; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| + "ark_std::perf_trace::inner::compute_indent", + [] + |), + [ + M.read (| + indent_amount + |) + ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "std::io::stdio::_print", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + indent + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + end_info + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + message + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + final_time + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "from_usize", + [] + |), + [ + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + Value.Integer + 75, + M.read (| + indent_amount + |) + |) + |) + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 8 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 2; + Value.UnicodeChar + 46; + Value.StructTuple + "core::fmt::rt::Alignment::Left" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Param" + [ + Value.Integer + 4 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 3; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) in + M.alloc (| + Value.Tuple [] + |) in + M.alloc (| + Value.Tuple [] + |) in + r + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ]; + Ty.apply + (Ty.path + "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::sync::Arc") + [ + Ty.apply + (Ty.path + "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + _assigned_cells, + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "pre_image_table_cells" + |) + ] + |) + ] + |) + ] + |) + |) + ] + |), + Value.StructTuple + "core::option::Option::Some" + [ M.read (| cells |) ] + |) in + M.alloc (| Value.Tuple [] |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _layouter := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + impl_Layouter_F_, + [], + "clone", + [] + |), + [ layouter ] + |) + |) in + let _assigned_cells := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells") + [ F ], + [], + "clone", + [] + |), + [ assigned_cells ] + |) + |) in + let _memory_writing_table := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ memory_writing_table ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "rayon_core::scope::Scope", + "spawn", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "rayon_core::scope::Scope" + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.read (| s |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let post_image_table := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::utils::image_table::EncodeImageTable", + Ty.path + "specs::slice::Slice", + [ F ], + "encode_post_compilation_table_values", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |); + M.read (| + M.SubPointer.get_struct_record_field (| + config, + "delphinus_zkwasm::circuits::zkwasm_circuit::ZkWasmCircuitConfig", + "k" + |) + |) + ] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable", + "count_rest_memory_finalize_ops", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::sync::Arc") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + _memory_writing_table + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + rest_memory_writing_ops := + M.copy (| γ0_0 |) in + let + memory_finalized_set := + M.copy (| γ0_1 |) in + let cells := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::post_image_table::PostImageTableChip") + [ F ], + "assign", + [ + impl_Layouter_F_ + ] + |), + [ + M.read (| + post_image_chip + |); + M.read (| + _layouter + |); + image_table_assigner; + M.read (| + post_image_table + |); + M.read (| + rest_memory_writing_ops + |); + M.read (| + memory_finalized_set + |) + ] + |) + ] + |) + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ] + ]; + Ty.apply + (Ty.path + "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ] + ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::sync::Arc") + [ + Ty.apply + (Ty.path + "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + _assigned_cells, + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "post_image_table_cells" + |) + ] + |) + ] + |) + ] + |) + |) + ] + |), + Value.StructTuple + "core::option::Option::Some" + [ + M.read (| + cells + |) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _layouter := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + impl_Layouter_F_, + [], + "clone", + [] + |), + [ layouter ] + |) + |) in + let _assigned_cells := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells") + [ F ], + [], + "clone", + [] + |), + [ assigned_cells ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "rayon_core::scope::Scope", + "spawn", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "rayon_core::scope::Scope" + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.read (| s |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let _ := + let timer := + M.copy (| + let msg := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]), + [ Ty.tuple [] ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "Assign frame table" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + Value.Tuple [] + ] + |) + |) in + let start_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path + "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "yellow", + [] + |), + [ + M.read (| + Value.String + "Start:" + |) + ] + |) + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer + 0; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| + "ark_std::perf_trace::inner::compute_indent", + [] + |), + [ + M.read (| + indent_amount + |) + ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "std::io::stdio::_print", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + indent + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + start_info + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + msg + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 8 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 2; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer 1; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) in + M.alloc (| + Value.StructRecord + "ark_std::perf_trace::inner::TimerInfo" + [ + ("msg", + M.call_closure (| + M.get_trait_method (| + "alloc::string::ToString", + Ty.path + "str", + [], + "to_string", + [] + |), + [ + M.read (| + msg + |) + ] + |)); + ("time", + M.call_closure (| + M.get_associated_function (| + Ty.path + "std::time::Instant", + "now", + [] + |), + [] + |)) + ] + |) + |) in + let r := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F + ]; + Ty.apply + (Ty.path + "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::jtable::JumpTableChip") + [ F ], + "assign", + [ + impl_Layouter_F_ + ] + |), + [ + frame_table_chip; + M.read (| + _layouter + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::sync::Arc") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.path + "specs::jtable::StaticFrameEntry" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "static_jtable" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::sync::Arc") + [ + Ty.path + "specs::jtable::JumpTable"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "frame_table" + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let + rest_jops_cell := + M.copy (| + γ0_0 + |) in + let + static_frame_entry_cells := + M.copy (| + γ0_1 + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ]; + Ty.apply + (Ty.path + "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::sync::Arc") + [ + Ty.apply + (Ty.path + "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + _assigned_cells, + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "rest_jops_cell_in_frame_table" + |) + ] + |) + ] + |) + ] + |) + |) + ] + |), + Value.StructTuple + "core::option::Option::Some" + [ + M.read (| + rest_jops_cell + |) + ] + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ] + ]; + Ty.apply + (Ty.path + "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ] + ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::sync::Arc") + [ + Ty.apply + (Ty.path + "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + _assigned_cells, + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "static_frame_entry_in_frame_table" + |) + ] + |) + ] + |) + ] + |) + |) + ] + |), + Value.StructTuple + "core::option::Option::Some" + [ + M.read (| + static_frame_entry_cells + |) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) + |) in + let _ := + let _ := + let time := + M.copy (| + M.SubPointer.get_struct_record_field (| + timer, + "ark_std::perf_trace::inner::TimerInfo", + "time" + |) + |) in + let final_time := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "std::time::Instant", + "elapsed", + [] + |), + [ time ] + |) + |) in + let final_time := + M.copy (| + let secs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "as_secs", + [] + |), + [ final_time ] + |) + |) in + let millis := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_millis", + [] + |), + [ final_time ] + |) + |) in + let micros := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_micros", + [] + |), + [ final_time + ] + |), + Value.Integer + 1000 + |) + |) in + let nanos := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_nanos", + [] + |), + [ final_time + ] + |), + Value.Integer + 1000 + |) + |) in + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.read (| + secs + |)) + (Value.Integer + 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + "s" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u64" + ] + |), + [ + secs + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + millis + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| + millis + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + "ms" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + millis + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + micros + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| + micros + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + (String.String + "181" + "s") + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + micros + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + nanos + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "ns" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_nanos", + [] + |), + [ + final_time + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + |) in + let end_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path + "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "green", + [] + |), + [ + M.read (| + Value.String + "End:" + |) + ] + |) + ] + |) + |) in + let message := + M.copy (| + let res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + timer, + "ark_std::perf_trace::inner::TimerInfo", + "msg" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]), + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + Value.Tuple + [] + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_sub", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer 1; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer + 0; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| + "ark_std::perf_trace::inner::compute_indent", + [] + |), + [ + M.read (| + indent_amount + |) + ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "std::io::stdio::_print", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + indent + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + end_info + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + message + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + final_time + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "from_usize", + [] + |), + [ + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + Value.Integer + 75, + M.read (| + indent_amount + |) + |) + |) + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 8 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 2; + Value.UnicodeChar + 46; + Value.StructTuple + "core::fmt::rt::Alignment::Left" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Param" + [ + Value.Integer + 4 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 3; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) in + M.alloc (| + Value.Tuple [] + |) in + M.alloc (| + Value.Tuple [] + |) in + r in + M.alloc (| Value.Tuple [] |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _layouter := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + impl_Layouter_F_, + [], + "clone", + [] + |), + [ layouter ] + |) + |) in + let _assigned_cells := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells") + [ F ], + [], + "clone", + [] + |), + [ assigned_cells ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "rayon_core::scope::Scope", + "spawn", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "rayon_core::scope::Scope" + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.read (| s |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let _ := + let timer := + M.copy (| + let msg := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]), + [ Ty.tuple [] ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "Assign mtable" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + Value.Tuple [] + ] + |) + |) in + let start_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path + "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "yellow", + [] + |), + [ + M.read (| + Value.String + "Start:" + |) + ] + |) + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer + 0; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| + "ark_std::perf_trace::inner::compute_indent", + [] + |), + [ + M.read (| + indent_amount + |) + ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "std::io::stdio::_print", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + indent + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + start_info + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + msg + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 8 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 2; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer 1; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) in + M.alloc (| + Value.StructRecord + "ark_std::perf_trace::inner::TimerInfo" + [ + ("msg", + M.call_closure (| + M.get_trait_method (| + "alloc::string::ToString", + Ty.path + "str", + [], + "to_string", + [] + |), + [ + M.read (| + msg + |) + ] + |)); + ("time", + M.call_closure (| + M.get_associated_function (| + Ty.path + "std::time::Instant", + "now", + [] + |), + [] + |)) + ] + |) + |) in + let r := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F + ]; + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::mtable::MemoryTableChip") + [ F ], + "assign", + [ + impl_Layouter_F_ + ] + |), + [ + mchip; + M.read (| + _layouter + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::sync::Arc") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryWritingTable"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + memory_writing_table + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| + γ, + 0 + |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| + γ, + 1 + |) in + let rest_mops := + M.copy (| + γ0_0 + |) in + let + rest_memory_finalize_ops_cell := + M.copy (| + γ0_1 + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ]; + Ty.apply + (Ty.path + "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::sync::Arc") + [ + Ty.apply + (Ty.path + "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + _assigned_cells, + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "mtable_rest_mops" + |) + ] + |) + ] + |) + ] + |) + |) + ] + |), + Value.StructTuple + "core::option::Option::Some" + [ + M.read (| + rest_mops + |) + ] + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ]; + Ty.apply + (Ty.path + "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::sync::Arc") + [ + Ty.apply + (Ty.path + "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + _assigned_cells, + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "rest_memory_finalize_ops_cell" + |) + ] + |) + ] + |) + ] + |) + |) + ] + |), + Value.StructTuple + "core::option::Option::Some" + [ + M.read (| + rest_memory_finalize_ops_cell + |) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) + |) in + let _ := + let _ := + let time := + M.copy (| + M.SubPointer.get_struct_record_field (| + timer, + "ark_std::perf_trace::inner::TimerInfo", + "time" + |) + |) in + let final_time := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "std::time::Instant", + "elapsed", + [] + |), + [ time ] + |) + |) in + let final_time := + M.copy (| + let secs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "as_secs", + [] + |), + [ final_time ] + |) + |) in + let millis := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_millis", + [] + |), + [ final_time ] + |) + |) in + let micros := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_micros", + [] + |), + [ final_time + ] + |), + Value.Integer + 1000 + |) + |) in + let nanos := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_nanos", + [] + |), + [ final_time + ] + |), + Value.Integer + 1000 + |) + |) in + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.read (| + secs + |)) + (Value.Integer + 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + "s" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u64" + ] + |), + [ + secs + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + millis + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| + millis + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + "ms" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + millis + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + micros + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| + micros + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + (String.String + "181" + "s") + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + micros + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + nanos + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "ns" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_nanos", + [] + |), + [ + final_time + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + |) in + let end_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path + "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "green", + [] + |), + [ + M.read (| + Value.String + "End:" + |) + ] + |) + ] + |) + |) in + let message := + M.copy (| + let res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + timer, + "ark_std::perf_trace::inner::TimerInfo", + "msg" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]), + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + Value.Tuple + [] + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_sub", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer 1; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer + 0; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| + "ark_std::perf_trace::inner::compute_indent", + [] + |), + [ + M.read (| + indent_amount + |) + ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "std::io::stdio::_print", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + indent + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + end_info + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + message + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + final_time + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "from_usize", + [] + |), + [ + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + Value.Integer + 75, + M.read (| + indent_amount + |) + |) + |) + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 8 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 2; + Value.UnicodeChar + 46; + Value.StructTuple + "core::fmt::rt::Alignment::Left" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Param" + [ + Value.Integer + 4 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 3; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) in + M.alloc (| + Value.Tuple [] + |) in + M.alloc (| + Value.Tuple [] + |) in + r in + M.alloc (| Value.Tuple [] |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _layouter := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + impl_Layouter_F_, + [], + "clone", + [] + |), + [ layouter ] + |) + |) in + let _assigned_cells := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells") + [ F ], + [], + "clone", + [] + |), + [ assigned_cells ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "rayon_core::scope::Scope", + "spawn", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "rayon_core::scope::Scope" + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.read (| s |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + let _ := + let timer := + M.copy (| + let msg := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]), + [ Ty.tuple [] ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ + with + | [ α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "Assign etable" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + Value.Tuple [] + ] + |) + |) in + let start_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path + "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "yellow", + [] + |), + [ + M.read (| + Value.String + "Start:" + |) + ] + |) + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer + 0; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| + "ark_std::perf_trace::inner::compute_indent", + [] + |), + [ + M.read (| + indent_amount + |) + ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "std::io::stdio::_print", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + indent + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + start_info + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + msg + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 8 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 2; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer 1; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) in + M.alloc (| + Value.StructRecord + "ark_std::perf_trace::inner::TimerInfo" + [ + ("msg", + M.call_closure (| + M.get_trait_method (| + "alloc::string::ToString", + Ty.path + "str", + [], + "to_string", + [] + |), + [ + M.read (| + msg + |) + ] + |)); + ("time", + M.call_closure (| + M.get_associated_function (| + Ty.path + "std::time::Instant", + "now", + [] + |), + [] + |)) + ] + |) + |) in + let r := + M.copy (| + let cells := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ F ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::EventTableChip") + [ F ], + "assign", + [ + impl_Layouter_F_ + ] + |), + [ + echip; + M.read (| + _layouter + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::sync::Arc") + [ + Ty.path + "specs::itable::InstructionTable"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "itable" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::sync::Arc") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::EventTableWithMemoryInfo"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ etable ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::sync::Arc") + [ + Ty.path + "specs::configure_table::ConfigureTable"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "configure_table" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::sync::Arc") + [ + Ty.apply + (Ty.path + "specs::state::InitializationState") + [ + Ty.path + "u32"; + Ty.path + "num_bigint::biguint::BigUint" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "initialization_state" + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::sync::Arc") + [ + Ty.apply + (Ty.path + "specs::state::InitializationState") + [ + Ty.path + "u32"; + Ty.path + "num_bigint::biguint::BigUint" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "post_initialization_state" + |) + ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::circuits::ZkWasmCircuit", + "slice" + |), + "specs::slice::Slice", + "is_last_slice" + |) + |) + ] + |) + ] + |) + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ F ] + ] + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ + F + ] + ] + ]; + Ty.apply + (Ty.path + "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path + "std::sync::mutex::MutexGuard") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ + F + ] + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ + F + ] + ] + ], + "lock", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::sync::Arc") + [ + Ty.apply + (Ty.path + "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ + F + ] + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + _assigned_cells, + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "etable_cells" + |) + ] + |) + ] + |) + ] + |) + |) + ] + |), + Value.StructTuple + "core::option::Option::Some" + [ + M.read (| + cells + |) + ] + |) in + M.alloc (| + Value.Tuple [] + |) + |) in + let _ := + let _ := + let time := + M.copy (| + M.SubPointer.get_struct_record_field (| + timer, + "ark_std::perf_trace::inner::TimerInfo", + "time" + |) + |) in + let final_time := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "std::time::Instant", + "elapsed", + [] + |), + [ time ] + |) + |) in + let final_time := + M.copy (| + let secs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "as_secs", + [] + |), + [ final_time ] + |) + |) in + let millis := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_millis", + [] + |), + [ final_time ] + |) + |) in + let micros := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_micros", + [] + |), + [ final_time + ] + |), + Value.Integer + 1000 + |) + |) in + let nanos := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_nanos", + [] + |), + [ final_time + ] + |), + Value.Integer + 1000 + |) + |) in + M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.read (| + secs + |)) + (Value.Integer + 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + "s" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u64" + ] + |), + [ + secs + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + millis + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| + millis + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + "ms" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + millis + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + micros + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple + [] + |), + [ + fun + γ => + ltac:(M.monadic + (let + γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| + micros + |)) + (Value.Integer + 0) + |)) in + let + _ := + M.is_constant_or_break_match (| + M.read (| + γ + |), + Value.Bool + true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "." + |); + M.read (| + Value.String + (String.String + "181" + "s") + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + micros + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + nanos + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun + γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + let + res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "ns" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "u32" + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_nanos", + [] + |), + [ + final_time + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + |) in + let end_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path + "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ], + [], + "green", + [] + |), + [ + M.read (| + Value.String + "End:" + |) + ] + |) + ] + |) + |) in + let message := + M.copy (| + let res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + timer, + "ark_std::perf_trace::inner::TimerInfo", + "msg" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]), + [ + Ty.tuple + [] + ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "" + |))) + ] + |) + | _ => + M.impossible (||) + end)) + |); + Value.Tuple + [] + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_sub", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer 1; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| + "ark_std::perf_trace::inner::NUM_INDENT" + |) + |); + Value.Integer + 0; + Value.StructTuple + "core::sync::atomic::Ordering::Relaxed" + [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| + "ark_std::perf_trace::inner::compute_indent", + [] + |), + [ + M.read (| + indent_amount + |) + ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "std::io::stdio::_print", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "" + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " " + |); + M.read (| + Value.String + "" + |); + M.read (| + Value.String + " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + indent + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + end_info + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "alloc::string::String" + ] + |), + [ + message + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.path + "colored::ColoredString" + ] + |), + [ + final_time + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "from_usize", + [] + |), + [ + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + Value.Integer + 75, + M.read (| + indent_amount + |) + |) + |) + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 8 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 2; + Value.UnicodeChar + 46; + Value.StructTuple + "core::fmt::rt::Alignment::Left" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Param" + [ + Value.Integer + 4 + ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer + 3; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer + 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |) in + M.alloc (| + Value.Tuple [] + |) in + M.alloc (| + Value.Tuple [] + |) in + r in + M.alloc (| Value.Tuple [] |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let static_frame_entry_in_frame_table := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ] + ], + "into_inner", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ] + ]; + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "try_unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + assigned_cells_cloned, + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "static_frame_entry_in_frame_table" + |) + |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + let etable_cells := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ F ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ F ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ F ] + ] + ], + "into_inner", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ F ] + ] + ]; + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells") + [ F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "try_unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + assigned_cells_cloned, + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "etable_cells" + |) + |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + let mtable_rest_mops := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ], + "into_inner", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "try_unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + assigned_cells_cloned, + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "mtable_rest_mops" + |) + |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + let rest_memory_finalize_ops_cell := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ], + "into_inner", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ]; + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "try_unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + assigned_cells_cloned, + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "rest_memory_finalize_ops_cell" + |) + |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + let pre_image_table_cells := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ], + "into_inner", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ]; + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "try_unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + assigned_cells_cloned, + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "pre_image_table_cells" + |) + |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + let post_image_table_cells := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ] + ], + "into_inner", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ] + ]; + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "try_unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + assigned_cells_cloned, + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "post_image_table_cells" + |) + |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + let rest_jops_cell_in_frame_table := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "halo2_proofs::circuit::AssignedCell") [ F; F ] ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply + (Ty.path "std::sync::poison::PoisonError") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ], + "into_inner", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "std::sync::mutex::Mutex") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "try_unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + assigned_cells_cloned, + "delphinus_zkwasm::circuits::zkwasm_circuit::AssignedCells", + "rest_jops_cell_in_frame_table" + |) + |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::Layouter", + impl_Layouter_F_, + [ F ], + "assign_region", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::Region") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ]); + Ty.tuple []; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + layouter_cloned; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String "permutation between tables" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let region := M.copy (| γ |) in + M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ], + "iter", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + static_frame_entry_in_frame_table + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ], + "iter", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + pre_image_table_cells, + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "static_frame_entries" + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let left := + M.copy (| γ1_0 |) in + let right := + M.copy (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "constrain_equal", + [] + |), + [ + M.read (| + region + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ], + "cell", + [] + |), + [ + M.SubPointer.get_tuple_field (| + M.read (| + left + |), + 0 + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ], + "cell", + [] + |), + [ + M.SubPointer.get_tuple_field (| + M.read (| + right + |), + 0 + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "constrain_equal", + [] + |), + [ + M.read (| + region + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ], + "cell", + [] + |), + [ + M.SubPointer.get_tuple_field (| + M.read (| + left + |), + 1 + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ], + "cell", + [] + |), + [ + M.SubPointer.get_tuple_field (| + M.read (| + right + |), + 1 + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ], + "as_ref", + [] + |), + [ post_image_table_cells ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ2_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let post_image_table_cells := + M.alloc (| γ2_0 |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ], + "iter", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + static_frame_entry_in_frame_table + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ], + "iter", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| + post_image_table_cells + |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "static_frame_entries" + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let left := + M.copy (| + γ1_0 + |) in + let right := + M.copy (| + γ1_1 + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ + F + ], + "constrain_equal", + [] + |), + [ + M.read (| + region + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ], + "cell", + [] + |), + [ + M.SubPointer.get_tuple_field (| + M.read (| + left + |), + 0 + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ], + "cell", + [] + |), + [ + M.SubPointer.get_tuple_field (| + M.read (| + right + |), + 0 + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ + F + ], + "constrain_equal", + [] + |), + [ + M.read (| + region + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ], + "cell", + [] + |), + [ + M.SubPointer.get_tuple_field (| + M.read (| + left + |), + 1 + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ], + "cell", + [] + |), + [ + M.SubPointer.get_tuple_field (| + M.read (| + right + |), + 1 + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + |))) + ] + |)))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ], + "as_ref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + etable_cells, + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells", + "rest_jops" + |) + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let rest_jops_in_event_chip := + M.copy (| γ0_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "constrain_equal", + [] + |), + [ + M.read (| region |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ], + "cell", + [] + |), + [ + M.read (| + rest_jops_in_event_chip + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ], + "cell", + [] + |), + [ + rest_jops_cell_in_frame_table + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "constrain_equal", + [] + |), + [ + M.read (| region |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ], + "cell", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + etable_cells, + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells", + "rest_mops" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ], + "cell", + [] + |), + [ mtable_rest_mops ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ], + "as_ref", + [] + |), + [ post_image_table_cells ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ2_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let + rest_memory_finalized_ops_in_post_image_table := + M.alloc (| γ2_1 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "constrain_equal", + [] + |), + [ + M.read (| region |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ], + "cell", + [] + |), + [ + M.read (| + rest_memory_finalized_ops_in_post_image_table + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ], + "cell", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ], + "as_ref", + [] + |), + [ + rest_memory_finalize_ops_cell + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "specs::state::InitializationState") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ], + "zip_for_each", + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.SubPointer.get_struct_record_field (| + etable_cells, + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells", + "pre_initialization_state" + |); + M.SubPointer.get_struct_record_field (| + pre_image_table_cells, + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "initialization_state" + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let l := + M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let r := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F ], + "constrain_equal", + [] + |), + [ + M.read (| + region + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ], + "cell", + [] + |), + [ + M.read (| + l + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ], + "cell", + [] + |), + [ + M.read (| + r + |) + ] + |) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ], + "as_ref", + [] + |), + [ post_image_table_cells ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ2_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let post_image_table_cells := + M.alloc (| γ2_0 |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "specs::state::InitializationState") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ], + "zip_for_each", + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ]) + ] + |), + [ + M.SubPointer.get_struct_record_field (| + etable_cells, + "delphinus_zkwasm::circuits::etable::assign::EventTablePermutationCells", + "post_initialization_state" + |); + M.SubPointer.get_struct_record_field (| + M.read (| + post_image_table_cells + |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "initialization_state" + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1 ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun γ => + ltac:(M.monadic + (let l := + M.copy (| + γ + |) in + M.match_operator (| + M.alloc (| + α1 + |), + [ + fun + γ => + ltac:(M.monadic + (let + r := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ + F + ], + "constrain_equal", + [] + |), + [ + M.read (| + region + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ], + "cell", + [] + |), + [ + M.read (| + l + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ], + "cell", + [] + |), + [ + M.read (| + r + |) + ] + |) + ] + |))) + ] + |))) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ], + "as_ref", + [] + |), + [ post_image_table_cells ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ2_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let post_image_table_cells := + M.alloc (| γ2_0 |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + pre_image_table_cells, + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "instructions" + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + post_image_table_cells + |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "instructions" + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := + M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let l := + M.copy (| + γ1_0 + |) in + let r := + M.copy (| + γ1_1 + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ + F + ], + "constrain_equal", + [] + |), + [ + M.read (| + region + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ], + "cell", + [] + |), + [ + M.read (| + l + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ], + "cell", + [] + |), + [ + M.read (| + r + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + pre_image_table_cells, + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "br_table_entires" + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + post_image_table_cells + |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "br_table_entires" + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := + M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let l := + M.copy (| + γ1_0 + |) in + let r := + M.copy (| + γ1_1 + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ + F + ], + "constrain_equal", + [] + |), + [ + M.read (| + region + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ], + "cell", + [] + |), + [ + M.read (| + l + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ], + "cell", + [] + |), + [ + M.read (| + r + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple + [] + |))) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + |))) + ] + |)) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ], + [], + "zip", + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + pre_image_table_cells, + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "padding_entires" + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ] + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + post_image_table_cells + |), + "delphinus_zkwasm::circuits::utils::image_table::ImageTableLayouter", + "padding_entires" + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F + ] + ]; + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F + ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let l := + M.copy (| + γ1_0 + |) in + let r := + M.copy (| + γ1_1 + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ + F + ], + "constrain_equal", + [] + |), + [ + M.read (| + region + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ], + "cell", + [] + |), + [ + M.read (| + l + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ], + "cell", + [] + |), + [ + M.read (| + r + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let + val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + |))) + ] + |)))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + let _ := + let time := + M.copy (| + M.SubPointer.get_struct_record_field (| + assign_timer, + "ark_std::perf_trace::inner::TimerInfo", + "time" + |) + |) in + let final_time := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "std::time::Instant", + "elapsed", + [] + |), + [ time ] + |) + |) in + let final_time := + M.copy (| + let secs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::time::Duration", + "as_secs", + [] + |), + [ final_time ] + |) + |) in + let millis := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::time::Duration", + "subsec_millis", + [] + |), + [ final_time ] + |) + |) in + let micros := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path "core::time::Duration", + "subsec_micros", + [] + |), + [ final_time ] + |), + Value.Integer 1000 + |) + |) in + let nanos := + M.alloc (| + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.path "core::time::Duration", + "subsec_nanos", + [] + |), + [ final_time ] + |), + Value.Integer 1000 + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne (M.read (| secs |)) (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "alloc::string::String", + [], + "deref", + [] + |), + [ + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "" |); + M.read (| Value.String "." |); + M.read (| Value.String "s" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "u64" ] + |), + [ secs ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "u32" ] + |), + [ millis ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 0; + Value.UnicodeChar 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 1; + Value.UnicodeChar 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ Value.Integer 3 ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| millis |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "alloc::string::String", + [], + "deref", + [] + |), + [ + let res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String "" + |); + M.read (| + Value.String "." + |); + M.read (| + Value.String "ms" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "u32" ] + |), + [ millis ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "u32" ] + |), + [ micros ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 0; + Value.UnicodeChar 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 1; + Value.UnicodeChar 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ Value.Integer 3 ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (M.read (| micros |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "alloc::string::String", + [], + "deref", + [] + |), + [ + let res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String "" + |); + M.read (| + Value.String "." + |); + M.read (| + Value.String + (String.String + "181" + "s") + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "u32" + ] + |), + [ micros ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "u32" + ] + |), + [ nanos ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 0; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Implied" + [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 1; + Value.UnicodeChar + 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 8; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ + Value.Integer + 3 + ] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "alloc::string::String", + [], + "deref", + [] + |), + [ + let res := + M.alloc (| + M.call_closure (| + M.get_function (| + "alloc::fmt::format", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String "" + |); + M.read (| + Value.String "ns" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "u32" + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::time::Duration", + "subsec_nanos", + [] + |), + [ final_time + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + |) in + let end_info := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.path "colored::ColoredString", + [], + "bold", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "colored::Colorize", + Ty.apply (Ty.path "&") [ Ty.path "str" ], + [], + "green", + [] + |), + [ M.read (| Value.String "End:" |) ] + |) + ] + |) + |) in + let message := + M.copy (| + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "" |); + M.read (| Value.String " " |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "alloc::string::String" ] + |), + [ + M.SubPointer.get_struct_record_field (| + assign_timer, + "ark_std::perf_trace::inner::TimerInfo", + "msg" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.function + [ Ty.tuple [] ] + (Ty.apply + (Ty.path "&") + [ Ty.path "str" ]), + [ Ty.tuple [] ], + "call", + [] + |), + [ + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String "" + |))) + ] + |) + | _ => M.impossible (||) + end)) + |); + Value.Tuple [] + ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::sync::atomic::AtomicUsize", + "fetch_sub", + [] + |), + [ + M.read (| + M.get_constant (| "ark_std::perf_trace::inner::NUM_INDENT" |) + |); + Value.Integer 1; + Value.StructTuple "core::sync::atomic::Ordering::Relaxed" [] + ] + |) + |) in + let indent_amount := + M.alloc (| + BinOp.Panic.mul (| + Integer.Usize, + Value.Integer 2, + M.call_closure (| + M.get_associated_function (| + Ty.path "core::sync::atomic::AtomicUsize", + "fetch_add", + [] + |), + [ + M.read (| + M.get_constant (| "ark_std::perf_trace::inner::NUM_INDENT" |) + |); + Value.Integer 0; + Value.StructTuple "core::sync::atomic::Ordering::Relaxed" [] + ] + |) + |) + |) in + let indent := + M.alloc (| + M.call_closure (| + M.get_function (| "ark_std::perf_trace::inner::compute_indent", [] |), + [ M.read (| indent_amount |) ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| "std::io::stdio::_print", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1_formatted", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "" |); + M.read (| Value.String "" |); + M.read (| Value.String " " |); + M.read (| Value.String "" |); + M.read (| Value.String " +" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "alloc::string::String" ] + |), + [ indent ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "colored::ColoredString" ] + |), + [ end_info ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "alloc::string::String" ] + |), + [ message ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "colored::ColoredString" ] + |), + [ final_time ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "from_usize", + [] + |), + [ + M.alloc (| + BinOp.Panic.sub (| + Integer.Usize, + Value.Integer 75, + M.read (| indent_amount |) + |) + |) + ] + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 0; + Value.UnicodeChar 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple "core::fmt::rt::Count::Implied" [] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 1; + Value.UnicodeChar 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Is" + [ Value.Integer 8 ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 2; + Value.UnicodeChar 46; + Value.StructTuple + "core::fmt::rt::Alignment::Left" + []; + Value.Integer 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple + "core::fmt::rt::Count::Param" + [ Value.Integer 4 ] + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Placeholder", + "new", + [] + |), + [ + Value.Integer 3; + Value.UnicodeChar 32; + Value.StructTuple + "core::fmt::rt::Alignment::Unknown" + []; + Value.Integer 0; + Value.StructTuple + "core::fmt::rt::Count::Implied" + []; + Value.StructTuple "core::fmt::rt::Count::Implied" [] + ] + |) + ] + |)); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::UnsafeArg", + "new", + [] + |), + [] + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) in + M.alloc (| Value.Tuple [] |) in + M.alloc (| Value.Tuple [] |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "halo2_proofs::plonk::circuit::Circuit" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("Config", InstanceField.Ty (_Config F)); + ("FloorPlanner", InstanceField.Ty (_FloorPlanner F)); + ("without_witnesses", InstanceField.Method (without_witnesses F)); + ("configure", InstanceField.Method (configure F)); + ("synthesize", InstanceField.Method (synthesize F)) + ]. + End Impl_halo2_proofs_plonk_circuit_Circuit_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_circuits_ZkWasmCircuit_F. + End zkwasm_circuit. +End circuits. diff --git a/CoqOfRust/zkWasm/error.v b/CoqOfRust/zkWasm/error.v new file mode 100644 index 000000000..8d8e28cee --- /dev/null +++ b/CoqOfRust/zkWasm/error.v @@ -0,0 +1,656 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module error. + (* + Enum CompilationError + { + ty_params := []; + variants := []; + } + *) + + Module Impl_core_fmt_Debug_for_delphinus_zkwasm_error_CompilationError. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::error::CompilationError". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.never_to_any (| M.read (| M.match_operator (| M.read (| self |), [] |) |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_delphinus_zkwasm_error_CompilationError. + + Module Impl_core_error_Error_for_delphinus_zkwasm_error_CompilationError. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::error::CompilationError". + + Axiom Implements : + M.IsTraitInstance + "core::error::Error" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_error_Error_for_delphinus_zkwasm_error_CompilationError. + + Module Impl_core_fmt_Display_for_delphinus_zkwasm_error_CompilationError. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::error::CompilationError". + + (* Error *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; __formatter ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let __formatter := M.alloc (| __formatter |) in + M.never_to_any (| M.read (| M.match_operator (| M.read (| self |), [] |) |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Display" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Display_for_delphinus_zkwasm_error_CompilationError. + + (* + Enum ExecutionError + { + ty_params := []; + variants := []; + } + *) + + Module Impl_core_fmt_Debug_for_delphinus_zkwasm_error_ExecutionError. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::error::ExecutionError". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.never_to_any (| M.read (| M.match_operator (| M.read (| self |), [] |) |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_delphinus_zkwasm_error_ExecutionError. + + Module Impl_core_error_Error_for_delphinus_zkwasm_error_ExecutionError. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::error::ExecutionError". + + Axiom Implements : + M.IsTraitInstance + "core::error::Error" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_error_Error_for_delphinus_zkwasm_error_ExecutionError. + + Module Impl_core_fmt_Display_for_delphinus_zkwasm_error_ExecutionError. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::error::ExecutionError". + + (* Error *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; __formatter ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let __formatter := M.alloc (| __formatter |) in + M.never_to_any (| M.read (| M.match_operator (| M.read (| self |), [] |) |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Display" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Display_for_delphinus_zkwasm_error_ExecutionError. + + (* + Enum BuildingCircuitError + { + ty_params := []; + variants := + [ + { + name := "MultiSlicesNotSupport"; + item := StructTuple [ Ty.path "usize" ]; + discriminant := None; + }; + { + name := "PagesExceedLimit"; + item := StructTuple [ Ty.path "u32"; Ty.path "u32"; Ty.path "u32" ]; + discriminant := None; + }; + { + name := "EtableEntriesExceedLimit"; + item := StructTuple [ Ty.path "u32"; Ty.path "u32"; Ty.path "u32" ]; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_fmt_Debug_for_delphinus_zkwasm_error_BuildingCircuitError. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::error::BuildingCircuitError". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "delphinus_zkwasm::error::BuildingCircuitError::MultiSlicesNotSupport", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "MultiSlicesNotSupport" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "delphinus_zkwasm::error::BuildingCircuitError::PagesExceedLimit", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "delphinus_zkwasm::error::BuildingCircuitError::PagesExceedLimit", + 1 + |) in + let γ1_2 := + M.SubPointer.get_struct_tuple_field (| + γ, + "delphinus_zkwasm::error::BuildingCircuitError::PagesExceedLimit", + 2 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + let __self_2 := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "PagesExceedLimit" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + (* Unsize *) M.pointer_coercion (M.read (| __self_1 |)); + (* Unsize *) M.pointer_coercion __self_2 + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "delphinus_zkwasm::error::BuildingCircuitError::EtableEntriesExceedLimit", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "delphinus_zkwasm::error::BuildingCircuitError::EtableEntriesExceedLimit", + 1 + |) in + let γ1_2 := + M.SubPointer.get_struct_tuple_field (| + γ, + "delphinus_zkwasm::error::BuildingCircuitError::EtableEntriesExceedLimit", + 2 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + let __self_1 := M.alloc (| γ1_1 |) in + let __self_2 := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field3_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "EtableEntriesExceedLimit" |); + (* Unsize *) M.pointer_coercion (M.read (| __self_0 |)); + (* Unsize *) M.pointer_coercion (M.read (| __self_1 |)); + (* Unsize *) M.pointer_coercion __self_2 + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_delphinus_zkwasm_error_BuildingCircuitError. + + Module Impl_core_error_Error_for_delphinus_zkwasm_error_BuildingCircuitError. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::error::BuildingCircuitError". + + Axiom Implements : + M.IsTraitInstance + "core::error::Error" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_core_error_Error_for_delphinus_zkwasm_error_BuildingCircuitError. + + Module Impl_core_fmt_Display_for_delphinus_zkwasm_error_BuildingCircuitError. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::error::BuildingCircuitError". + + (* Error *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; __formatter ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let __formatter := M.alloc (| __formatter |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "delphinus_zkwasm::error::BuildingCircuitError::MultiSlicesNotSupport", + 0 + |) in + let _0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| __formatter |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "Only support single slice for non-continuation mode but " + |); + M.read (| + Value.String + " provided. You could increase K or enable continuation feature." + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "usize" ] ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "thiserror::display::AsDisplay", + Ty.apply (Ty.path "&") [ Ty.path "usize" ], + [], + "as_display", + [] + |), + [ _0 ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "delphinus_zkwasm::error::BuildingCircuitError::PagesExceedLimit", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "delphinus_zkwasm::error::BuildingCircuitError::PagesExceedLimit", + 1 + |) in + let γ1_2 := + M.SubPointer.get_struct_tuple_field (| + γ, + "delphinus_zkwasm::error::BuildingCircuitError::PagesExceedLimit", + 2 + |) in + let _0 := M.alloc (| γ1_0 |) in + let _1 := M.alloc (| γ1_1 |) in + let _2 := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| __formatter |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "Allocated pages(" |); + M.read (| Value.String ") exceed the limit(" |); + M.read (| Value.String "). Current K is " |); + M.read (| + Value.String ", consider increasing the circuit size K." + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "thiserror::display::AsDisplay", + Ty.apply (Ty.path "&") [ Ty.path "u32" ], + [], + "as_display", + [] + |), + [ _0 ] + |) + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "thiserror::display::AsDisplay", + Ty.apply (Ty.path "&") [ Ty.path "u32" ], + [], + "as_display", + [] + |), + [ _1 ] + |) + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "thiserror::display::AsDisplay", + Ty.apply (Ty.path "&") [ Ty.path "u32" ], + [], + "as_display", + [] + |), + [ _2 ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "delphinus_zkwasm::error::BuildingCircuitError::EtableEntriesExceedLimit", + 0 + |) in + let γ1_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "delphinus_zkwasm::error::BuildingCircuitError::EtableEntriesExceedLimit", + 1 + |) in + let γ1_2 := + M.SubPointer.get_struct_tuple_field (| + γ, + "delphinus_zkwasm::error::BuildingCircuitError::EtableEntriesExceedLimit", + 2 + |) in + let _0 := M.alloc (| γ1_0 |) in + let _1 := M.alloc (| γ1_1 |) in + let _2 := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "write_fmt", + [] + |), + [ + M.read (| __formatter |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "Etable entries(" |); + M.read (| Value.String ") exceed the limit(" |); + M.read (| Value.String "). Current K is " |); + M.read (| + Value.String ", consider increasing the circuit size K." + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "thiserror::display::AsDisplay", + Ty.apply (Ty.path "&") [ Ty.path "u32" ], + [], + "as_display", + [] + |), + [ _0 ] + |) + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "thiserror::display::AsDisplay", + Ty.apply (Ty.path "&") [ Ty.path "u32" ], + [], + "as_display", + [] + |), + [ _1 ] + |) + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "thiserror::display::AsDisplay", + Ty.apply (Ty.path "&") [ Ty.path "u32" ], + [], + "as_display", + [] + |), + [ _2 ] + |) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Display" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Display_for_delphinus_zkwasm_error_BuildingCircuitError. +End error. diff --git a/CoqOfRust/zkWasm/foreign/context/circuits/assign.v b/CoqOfRust/zkWasm/foreign/context/circuits/assign.v new file mode 100644 index 000000000..93e052e5e --- /dev/null +++ b/CoqOfRust/zkWasm/foreign/context/circuits/assign.v @@ -0,0 +1,1487 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module foreign. + Module context. + Module circuits. + Module assign. + (* StructRecord + { + name := "ContextContHelperTableChip"; + ty_params := [ "F" ]; + fields := + [ + ("config", + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig") + [ F ]) + ]; + } *) + + Module Impl_delphinus_zkwasm_foreign_context_circuits_assign_ContextContHelperTableChip_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::context::circuits::assign::ContextContHelperTableChip") + [ F ]. + + (* + pub fn new(config: ContextContHelperTableConfig) -> Self { + Self { config } + } + *) + Definition new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ config ] => + ltac:(M.monadic + (let config := M.alloc (| config |) in + Value.StructRecord + "delphinus_zkwasm::foreign::context::circuits::assign::ContextContHelperTableChip" + [ ("config", M.read (| config |)) ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "new" (new F). + + (* + pub fn assign( + &self, + layouter: impl Layouter, + inputs: &Vec, + outputs: &Vec, + ) -> Result<(), Error> { + layouter.assign_region( + || "context cont helper assign", + |region| { + for (offset, input) in inputs.iter().enumerate() { + region.assign_advice( + || "context cont input index", + self.config.input, + offset + 1, // The first fixed index should be 1. + || Ok(F::from( *input)), + )?; + } + + for (offset, output) in outputs.iter().enumerate() { + region.assign_advice( + || "context cont output index", + self.config.output, + offset + 1, // The first fixed index should be 1. + || Ok(F::from( *output)), + )?; + } + + Ok(()) + }, + )?; + + Ok(()) + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Layouter_F_ ], [ self; layouter; inputs; outputs ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let layouter := M.alloc (| layouter |) in + let inputs := M.alloc (| inputs |) in + let outputs := M.alloc (| outputs |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "halo2_proofs::circuit::Layouter", + impl_Layouter_F_, + [ F ], + "assign_region", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::Region") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ]); + Ty.tuple []; + Ty.function + [ Ty.tuple [] ] + (Ty.apply (Ty.path "&") [ Ty.path "str" ]); + Ty.apply (Ty.path "&") [ Ty.path "str" ] + ] + |), + [ + layouter; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.read (| + Value.String "context cont helper assign" + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let region := M.copy (| γ |) in + M.read (| + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.path "u64" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.path "u64" ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "u64" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| inputs |) ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "u64" + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let offset := + M.copy (| + γ1_0 + |) in + let input := + M.copy (| + γ1_1 + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F + ], + "assign_advice", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + region + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "context cont input index" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::foreign::context::circuits::assign::ContextContHelperTableChip", + "config" + |), + "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig", + "input" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + offset + |), + Value.Integer + 1 + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.read (| + input + |) + |) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.path "u64" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.path "u64" ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "u64" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| outputs |) ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "u64" + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let offset := + M.copy (| + γ1_0 + |) in + let output := + M.copy (| + γ1_1 + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ + F; + F + ]; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::circuit::Region") + [ F + ], + "assign_advice", + [ + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "core::result::Result") + [ + F; + Ty.path + "halo2_proofs::plonk::error::Error" + ]); + F; + Ty.function + [ + Ty.tuple + [] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ]); + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ] + |), + [ + M.read (| + region + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (M.read (| + Value.String + "context cont output index" + |))) + ] + |) + | _ => + M.impossible (||) + end)); + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::foreign::context::circuits::assign::ContextContHelperTableChip", + "config" + |), + "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig", + "output" + |) + |); + BinOp.Panic.add (| + Integer.Usize, + M.read (| + offset + |), + Value.Integer + 1 + |); + M.closure + (fun + γ => + ltac:(M.monadic + match + γ + with + | [ + α0 + ] => + M.match_operator (| + M.alloc (| + α0 + |), + [ + fun + γ => + ltac:(M.monadic + (Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ + Ty.path + "u64" + ], + "from", + [] + |), + [ + M.read (| + M.read (| + output + |) + |) + ] + |) + ])) + ] + |) + | _ => + M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let + residual := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple + []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ + M.read (| + residual + |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let + γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := + M.copy (| + γ0_0 + |) in + val)) + ] + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_assign : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "assign" (assign F). + End Impl_delphinus_zkwasm_foreign_context_circuits_assign_ContextContHelperTableChip_F. + + (* Trait *) + (* Empty module 'ExtractContextFromTrace' *) + + Module Impl_delphinus_zkwasm_foreign_context_circuits_assign_ExtractContextFromTrace_for_specs_etable_EventTable. + Definition Self : Ty.t := Ty.path "specs::etable::EventTable". + + (* + fn get_context_inputs(&self) -> Vec { + self.entries() + .iter() + .filter_map(|e| match &e.step_info { + StepInfo::CallHost { + plugin: HostPlugin::Context, + op_index_in_plugin, + ret_val, + .. + } => { + if *op_index_in_plugin == Op::ReadContext as usize { + *ret_val + } else { + None + } + } + _ => None, + }) + .collect() + } + *) + Definition get_context_inputs (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "specs::etable::EventTableEntry" ]; + Ty.function + [ + Ty.tuple + [ Ty.apply (Ty.path "&") [ Ty.path "specs::etable::EventTableEntry" ] + ] + ] + (Ty.apply (Ty.path "core::option::Option") [ Ty.path "u64" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "specs::etable::EventTableEntry" ], + [], + "filter_map", + [ + Ty.path "u64"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "specs::etable::EventTableEntry" ] + ] + ] + (Ty.apply (Ty.path "core::option::Option") [ Ty.path "u64" ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "specs::etable::EventTableEntry" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::etable::EventTableEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::etable::EventTable", + "entries", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let e := M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| e |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "plugin" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "op_index_in_plugin" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "ret_val" + |) in + let op_index_in_plugin := M.alloc (| γ1_1 |) in + let ret_val := M.alloc (| γ1_2 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| + M.read (| op_index_in_plugin |) + |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::foreign::context::Op::ReadContext_discriminant" + |), + Value.Integer 0 + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.read (| ret_val |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn get_context_outputs(&self) -> Vec { + self.entries() + .iter() + .filter_map(|e| match &e.step_info { + StepInfo::CallHost { + plugin: HostPlugin::Context, + op_index_in_plugin, + args, + .. + } => { + if *op_index_in_plugin == Op::WriteContext as usize { + Some(args[0]) + } else { + None + } + } + _ => None, + }) + .collect() + } + *) + Definition get_context_outputs (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::filter_map::FilterMap") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "specs::etable::EventTableEntry" ]; + Ty.function + [ + Ty.tuple + [ Ty.apply (Ty.path "&") [ Ty.path "specs::etable::EventTableEntry" ] + ] + ] + (Ty.apply (Ty.path "core::option::Option") [ Ty.path "u64" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "specs::etable::EventTableEntry" ], + [], + "filter_map", + [ + Ty.path "u64"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "specs::etable::EventTableEntry" ] + ] + ] + (Ty.apply (Ty.path "core::option::Option") [ Ty.path "u64" ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "specs::etable::EventTableEntry" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::etable::EventTableEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::etable::EventTable", + "entries", + [] + |), + [ M.read (| self |) ] + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let e := M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| e |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "plugin" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "op_index_in_plugin" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "args" + |) in + let op_index_in_plugin := M.alloc (| γ1_1 |) in + let args := M.alloc (| γ1_2 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| + M.read (| op_index_in_plugin |) + |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::foreign::context::Op::WriteContext_discriminant" + |), + Value.Integer 0 + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| args |); + Value.Integer 0 + ] + |) + |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "delphinus_zkwasm::foreign::context::circuits::assign::ExtractContextFromTrace" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ + ("get_context_inputs", InstanceField.Method get_context_inputs); + ("get_context_outputs", InstanceField.Method get_context_outputs) + ]. + End Impl_delphinus_zkwasm_foreign_context_circuits_assign_ExtractContextFromTrace_for_specs_etable_EventTable. + End assign. + End circuits. + End context. +End foreign. diff --git a/CoqOfRust/zkWasm/foreign/context/circuits/config.v b/CoqOfRust/zkWasm/foreign/context/circuits/config.v new file mode 100644 index 000000000..5866d3bcb --- /dev/null +++ b/CoqOfRust/zkWasm/foreign/context/circuits/config.v @@ -0,0 +1,768 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module foreign. + Module context. + Module circuits. + Module config. + Module Impl_delphinus_zkwasm_foreign_context_circuits_ContextContHelperTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig") + [ F ]. + + (* + pub fn configure(meta: &mut ConstraintSystem, from_zero_index: Column) -> Self { + let input = meta.named_advice_column("context_input".to_string()); + let output = meta.named_advice_column("context_output".to_string()); + meta.enable_equality(input); + meta.enable_equality(output); + + ContextContHelperTableConfig { + from_zero_index, + input, + output, + _mark: PhantomData, + } + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ meta; from_zero_index ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + let from_zero_index := M.alloc (| from_zero_index |) in + M.read (| + let input := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "named_advice_column", + [] + |), + [ + M.read (| meta |); + M.call_closure (| + M.get_trait_method (| + "alloc::string::ToString", + Ty.path "str", + [], + "to_string", + [] + |), + [ M.read (| Value.String "context_input" |) ] + |) + ] + |) + |) in + let output := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "named_advice_column", + [] + |), + [ + M.read (| meta |); + M.call_closure (| + M.get_trait_method (| + "alloc::string::ToString", + Ty.path "str", + [], + "to_string", + [] + |), + [ M.read (| Value.String "context_output" |) ] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "enable_equality", + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ] + |), + [ M.read (| meta |); M.read (| input |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "enable_equality", + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ] + ] + |), + [ M.read (| meta |); M.read (| output |) ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig" + [ + ("from_zero_index", M.read (| from_zero_index |)); + ("input", M.read (| input |)); + ("output", M.read (| output |)); + ("_mark", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure" (configure F). + End Impl_delphinus_zkwasm_foreign_context_circuits_ContextContHelperTableConfig_F. + + Module Impl_delphinus_zkwasm_foreign_ForeignTableConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_foreign_context_circuits_ContextContHelperTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig") + [ F ]. + + (* + fn configure_in_table( + &self, + meta: &mut ConstraintSystem, + _key: &'static str, + expr: &dyn Fn(&mut VirtualCells<'_, F>) -> Vec>, + ) { + meta.lookup_any("context_cont input lookup", |meta| { + let mut exprs = expr(meta); + + vec![ + (exprs.remove(0), fixed_curr!(meta, self.from_zero_index)), + (exprs.remove(0), curr!(meta, self.input)), + ] + }); + + meta.lookup_any("context_cont output lookup", |meta| { + let mut exprs = expr(meta); + + let _ = exprs.remove(0); + let _ = exprs.remove(0); + + vec![ + (exprs.remove(0), fixed_curr!(meta, self.from_zero_index)), + (exprs.remove(0), curr!(meta, self.output)), + ] + }); + } + *) + Definition configure_in_table (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta; _key; expr ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let _key := M.alloc (| _key |) in + let expr := M.alloc (| expr |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "lookup_any", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "context_cont input lookup" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let exprs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", []) + ], + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + M.read (| expr |); + Value.Tuple [ M.read (| meta |) ] + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + "remove", + [] + |), + [ exprs; Value.Integer 0 ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig", + "from_zero_index" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ]; + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + "remove", + [] + |), + [ exprs; Value.Integer 0 ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig", + "input" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + ] + |) + ] + |) + |)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "lookup_any", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| Value.String "context_cont output lookup" |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let exprs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", []) + ], + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + M.read (| expr |); + Value.Tuple [ M.read (| meta |) ] + ] + |) + |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "remove", + [] + |), + [ exprs; Value.Integer 0 ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "remove", + [] + |), + [ exprs; Value.Integer 0 ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + "remove", + [] + |), + [ + exprs; + Value.Integer + 0 + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| + meta + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig", + "from_zero_index" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ]; + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + "remove", + [] + |), + [ + exprs; + Value.Integer + 0 + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_advice", + [] + |), + [ + M.read (| + meta + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + self + |), + "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig", + "output" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ] + ] + |) + ] + |) + |)) + ] + |) + |))) + ] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::foreign::ForeignTableConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ ("configure_in_table", InstanceField.Method (configure_in_table F)) ]. + End Impl_delphinus_zkwasm_foreign_ForeignTableConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_foreign_context_circuits_ContextContHelperTableConfig_F. + End config. + End circuits. + End context. +End foreign. diff --git a/CoqOfRust/zkWasm/foreign/context/circuits/mod.v b/CoqOfRust/zkWasm/foreign/context/circuits/mod.v new file mode 100644 index 000000000..337df21c5 --- /dev/null +++ b/CoqOfRust/zkWasm/foreign/context/circuits/mod.v @@ -0,0 +1,136 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module foreign. + Module context. + Module circuits. + Definition value_CONTEXT_FOREIGN_TABLE_KEY : Value.t := + M.run ltac:(M.monadic (Value.String "wasm-context-helper-table")). + + (* StructRecord + { + name := "ContextContHelperTableConfig"; + ty_params := [ "F" ]; + fields := + [ + ("from_zero_index", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]); + ("input", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + ("output", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ]); + ("_mark", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_foreign_context_circuits_ContextContHelperTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig") + [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig" + [ + ("from_zero_index", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig", + "from_zero_index" + |) + ] + |)); + ("input", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig", + "input" + |) + ] + |)); + ("output", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Advice" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig", + "output" + |) + ] + |)); + ("_mark", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::circuits::ContextContHelperTableConfig", + "_mark" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_foreign_context_circuits_ContextContHelperTableConfig_F. + End circuits. + End context. +End foreign. diff --git a/CoqOfRust/zkWasm/foreign/context/etable_op_configure.v b/CoqOfRust/zkWasm/foreign/context/etable_op_configure.v new file mode 100644 index 000000000..adbf1e477 --- /dev/null +++ b/CoqOfRust/zkWasm/foreign/context/etable_op_configure.v @@ -0,0 +1,3801 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module foreign. + Module context. + Module etable_op_configure. + (* StructRecord + { + name := "ETableContextHelperTableConfig"; + ty_params := [ "F" ]; + fields := + [ + ("plugin_index", Ty.path "u64"); + ("is_context_in_op", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_context_out_op", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("context_input_index_for_lookup", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("context_output_index_for_lookup", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("input_value", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("output_value", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("lookup_read_stack", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("lookup_write_stack", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructRecord + { + name := "ETableContextHelperTableConfigBuilder"; + ty_params := []; + fields := [ ("index", Ty.path "usize") ]; + } *) + + Module Impl_delphinus_zkwasm_foreign_InternalHostPluginBuilder_for_delphinus_zkwasm_foreign_context_etable_op_configure_ETableContextHelperTableConfigBuilder. + Definition Self : Ty.t := + Ty.path + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfigBuilder". + + (* + fn new(index: usize) -> Self { + Self { index } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ index ] => + ltac:(M.monadic + (let index := M.alloc (| index |) in + Value.StructRecord + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfigBuilder" + [ ("index", M.read (| index |)) ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "delphinus_zkwasm::foreign::InternalHostPluginBuilder" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("new", InstanceField.Method new) ]. + End Impl_delphinus_zkwasm_foreign_InternalHostPluginBuilder_for_delphinus_zkwasm_foreign_context_etable_op_configure_ETableContextHelperTableConfigBuilder. + + Module Impl_delphinus_zkwasm_foreign_EventTableForeignCallConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_foreign_context_etable_op_configure_ETableContextHelperTableConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfigBuilder". + + (* + fn configure( + self, + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + lookup_cells: &mut (impl Iterator> + Clone), + ) -> Box> { + let is_context_in_op = allocator.alloc_bit_cell(); + let is_context_out_op = allocator.alloc_bit_cell(); + let context_input_index_for_lookup = lookup_cells.next().unwrap(); + let context_output_index_for_lookup = lookup_cells.next().unwrap(); + + let input_value = lookup_cells.next().unwrap(); + let output_value = lookup_cells.next().unwrap(); + + let sp = common_config.sp_cell; + + let context_input_index = common_config.context_input_index_cell; + let context_output_index = common_config.context_output_index_cell; + + let lookup_read_stack = allocator.alloc_memory_table_lookup_read_cell( + "context stack read", + constraint_builder, + common_config.eid_cell, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |____| constant_from!(0), + move |meta| output_value.expr(meta), + move |meta| is_context_out_op.expr(meta), + ); + let lookup_write_stack = allocator.alloc_memory_table_lookup_write_cell( + "context stack write", + constraint_builder, + common_config.eid_cell, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta), + move |____| constant_from!(0), + move |meta| input_value.expr(meta), + move |meta| is_context_in_op.expr(meta), + ); + + constraint_builder.push( + "context sel", + Box::new(move |meta| { + vec![is_context_in_op.expr(meta) + is_context_out_op.expr(meta) - constant_from!(1)] + }), + ); + + constraint_builder.push( + "context lookup", + Box::new(move |meta| { + vec![ + is_context_in_op.expr(meta) + * (context_input_index_for_lookup.expr(meta) + - context_input_index.expr(meta)), + is_context_out_op.expr(meta) + * (context_output_index_for_lookup.expr(meta) + - context_output_index.expr(meta)), + ] + }), + ); + + constraint_builder.lookup( + CONTEXT_FOREIGN_TABLE_KEY, + "lookup context cont table", + Box::new(move |meta| { + vec![ + context_input_index_for_lookup.expr(meta), + input_value.expr(meta), + context_output_index_for_lookup.expr(meta), + output_value.expr(meta), + ] + }), + ); + + Box::new(ETableContextHelperTableConfig { + plugin_index: self.index as u64, + is_context_in_op, + is_context_out_op, + input_value, + output_value, + lookup_read_stack, + lookup_write_stack, + context_input_index_for_lookup, + context_output_index_for_lookup, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Iterator_Item___AllocatedUnlimitedCell_F____plus__Clone ], + [ self; common_config; allocator; constraint_builder; lookup_cells ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + let lookup_cells := M.alloc (| lookup_cells |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let is_context_in_op := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_context_out_op := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let context_input_index_for_lookup := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___AllocatedUnlimitedCell_F____plus__Clone, + [], + "next", + [] + |), + [ M.read (| lookup_cells |) ] + |) + ] + |) + |) in + let context_output_index_for_lookup := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___AllocatedUnlimitedCell_F____plus__Clone, + [], + "next", + [] + |), + [ M.read (| lookup_cells |) ] + |) + ] + |) + |) in + let input_value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___AllocatedUnlimitedCell_F____plus__Clone, + [], + "next", + [] + |), + [ M.read (| lookup_cells |) ] + |) + ] + |) + |) in + let output_value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___AllocatedUnlimitedCell_F____plus__Clone, + [], + "next", + [] + |), + [ M.read (| lookup_cells |) ] + |) + ] + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let context_input_index := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "context_input_index_cell" + |) + |) in + let context_output_index := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "context_output_index_cell" + |) + |) in + let lookup_read_stack := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "context stack read" |); + M.read (| constraint_builder |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 0 |)) |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ output_value; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_context_out_op; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let lookup_write_stack := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "context stack write" |); + M.read (| constraint_builder |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 0 |)) |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ input_value; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_context_in_op; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "context sel" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_context_in_op; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_context_out_op; + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "context lookup" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_context_in_op; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + context_input_index_for_lookup; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + context_input_index; + M.read (| meta |) + ] + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_context_out_op; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + context_output_index_for_lookup; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + context_output_index; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "lookup", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| + M.get_constant (| + "delphinus_zkwasm::foreign::context::circuits::CONTEXT_FOREIGN_TABLE_KEY" + |) + |); + M.read (| Value.String "lookup context cont table" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + context_input_index_for_lookup; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ input_value; M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + context_output_index_for_lookup; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + output_value; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfig" + [ + ("plugin_index", + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfigBuilder", + "index" + |) + |))); + ("is_context_in_op", M.read (| is_context_in_op |)); + ("is_context_out_op", M.read (| is_context_out_op |)); + ("input_value", M.read (| input_value |)); + ("output_value", M.read (| output_value |)); + ("lookup_read_stack", M.read (| lookup_read_stack |)); + ("lookup_write_stack", M.read (| lookup_write_stack |)); + ("context_input_index_for_lookup", + M.read (| context_input_index_for_lookup |)); + ("context_output_index_for_lookup", + M.read (| context_output_index_for_lookup |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::foreign::EventTableForeignCallConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_foreign_EventTableForeignCallConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_foreign_context_etable_op_configure_ETableContextHelperTableConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_foreign_context_etable_op_configure_ETableContextHelperTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfig") + [ F ]. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + constant_from_bn!( + &(BigUint::from(OpcodeClass::ForeignPluginStart as u64 + self.plugin_index) + << OPCODE_CLASS_SHIFT) + ) + self.is_context_out_op.expr(meta) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + BinOp.Panic.add (| + Integer.U64, + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 28 + |)), + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfig", + "plugin_index" + |) + |) + |) + ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_CLASS_SHIFT" |) + |) + ] + |) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfig", + "is_context_out_op" + |); + M.read (| meta |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::CallHost { + plugin, + args, + ret_val, + op_index_in_plugin, + .. + } => { + assert_eq!( *plugin, HostPlugin::Context); + + if *op_index_in_plugin == Op::ReadContext as usize { + let value = ret_val.unwrap(); + + self.input_value.assign(ctx, F::from(value))?; + self.lookup_write_stack.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp, + LocationType::Stack, + false, + value, + )?; + self.is_context_in_op.assign_bool(ctx, true)?; + self.context_input_index_for_lookup + .assign(ctx, F::from(step.current.context_in_index as u64))?; + + Ok(()) + } else { + let value = *args.first().unwrap(); + + self.output_value.assign(ctx, F::from(value))?; + self.lookup_read_stack.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + false, + value, + )?; + self.is_context_out_op.assign_bool(ctx, true)?; + self.context_output_index_for_lookup + .assign(ctx, F::from(step.current.context_out_index as u64))?; + + Ok(()) + } + } + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "plugin" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "args" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "ret_val" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "op_index_in_plugin" + |) in + let plugin := M.alloc (| γ1_0 |) in + let args := M.alloc (| γ1_1 |) in + let ret_val := M.alloc (| γ1_2 |) in + let op_index_in_plugin := M.alloc (| γ1_3 |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.read (| plugin |); + M.alloc (| + Value.StructTuple + "specs::host_function::HostPlugin::Context" + [] + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "specs::host_function::HostPlugin", + [ + Ty.path + "specs::host_function::HostPlugin" + ], + "eq", + [] + |), + [ + M.read (| left_val |); + M.read (| right_val |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ + Ty.path + "specs::host_function::HostPlugin"; + Ty.path + "specs::host_function::HostPlugin" + ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| M.read (| op_index_in_plugin |) |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::foreign::context::Op::ReadContext_discriminant" + |), + Value.Integer 0 + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ], + "unwrap", + [] + |), + [ M.read (| M.read (| ret_val |) |) ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfig", + "input_value" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| value |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfig", + "lookup_write_stack" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool false; + M.read (| value |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfig", + "is_context_in_op" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfig", + "context_input_index_for_lookup" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "context_in_index" + |) + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (let value := + M.copy (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.path "u64" ] ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u64" ], + "first", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| args |) ] + |) + ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfig", + "output_value" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| value |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfig", + "lookup_read_stack" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool false; + M.read (| value |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfig", + "is_context_out_op" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfig", + "context_output_index_for_lookup" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "context_out_index" + |) + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ] + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn mops(&self, meta: &mut VirtualCells<'_, F>) -> Option> { + Some(self.is_context_in_op.expr(meta)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfig", + "is_context_in_op" + |); + M.read (| meta |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, entry: &EventTableEntry) -> u32 { + match &entry.step_info { + StepInfo::CallHost { + plugin, + op_index_in_plugin, + .. + } => { + assert_eq!( *plugin, HostPlugin::Context); + + ( *op_index_in_plugin == Op::ReadContext as usize) as u32 + } + _ => unreachable!(), + } + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let entry := M.alloc (| entry |) in + M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "plugin" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "op_index_in_plugin" + |) in + let plugin := M.alloc (| γ1_0 |) in + let op_index_in_plugin := M.alloc (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.read (| plugin |); + M.alloc (| + Value.StructTuple "specs::host_function::HostPlugin::Context" [] + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::host_function::HostPlugin", + [ Ty.path "specs::host_function::HostPlugin" + ], + "eq", + [] + |), + [ M.read (| left_val |); M.read (| right_val |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ + Ty.path "specs::host_function::HostPlugin"; + Ty.path "specs::host_function::HostPlugin" + ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| + M.rust_cast + (BinOp.Pure.eq + (M.read (| M.read (| op_index_in_plugin |) |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::foreign::context::Op::ReadContext_discriminant" + |), + Value.Integer 0 + |)))) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "internal error: entered unreachable code" |) + ] + |) + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, meta: &mut VirtualCells<'_, F>) -> Option> { + /* + * context_out: sp + 1 + * context_in: sp - 1 + */ + Some(constant!(-F::one()) + constant_from!(2) * self.is_context_out_op.expr(meta)) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| "core::ops::arith::Neg", F, [], "neg", [] |), + [ + M.call_closure (| + M.get_trait_method (| "ff::Field", F, [], "one", [] |), + [] + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "mul", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 2 |)) |) ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfig", + "is_context_out_op" + |); + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn is_context_input_op(&self, entry: &EventTableEntry) -> bool { + match &entry.step_info { + StepInfo::CallHost { + plugin, + op_index_in_plugin, + .. + } => { + assert_eq!( *plugin, HostPlugin::Context); + + return *op_index_in_plugin == Op::ReadContext as usize; + } + _ => unreachable!(), + } + } + *) + Definition is_context_input_op (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "plugin" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "op_index_in_plugin" + |) in + let plugin := M.alloc (| γ1_0 |) in + let op_index_in_plugin := M.alloc (| γ1_1 |) in + M.alloc (| + M.never_to_any (| + M.read (| + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.read (| plugin |); + M.alloc (| + Value.StructTuple + "specs::host_function::HostPlugin::Context" + [] + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "specs::host_function::HostPlugin", + [ + Ty.path + "specs::host_function::HostPlugin" + ], + "eq", + [] + |), + [ + M.read (| left_val |); + M.read (| right_val |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ + Ty.path + "specs::host_function::HostPlugin"; + Ty.path + "specs::host_function::HostPlugin" + ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.return_ (| + BinOp.Pure.eq + (M.read (| M.read (| op_index_in_plugin |) |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::foreign::context::Op::ReadContext_discriminant" + |), + Value.Integer 0 + |))) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn context_input_index_increase( + &self, + meta: &mut VirtualCells<'_, F>, + _common_config: &EventTableCommonConfig, + ) -> Option> { + Some(self.is_context_in_op.expr(meta)) + } + *) + Definition context_input_index_increase (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta; _common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let _common_config := M.alloc (| _common_config |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfig", + "is_context_in_op" + |); + M.read (| meta |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn is_context_output_op(&self, entry: &EventTableEntry) -> bool { + match &entry.step_info { + StepInfo::CallHost { + plugin, + op_index_in_plugin, + .. + } => { + assert_eq!( *plugin, HostPlugin::Context); + + return *op_index_in_plugin == Op::WriteContext as usize; + } + _ => unreachable!(), + } + } + *) + Definition is_context_output_op (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "plugin" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "op_index_in_plugin" + |) in + let plugin := M.alloc (| γ1_0 |) in + let op_index_in_plugin := M.alloc (| γ1_1 |) in + M.alloc (| + M.never_to_any (| + M.read (| + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.read (| plugin |); + M.alloc (| + Value.StructTuple + "specs::host_function::HostPlugin::Context" + [] + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "specs::host_function::HostPlugin", + [ + Ty.path + "specs::host_function::HostPlugin" + ], + "eq", + [] + |), + [ + M.read (| left_val |); + M.read (| right_val |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ + Ty.path + "specs::host_function::HostPlugin"; + Ty.path + "specs::host_function::HostPlugin" + ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.return_ (| + BinOp.Pure.eq + (M.read (| M.read (| op_index_in_plugin |) |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::foreign::context::Op::WriteContext_discriminant" + |), + Value.Integer 0 + |))) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn context_output_index_increase( + &self, + meta: &mut VirtualCells<'_, F>, + _common_config: &EventTableCommonConfig, + ) -> Option> { + Some(self.is_context_out_op.expr(meta)) + } + *) + Definition context_output_index_increase + (F : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta; _common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let _common_config := M.alloc (| _common_config |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::etable_op_configure::ETableContextHelperTableConfig", + "is_context_out_op" + |); + M.read (| meta |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)); + ("sp_diff", InstanceField.Method (sp_diff F)); + ("is_context_input_op", InstanceField.Method (is_context_input_op F)); + ("context_input_index_increase", + InstanceField.Method (context_input_index_increase F)); + ("is_context_output_op", InstanceField.Method (is_context_output_op F)); + ("context_output_index_increase", + InstanceField.Method (context_output_index_increase F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_foreign_context_etable_op_configure_ETableContextHelperTableConfig_F. + End etable_op_configure. + End context. +End foreign. diff --git a/CoqOfRust/zkWasm/foreign/context/mod.v b/CoqOfRust/zkWasm/foreign/context/mod.v new file mode 100644 index 000000000..086ed3ee9 --- /dev/null +++ b/CoqOfRust/zkWasm/foreign/context/mod.v @@ -0,0 +1,500 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module foreign. + Module context. + (* + Enum Op + { + ty_params := []; + variants := + [ + { + name := "ReadContext"; + item := StructTuple []; + discriminant := Some 0; + }; + { + name := "WriteContext"; + item := StructTuple []; + discriminant := Some 1; + } + ]; + } + *) + + (* StructTuple + { + name := "ContextOutput"; + ty_params := []; + fields := + [ Ty.apply (Ty.path "alloc::vec::Vec") [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ] + ]; + } *) + + Module Impl_core_clone_Clone_for_delphinus_zkwasm_foreign_context_ContextOutput. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::foreign::context::ContextOutput". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructTuple + "delphinus_zkwasm::foreign::context::ContextOutput" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::ContextOutput", + 0 + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_delphinus_zkwasm_foreign_context_ContextOutput. + + Module Impl_core_default_Default_for_delphinus_zkwasm_foreign_context_ContextOutput. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::foreign::context::ContextOutput". + + (* Default *) + Definition default (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [] => + ltac:(M.monadic + (Value.StructTuple + "delphinus_zkwasm::foreign::context::ContextOutput" + [ + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + [], + "default", + [] + |), + [] + |) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::default::Default" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("default", InstanceField.Method default) ]. + End Impl_core_default_Default_for_delphinus_zkwasm_foreign_context_ContextOutput. + + Module Impl_delphinus_zkwasm_foreign_context_ContextOutput. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::foreign::context::ContextOutput". + + (* + pub fn write(&self, fd: &mut File) -> io::Result<()> { + fd.write_all("0x".as_bytes())?; + + for value in &self.0 { + let bytes = value.to_le_bytes(); + let s = hex::encode(bytes); + fd.write_all(&s.as_bytes())?; + } + + fd.write_all(":bytes-packed".as_bytes())?; + + Ok(()) + } + *) + Definition write (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; fd ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let fd := M.alloc (| fd |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "std::io::Write", + Ty.path "std::fs::File", + [], + "write_all", + [] + |), + [ + M.read (| fd |); + M.call_closure (| + M.get_associated_function (| Ty.path "str", "as_bytes", [] |), + [ M.read (| Value.String "0x" |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ] + ], + [], + "into_iter", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::ContextOutput", + 0 + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "u64" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let value := M.copy (| γ0_0 |) in + let bytes := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u64", + "to_le_bytes", + [] + |), + [ M.read (| M.read (| value |) |) ] + |) + |) in + let s := + M.alloc (| + M.call_closure (| + M.get_function (| + "hex::encode", + [ Ty.apply (Ty.path "array") [ Ty.path "u8" ] ] + |), + [ M.read (| bytes |) ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "std::io::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "std::io::Write", + Ty.path "std::fs::File", + [], + "write_all", + [] + |), + [ + M.read (| fd |); + M.call_closure (| + M.get_associated_function (| + Ty.path "alloc::string::String", + "as_bytes", + [] + |), + [ s ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "std::io::error::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "std::io::Write", + Ty.path "std::fs::File", + [], + "write_all", + [] + |), + [ + M.read (| fd |); + M.call_closure (| + M.get_associated_function (| Ty.path "str", "as_bytes", [] |), + [ M.read (| Value.String ":bytes-packed" |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "std::io::error::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "std::io::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_write : M.IsAssociatedFunction Self "write" write. + End Impl_delphinus_zkwasm_foreign_context_ContextOutput. + End context. +End foreign. diff --git a/CoqOfRust/zkWasm/foreign/context/runtime.v b/CoqOfRust/zkWasm/foreign/context/runtime.v new file mode 100644 index 000000000..e59dc6bb2 --- /dev/null +++ b/CoqOfRust/zkWasm/foreign/context/runtime.v @@ -0,0 +1,725 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module foreign. + Module context. + Module runtime. + (* StructRecord + { + name := "Context"; + ty_params := []; + fields := + [ + ("inputs", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ]); + ("outputs", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ]) + ]; + } *) + + Module Impl_delphinus_zkwasm_foreign_context_runtime_Context. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::foreign::context::runtime::Context". + + (* + fn new(context_input: Vec) -> Self { + let mut inputs = context_input.clone(); + inputs.reverse(); + + Context { + inputs, + outputs: vec![], + } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ context_input ] => + ltac:(M.monadic + (let context_input := M.alloc (| context_input |) in + M.read (| + let inputs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ context_input ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u64" ], + "reverse", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + [], + "deref_mut", + [] + |), + [ inputs ] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::foreign::context::runtime::Context" + [ + ("inputs", M.read (| inputs |)); + ("outputs", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + + (* + pub fn write_context(&mut self, value: u64) { + self.outputs.push(value) + } + *) + Definition write_context (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let value := M.alloc (| value |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::runtime::Context", + "outputs" + |); + M.read (| value |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_write_context : + M.IsAssociatedFunction Self "write_context" write_context. + + (* + pub fn read_context(&mut self) -> u64 { + self.inputs + .pop() + .expect("Failed to pop value from context_in array, please check you inputs") + } + *) + Definition read_context (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.path "u64" ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "pop", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::runtime::Context", + "inputs" + |) + ] + |); + M.read (| + Value.String + "Failed to pop value from context_in array, please check you inputs" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_read_context : + M.IsAssociatedFunction Self "read_context" read_context. + End Impl_delphinus_zkwasm_foreign_context_runtime_Context. + + Module Impl_delphinus_zkwasm_runtime_host_ForeignContext_for_delphinus_zkwasm_foreign_context_runtime_Context. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::foreign::context::runtime::Context". + + (* + fn expose_context_outputs(&self) -> Vec { + self.outputs.clone() + } + *) + Definition expose_context_outputs (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::context::runtime::Context", + "outputs" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "delphinus_zkwasm::runtime::host::ForeignContext" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("expose_context_outputs", InstanceField.Method expose_context_outputs) ]. + End Impl_delphinus_zkwasm_runtime_host_ForeignContext_for_delphinus_zkwasm_foreign_context_runtime_Context. + + (* + pub fn register_context_foreign(env: &mut HostEnv, context_input: Vec) { + env.internal_env.register_plugin( + "context plugin", + HostPlugin::Context, + Box::new(Context::new(context_input)), + ); + + env.internal_env.register_function( + "wasm_read_context", + Signature { + params: vec![], + return_type: Some(ValueType::I64), + }, + HostPlugin::Context, + Op::ReadContext as usize, + Rc::new( + |_obs, context: &mut dyn ForeignContext, _args: RuntimeArgs| { + let context = context.downcast_mut::().unwrap(); + + Some(wasmi::RuntimeValue::I64(context.read_context() as i64)) + }, + ), + ); + + env.internal_env.register_function( + "wasm_write_context", + Signature { + params: vec![ValueType::I64], + return_type: None, + }, + HostPlugin::Context, + Op::WriteContext as usize, + Rc::new( + |_obs, context: &mut dyn ForeignContext, args: RuntimeArgs| { + let context = context.downcast_mut::().unwrap(); + + let value: i64 = args.nth(0); + context.write_context(value as u64); + + None + }, + ), + ); + } + *) + Definition register_context_foreign (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ env; context_input ] => + ltac:(M.monadic + (let env := M.alloc (| env |) in + let context_input := M.alloc (| context_input |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv", + "register_plugin", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| env |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "internal_env" + |); + M.read (| Value.String "context plugin" |); + Value.StructTuple "specs::host_function::HostPlugin::Context" []; + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.path "delphinus_zkwasm::foreign::context::runtime::Context"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "delphinus_zkwasm::foreign::context::runtime::Context", + "new", + [] + |), + [ M.read (| context_input |) ] + |) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv", + "register_function", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| env |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "internal_env" + |); + M.read (| Value.String "wasm_read_context" |); + Value.StructRecord + "specs::host_function::Signature" + [ + ("params", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("return_type", + Value.StructTuple + "core::option::Option::Some" + [ Value.StructTuple "specs::types::ValueType::I64" [] ]) + ]; + Value.StructTuple "specs::host_function::HostPlugin::Context" []; + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::foreign::context::Op::ReadContext_discriminant" + |), + Value.Integer 0 + |)); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ] + ]; + Ty.path "wasmi::host::RuntimeArgs" + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi_core::value::Value" ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let _obs := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let context := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α2 |), + [ + fun γ => + ltac:(M.monadic + (let _args := M.copy (| γ |) in + M.read (| + let context := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.path + "delphinus_zkwasm::foreign::context::runtime::Context" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ], + "downcast_mut", + [ + Ty.path + "delphinus_zkwasm::foreign::context::runtime::Context" + ] + |), + [ M.read (| context |) ] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "wasmi_core::value::Value::I64" + [ + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::foreign::context::runtime::Context", + "read_context", + [] + |), + [ M.read (| context |) ] + |)) + ] + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv", + "register_function", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| env |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "internal_env" + |); + M.read (| Value.String "wasm_write_context" |); + Value.StructRecord + "specs::host_function::Signature" + [ + ("params", + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "specs::types::ValueType" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::types::ValueType" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ Value.StructTuple "specs::types::ValueType::I64" [] ] + |) + ] + |) + |)) + ] + |)); + ("return_type", Value.StructTuple "core::option::Option::None" []) + ]; + Value.StructTuple "specs::host_function::HostPlugin::Context" []; + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::foreign::context::Op::WriteContext_discriminant" + |), + Value.Integer 0 + |)); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ] + ]; + Ty.path "wasmi::host::RuntimeArgs" + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi_core::value::Value" ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let _obs := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let context := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α2 |), + [ + fun γ => + ltac:(M.monadic + (let args := M.copy (| γ |) in + M.read (| + let context := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.path + "delphinus_zkwasm::foreign::context::runtime::Context" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ], + "downcast_mut", + [ + Ty.path + "delphinus_zkwasm::foreign::context::runtime::Context" + ] + |), + [ M.read (| context |) ] + |) + ] + |) + |) in + let value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::host::RuntimeArgs", + "nth", + [ Ty.path "i64" ] + |), + [ args; Value.Integer 0 ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::foreign::context::runtime::Context", + "write_context", + [] + |), + [ + M.read (| context |); + M.rust_cast + (M.read (| value |)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + End runtime. + End context. +End foreign. diff --git a/CoqOfRust/zkWasm/foreign/log_helper/mod.v b/CoqOfRust/zkWasm/foreign/log_helper/mod.v new file mode 100644 index 000000000..421df28b0 --- /dev/null +++ b/CoqOfRust/zkWasm/foreign/log_helper/mod.v @@ -0,0 +1,470 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module foreign. + Module log_helper. + (* StructTuple + { + name := "Context"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_runtime_host_ForeignContext_for_delphinus_zkwasm_foreign_log_helper_Context. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::foreign::log_helper::Context". + + Axiom Implements : + M.IsTraitInstance + "delphinus_zkwasm::runtime::host::ForeignContext" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_delphinus_zkwasm_runtime_host_ForeignContext_for_delphinus_zkwasm_foreign_log_helper_Context. + + (* + pub fn register_log_foreign(env: &mut HostEnv) { + let foreign_log_plugin = env + .external_env + .register_plugin("foreign_print", Box::new(Context)); + + let print = Rc::new( + |_observer: &Observer, _context: &mut dyn ForeignContext, args: wasmi::RuntimeArgs| { + let value: u64 = args.nth(0); + println!("{}", value); + None + }, + ); + + let printchar = Rc::new( + |_observer: &Observer, _context: &mut dyn ForeignContext, args: wasmi::RuntimeArgs| { + let value: u64 = args.nth(0); + print!("{}", value as u8 as char); + None + }, + ); + + env.external_env.register_function( + "wasm_dbg", + Log as usize, + ExternalHostCallSignature::Argument, + foreign_log_plugin.clone(), + print, + ); + + env.external_env.register_function( + "wasm_dbg_char", + LogChar as usize, + ExternalHostCallSignature::Argument, + foreign_log_plugin, + printchar, + ); + } + *) + Definition register_log_foreign (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ env ] => + ltac:(M.monadic + (let env := M.alloc (| env |) in + M.read (| + let foreign_log_plugin := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ExternalCircuitEnv", + "register_plugin", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| env |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "external_env" + |); + M.read (| Value.String "foreign_print" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.path "delphinus_zkwasm::foreign::log_helper::Context"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ Value.StructTuple "delphinus_zkwasm::foreign::log_helper::Context" [] ] + |)) + ] + |) + |) in + let print := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "delphinus_zkwasm::runtime::monitor::observer::Observer" + ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ] + ]; + Ty.path "wasmi::host::RuntimeArgs" + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi_core::value::Value" ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let _observer := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let _context := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α2 |), + [ + fun γ => + ltac:(M.monadic + (let args := M.copy (| γ |) in + M.read (| + let value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::host::RuntimeArgs", + "nth", + [ Ty.path "u64" ] + |), + [ args; Value.Integer 0 ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "std::io::stdio::_print", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String "" + |); + M.read (| + Value.String " +" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "u64" ] + |), + [ value ] + |) + ] + |)) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) in + M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let printchar := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "delphinus_zkwasm::runtime::monitor::observer::Observer" + ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ] + ]; + Ty.path "wasmi::host::RuntimeArgs" + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi_core::value::Value" ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let _observer := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let _context := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α2 |), + [ + fun γ => + ltac:(M.monadic + (let args := M.copy (| γ |) in + M.read (| + let value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::host::RuntimeArgs", + "nth", + [ Ty.path "u64" ] + |), + [ args; Value.Integer 0 ] + |) + |) in + let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "std::io::stdio::_print", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String "" + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ Ty.path "char" ] + |), + [ + M.alloc (| + M.rust_cast + (M.rust_cast + (M.read (| + value + |))) + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) in + M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ExternalCircuitEnv", + "register_function", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| env |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "external_env" + |); + M.read (| Value.String "wasm_dbg" |); + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "zkwasm_host_circuits::host::ForeignInst::Log_discriminant" + |), + Value.Integer 0 + |)); + Value.StructTuple + "specs::external_host_call_table::ExternalHostCallSignature::Argument" + []; + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.path "delphinus_zkwasm::runtime::host::ForeignPlugin"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ foreign_log_plugin ] + |); + (* Unsize *) M.pointer_coercion (M.read (| print |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ExternalCircuitEnv", + "register_function", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| env |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "external_env" + |); + M.read (| Value.String "wasm_dbg_char" |); + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "zkwasm_host_circuits::host::ForeignInst::Log_discriminant" + |), + Value.Integer 36 + |)); + Value.StructTuple + "specs::external_host_call_table::ExternalHostCallSignature::Argument" + []; + M.read (| foreign_log_plugin |); + (* Unsize *) M.pointer_coercion (M.read (| printchar |)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + End log_helper. +End foreign. diff --git a/CoqOfRust/zkWasm/foreign/mod.v b/CoqOfRust/zkWasm/foreign/mod.v new file mode 100644 index 000000000..77c3466c8 --- /dev/null +++ b/CoqOfRust/zkWasm/foreign/mod.v @@ -0,0 +1,30 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module foreign. + (* + pub fn foreign_table_enable_lines(k: u32) -> usize { + 1 << (k as usize - 1) + } + *) + Definition foreign_table_enable_lines (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ k ] => + ltac:(M.monadic + (let k := M.alloc (| k |) in + BinOp.Panic.shl (| + Value.Integer 1, + BinOp.Panic.sub (| Integer.Usize, M.rust_cast (M.read (| k |)), Value.Integer 1 |) + |))) + | _, _ => M.impossible + end. + + (* Trait *) + (* Empty module 'ForeignTableConfig' *) + + (* Trait *) + (* Empty module 'EventTableForeignCallConfigBuilder' *) + + (* Trait *) + (* Empty module 'InternalHostPluginBuilder' *) +End foreign. diff --git a/CoqOfRust/zkWasm/foreign/require_helper/etable_op_configure.v b/CoqOfRust/zkWasm/foreign/require_helper/etable_op_configure.v new file mode 100644 index 000000000..1dccfeb96 --- /dev/null +++ b/CoqOfRust/zkWasm/foreign/require_helper/etable_op_configure.v @@ -0,0 +1,1336 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module foreign. + Module require_helper. + Module etable_op_configure. + (* StructRecord + { + name := "ETableRequireHelperTableConfig"; + ty_params := [ "F" ]; + fields := + [ + ("plugin_index", Ty.path "usize"); + ("cond", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("cond_inv", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("memory_table_lookup_read_stack", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]) + ]; + } *) + + (* StructRecord + { + name := "ETableRequireHelperTableConfigBuilder"; + ty_params := []; + fields := [ ("index", Ty.path "usize") ]; + } *) + + Module Impl_delphinus_zkwasm_foreign_InternalHostPluginBuilder_for_delphinus_zkwasm_foreign_require_helper_etable_op_configure_ETableRequireHelperTableConfigBuilder. + Definition Self : Ty.t := + Ty.path + "delphinus_zkwasm::foreign::require_helper::etable_op_configure::ETableRequireHelperTableConfigBuilder". + + (* + fn new(index: usize) -> Self { + Self { index } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ index ] => + ltac:(M.monadic + (let index := M.alloc (| index |) in + Value.StructRecord + "delphinus_zkwasm::foreign::require_helper::etable_op_configure::ETableRequireHelperTableConfigBuilder" + [ ("index", M.read (| index |)) ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "delphinus_zkwasm::foreign::InternalHostPluginBuilder" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("new", InstanceField.Method new) ]. + End Impl_delphinus_zkwasm_foreign_InternalHostPluginBuilder_for_delphinus_zkwasm_foreign_require_helper_etable_op_configure_ETableRequireHelperTableConfigBuilder. + + Module Impl_delphinus_zkwasm_foreign_EventTableForeignCallConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_foreign_require_helper_etable_op_configure_ETableRequireHelperTableConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::foreign::require_helper::etable_op_configure::ETableRequireHelperTableConfigBuilder". + + (* + fn configure( + self, + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + _lookup_cells: &mut (impl Iterator> + Clone), + ) -> Box> { + let cond = allocator.alloc_u64_cell(); + let cond_inv = allocator.alloc_unlimited_cell(); + + constraint_builder.push( + "require: cond is not zero", + Box::new(move |meta| vec![(cond.expr(meta) * cond_inv.expr(meta) - constant_from!(1))]), + ); + + let eid = common_config.eid_cell; + let sp = common_config.sp_cell; + + let memory_table_lookup_read_stack = allocator.alloc_memory_table_lookup_read_cell( + "require stack read", + constraint_builder, + eid, + move |_| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |____| constant_from!(1), + move |meta| cond.expr(meta), + move |_| constant_from!(1), + ); + + Box::new(ETableRequireHelperTableConfig { + plugin_index: self.index, + cond, + cond_inv, + memory_table_lookup_read_stack, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Iterator_Item___AllocatedUnlimitedCell_F____plus__Clone ], + [ self; common_config; allocator; constraint_builder; _lookup_cells ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + let _lookup_cells := M.alloc (| _lookup_cells |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let cond := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let cond_inv := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_unlimited_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "require: cond is not zero" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + cond; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + cond_inv; + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let memory_table_lookup_read_stack := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "require stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ cond; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::require_helper::etable_op_configure::ETableRequireHelperTableConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::foreign::require_helper::etable_op_configure::ETableRequireHelperTableConfig" + [ + ("plugin_index", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::foreign::require_helper::etable_op_configure::ETableRequireHelperTableConfigBuilder", + "index" + |) + |)); + ("cond", M.read (| cond |)); + ("cond_inv", M.read (| cond_inv |)); + ("memory_table_lookup_read_stack", + M.read (| memory_table_lookup_read_stack |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::foreign::EventTableForeignCallConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_foreign_EventTableForeignCallConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_foreign_require_helper_etable_op_configure_ETableRequireHelperTableConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_foreign_require_helper_etable_op_configure_ETableRequireHelperTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::require_helper::etable_op_configure::ETableRequireHelperTableConfig") + [ F ]. + + (* + fn opcode(&self, _meta: &mut VirtualCells<'_, F>) -> Expression { + constant_from_bn!( + &(BigUint::from(OpcodeClass::ForeignPluginStart as u64 + self.plugin_index as u64) + << OPCODE_CLASS_SHIFT) + ) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| "delphinus_zkwasm::circuits::utils::bn_to_field", [ F ] |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + BinOp.Panic.add (| + Integer.U64, + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 28 + |)), + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::require_helper::etable_op_configure::ETableRequireHelperTableConfig", + "plugin_index" + |) + |)) + |) + ] + |); + M.read (| M.get_constant (| "specs::itable::OPCODE_CLASS_SHIFT" |) |) + ] + |) + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::CallHost { args, .. } => { + let cond = args[0]; + + self.cond.assign(ctx, cond)?; + self.cond_inv + .assign(ctx, F::from(cond).invert().unwrap_or(F::zero()))?; + self.memory_table_lookup_read_stack.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + true, + cond, + )?; + + Ok(()) + } + + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "args" + |) in + let args := M.alloc (| γ1_0 |) in + let cond := + M.copy (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + [ Ty.path "usize" ], + "index", + [] + |), + [ M.read (| args |); Value.Integer 0 ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::require_helper::etable_op_configure::ETableRequireHelperTableConfig", + "cond" + |); + M.read (| ctx |); + M.read (| cond |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::require_helper::etable_op_configure::ETableRequireHelperTableConfig", + "cond_inv" + |); + M.read (| ctx |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "subtle::CtOption") [ F ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "invert", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| cond |) ] + |) + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "ff::Field", + F, + [], + "zero", + [] + |), + [] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::require_helper::etable_op_configure::ETableRequireHelperTableConfig", + "memory_table_lookup_read_stack" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple "specs::mtable::LocationType::Stack" []; + Value.Bool true; + M.read (| cond |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn sp_diff(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { + Some(constant_from!(1)) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; _meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _meta := M.alloc (| _meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) ] + |) + ] + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("sp_diff", InstanceField.Method (sp_diff F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_foreign_require_helper_etable_op_configure_ETableRequireHelperTableConfig_F. + End etable_op_configure. + End require_helper. +End foreign. diff --git a/CoqOfRust/zkWasm/foreign/require_helper/mod.v b/CoqOfRust/zkWasm/foreign/require_helper/mod.v new file mode 100644 index 000000000..8871d265b --- /dev/null +++ b/CoqOfRust/zkWasm/foreign/require_helper/mod.v @@ -0,0 +1,309 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module foreign. + Module require_helper. + (* StructTuple + { + name := "Context"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_runtime_host_ForeignContext_for_delphinus_zkwasm_foreign_require_helper_Context. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::foreign::require_helper::Context". + + Axiom Implements : + M.IsTraitInstance + "delphinus_zkwasm::runtime::host::ForeignContext" + Self + (* Trait polymorphic types *) [] + (* Instance *) []. + End Impl_delphinus_zkwasm_runtime_host_ForeignContext_for_delphinus_zkwasm_foreign_require_helper_Context. + + (* + pub fn register_require_foreign(env: &mut HostEnv) { + let require = Rc::new( + |_observer: &Observer, _context: &mut dyn ForeignContext, args: wasmi::RuntimeArgs| { + let cond: u32 = args.nth(0); + + if cond == 0 { + panic!( + "require is not satisfied, which is a \ + false assertion in the wasm code. Please check \ + the logic of your image or input." + ) + } + + None + }, + ); + + env.internal_env + .register_plugin("require plugin", HostPlugin::Require, Box::new(Context)); + + env.internal_env.register_function( + "require", + specs::host_function::Signature { + params: vec![ValueType::I32], + return_type: None, + }, + HostPlugin::Require, + 0, + require, + ); + } + *) + Definition register_require_foreign (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ env ] => + ltac:(M.monadic + (let env := M.alloc (| env |) in + M.read (| + let require := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "delphinus_zkwasm::runtime::monitor::observer::Observer" + ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ] + ]; + Ty.path "wasmi::host::RuntimeArgs" + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi_core::value::Value" ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let _observer := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let _context := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α2 |), + [ + fun γ => + ltac:(M.monadic + (let args := M.copy (| γ |) in + M.read (| + let cond := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::host::RuntimeArgs", + "nth", + [ Ty.path "u32" ] + |), + [ args; Value.Integer 0 ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| cond |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic_fmt", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "require is not satisfied, which is a false assertion in the wasm code. Please check the logic of your image or input." + |) + ] + |)) + ] + |) + ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv", + "register_plugin", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| env |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "internal_env" + |); + M.read (| Value.String "require plugin" |); + Value.StructTuple "specs::host_function::HostPlugin::Require" []; + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.path "delphinus_zkwasm::foreign::require_helper::Context"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ Value.StructTuple "delphinus_zkwasm::foreign::require_helper::Context" [] + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv", + "register_function", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| env |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "internal_env" + |); + M.read (| Value.String "require" |); + Value.StructRecord + "specs::host_function::Signature" + [ + ("params", + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "specs::types::ValueType" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::types::ValueType" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ Value.StructTuple "specs::types::ValueType::I32" [] ] + |) + ] + |) + |)) + ] + |)); + ("return_type", Value.StructTuple "core::option::Option::None" []) + ]; + Value.StructTuple "specs::host_function::HostPlugin::Require" []; + Value.Integer 0; + (* Unsize *) M.pointer_coercion (M.read (| require |)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + End require_helper. +End foreign. diff --git a/CoqOfRust/zkWasm/foreign/wasm_input_helper/circuits/config.v b/CoqOfRust/zkWasm/foreign/wasm_input_helper/circuits/config.v new file mode 100644 index 000000000..c2d2aa918 --- /dev/null +++ b/CoqOfRust/zkWasm/foreign/wasm_input_helper/circuits/config.v @@ -0,0 +1,384 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module foreign. + Module wasm_input_helper. + Module circuits. + Module config. + Module Impl_delphinus_zkwasm_foreign_wasm_input_helper_circuits_WasmInputHelperTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::circuits::WasmInputHelperTableConfig") + [ F ]. + + (* + pub fn configure(meta: &mut ConstraintSystem, from_zero_index: Column) -> Self { + let input = meta.instance_column(); + meta.enable_equality(input); + + WasmInputHelperTableConfig { + from_zero_index, + input, + _mark: std::marker::PhantomData, + } + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ meta; from_zero_index ] => + ltac:(M.monadic + (let meta := M.alloc (| meta |) in + let from_zero_index := M.alloc (| from_zero_index |) in + M.read (| + let input := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "instance_column", + [] + |), + [ M.read (| meta |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "enable_equality", + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ] + ] + |), + [ M.read (| meta |); M.read (| input |) ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::foreign::wasm_input_helper::circuits::WasmInputHelperTableConfig" + [ + ("from_zero_index", M.read (| from_zero_index |)); + ("input", M.read (| input |)); + ("_mark", Value.StructTuple "core::marker::PhantomData" []) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_configure : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "configure" (configure F). + End Impl_delphinus_zkwasm_foreign_wasm_input_helper_circuits_WasmInputHelperTableConfig_F. + + Module Impl_delphinus_zkwasm_foreign_ForeignTableConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_foreign_wasm_input_helper_circuits_WasmInputHelperTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::circuits::WasmInputHelperTableConfig") + [ F ]. + + (* + fn configure_in_table( + &self, + meta: &mut ConstraintSystem, + key: &'static str, + expr: &dyn Fn(&mut VirtualCells<'_, F>) -> Vec>, + ) { + meta.lookup_any(key, |meta| { + let mut exprs = expr(meta); + + vec![ + (exprs.remove(0), fixed_curr!(meta, self.from_zero_index)), + (exprs.remove(0), instance_prev!(meta, self.input)), + ] + }); + } + *) + Definition configure_in_table (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta; key; expr ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let key := M.alloc (| key |) in + let expr := M.alloc (| expr |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::ConstraintSystem") [ F ], + "lookup_any", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.tuple + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| meta |); + M.read (| key |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.read (| + let exprs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", []) + ], + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ], + "call", + [] + |), + [ + M.read (| expr |); + Value.Tuple [ M.read (| meta |) ] + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.tuple + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + "remove", + [] + |), + [ exprs; Value.Integer 0 ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_fixed", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::circuits::WasmInputHelperTableConfig", + "from_zero_index" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "cur", + [] + |), + [] + |) + ] + |) + ]; + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path + "alloc::alloc::Global" + ], + "remove", + [] + |), + [ exprs; Value.Integer 0 ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ], + "query_instance", + [] + |), + [ + M.read (| meta |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::circuits::WasmInputHelperTableConfig", + "input" + |) + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "halo2_proofs::poly::Rotation", + "prev", + [] + |), + [] + |) + ] + |) + ] + ] + |) + ] + |) + |)) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::foreign::ForeignTableConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ ("configure_in_table", InstanceField.Method (configure_in_table F)) ]. + End Impl_delphinus_zkwasm_foreign_ForeignTableConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_foreign_wasm_input_helper_circuits_WasmInputHelperTableConfig_F. + End config. + End circuits. + End wasm_input_helper. +End foreign. diff --git a/CoqOfRust/zkWasm/foreign/wasm_input_helper/circuits/mod.v b/CoqOfRust/zkWasm/foreign/wasm_input_helper/circuits/mod.v new file mode 100644 index 000000000..2acbdb1c4 --- /dev/null +++ b/CoqOfRust/zkWasm/foreign/wasm_input_helper/circuits/mod.v @@ -0,0 +1,114 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module foreign. + Module wasm_input_helper. + Module circuits. + Definition value_WASM_INPUT_FOREIGN_TABLE_KEY : Value.t := + M.run ltac:(M.monadic (Value.String "wasm-input-helper-table")). + + (* StructRecord + { + name := "WasmInputHelperTableConfig"; + ty_params := [ "F" ]; + fields := + [ + ("from_zero_index", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ]); + ("input", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ]); + ("_mark", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_foreign_wasm_input_helper_circuits_WasmInputHelperTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::circuits::WasmInputHelperTableConfig") + [ F ]. + + (* Clone *) + Definition clone (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::foreign::wasm_input_helper::circuits::WasmInputHelperTableConfig" + [ + ("from_zero_index", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Fixed" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::circuits::WasmInputHelperTableConfig", + "from_zero_index" + |) + ] + |)); + ("input", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Column") + [ Ty.path "halo2_proofs::plonk::circuit::Instance" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::circuits::WasmInputHelperTableConfig", + "input" + |) + ] + |)); + ("_mark", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply (Ty.path "core::marker::PhantomData") [ F ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::circuits::WasmInputHelperTableConfig", + "_mark" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::clone::Clone" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method (clone F)) ]. + End Impl_core_clone_Clone_where_core_clone_Clone_F_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_foreign_wasm_input_helper_circuits_WasmInputHelperTableConfig_F. + End circuits. + End wasm_input_helper. +End foreign. diff --git a/CoqOfRust/zkWasm/foreign/wasm_input_helper/etable_op_configure.v b/CoqOfRust/zkWasm/foreign/wasm_input_helper/etable_op_configure.v new file mode 100644 index 000000000..9741b5801 --- /dev/null +++ b/CoqOfRust/zkWasm/foreign/wasm_input_helper/etable_op_configure.v @@ -0,0 +1,5207 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module foreign. + Module wasm_input_helper. + Module etable_op_configure. + (* StructRecord + { + name := "ETableWasmInputHelperTableConfig"; + ty_params := [ "F" ]; + fields := + [ + ("plugin_index", Ty.path "usize"); + ("is_wasm_input_op", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_wasm_output_op", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("is_public", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("value", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") [ F ]); + ("enable_input_table_lookup", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ]); + ("public_input_index_for_lookup", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("value_for_lookup", + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ]); + ("lookup_read_stack", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ]); + ("lookup_write_stack", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ]) + ]; + } *) + + (* StructRecord + { + name := "ETableWasmInputHelperTableConfigBuilder"; + ty_params := []; + fields := [ ("index", Ty.path "usize") ]; + } *) + + Module Impl_delphinus_zkwasm_foreign_InternalHostPluginBuilder_for_delphinus_zkwasm_foreign_wasm_input_helper_etable_op_configure_ETableWasmInputHelperTableConfigBuilder. + Definition Self : Ty.t := + Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfigBuilder". + + (* + fn new(index: usize) -> Self { + Self { index } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ index ] => + ltac:(M.monadic + (let index := M.alloc (| index |) in + Value.StructRecord + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfigBuilder" + [ ("index", M.read (| index |)) ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "delphinus_zkwasm::foreign::InternalHostPluginBuilder" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("new", InstanceField.Method new) ]. + End Impl_delphinus_zkwasm_foreign_InternalHostPluginBuilder_for_delphinus_zkwasm_foreign_wasm_input_helper_etable_op_configure_ETableWasmInputHelperTableConfigBuilder. + + Module Impl_delphinus_zkwasm_foreign_EventTableForeignCallConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_foreign_wasm_input_helper_etable_op_configure_ETableWasmInputHelperTableConfigBuilder. + Definition Self (F : Ty.t) : Ty.t := + Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfigBuilder". + + (* + fn configure( + self, + common_config: &EventTableCommonConfig, + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + lookup_cells: &mut (impl Iterator> + Clone), + ) -> Box> { + let eid = common_config.eid_cell; + let sp = common_config.sp_cell; + let public_input_index = common_config.input_index_cell; + + let is_wasm_input_op: AllocatedBitCell = allocator.alloc_bit_cell(); + let is_wasm_output_op: AllocatedBitCell = allocator.alloc_bit_cell(); + + let is_public = allocator.alloc_bit_cell(); + let value = allocator.alloc_u64_cell(); + + let enable_input_table_lookup = allocator.alloc_bit_cell(); + let public_input_index_for_lookup = lookup_cells.next().unwrap(); + let value_for_lookup = lookup_cells.next().unwrap(); + + let lookup_read_stack = allocator.alloc_memory_table_lookup_read_cell( + "wasm input stack read", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |meta| is_wasm_input_op.expr(meta), + move |meta| { + is_public.expr(meta) * is_wasm_input_op.expr(meta) + + value.u64_cell.expr(meta) * is_wasm_output_op.expr(meta) + }, + move |____| constant_from!(1), + ); + let lookup_write_stack = allocator.alloc_memory_table_lookup_write_cell( + "wasm input stack write", + constraint_builder, + eid, + move |____| constant_from!(LocationType::Stack as u64), + move |meta| sp.expr(meta) + constant_from!(1), + move |____| constant_from!(0), + move |meta| value.u64_cell.expr(meta), + move |meta| is_wasm_input_op.expr(meta), + ); + + constraint_builder.push( + "wasm_input_helper: sel", + Box::new(move |meta| { + vec![is_wasm_input_op.expr(meta) + is_wasm_output_op.expr(meta) - constant_from!(1)] + }), + ); + + constraint_builder.push( + "enable lookup bit", + Box::new(move |meta| { + vec![ + enable_input_table_lookup.expr(meta) + - (is_public.expr(meta) + is_wasm_output_op.expr(meta)), + ] + }), + ); + + constraint_builder.push( + "wasm input lookup aux", + Box::new(move |meta| { + vec![ + enable_input_table_lookup.expr(meta) * public_input_index.expr(meta) + - public_input_index_for_lookup.expr(meta), + enable_input_table_lookup.expr(meta) * value.expr(meta) + - value_for_lookup.expr(meta), + ] + }), + ); + + constraint_builder.lookup( + WASM_INPUT_FOREIGN_TABLE_KEY, + "lookup input table", + Box::new(move |meta| { + vec![ + public_input_index_for_lookup.expr(meta), + value_for_lookup.expr(meta), + ] + }), + ); + + Box::new(ETableWasmInputHelperTableConfig { + plugin_index: self.index, + is_wasm_input_op, + is_wasm_output_op, + is_public, + value, + enable_input_table_lookup, + public_input_index_for_lookup, + value_for_lookup, + lookup_read_stack, + lookup_write_stack, + }) + } + *) + Definition configure (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [ impl_Iterator_Item___AllocatedUnlimitedCell_F____plus__Clone ], + [ self; common_config; allocator; constraint_builder; lookup_cells ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let common_config := M.alloc (| common_config |) in + let allocator := M.alloc (| allocator |) in + let constraint_builder := M.alloc (| constraint_builder |) in + let lookup_cells := M.alloc (| lookup_cells |) in + (* Unsize *) + M.pointer_coercion + (M.read (| + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "eid_cell" + |) + |) in + let sp := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "sp_cell" + |) + |) in + let public_input_index := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| common_config |), + "delphinus_zkwasm::circuits::etable::EventTableCommonConfig", + "input_index_cell" + |) + |) in + let is_wasm_input_op := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_wasm_output_op := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let is_public := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_u64_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let enable_input_table_lookup := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_bit_cell", + [] + |), + [ M.read (| allocator |) ] + |) + |) in + let public_input_index_for_lookup := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___AllocatedUnlimitedCell_F____plus__Clone, + [], + "next", + [] + |), + [ M.read (| lookup_cells |) ] + |) + ] + |) + |) in + let value_for_lookup := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + impl_Iterator_Item___AllocatedUnlimitedCell_F____plus__Clone, + [], + "next", + [] + |), + [ M.read (| lookup_cells |) ] + |) + ] + |) + |) in + let lookup_read_stack := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_read_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "wasm input stack read" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_wasm_input_op; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_public; M.read (| meta |) ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_wasm_input_op; M.read (| meta |) ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_wasm_output_op; M.read (| meta |) ] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 1 |)) |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let lookup_write_stack := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::EventTableCellAllocator") + [ F ], + "alloc_memory_table_lookup_write_cell", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]); + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ]) + ] + |), + [ + M.read (| allocator |); + M.read (| Value.String "wasm input stack write" |); + M.read (| constraint_builder |); + M.read (| eid |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::mtable::LocationType::Stack_discriminant" + |), + Value.Integer 0 + |)) + |)) + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ sp; M.read (| meta |) ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use (M.alloc (| Value.Integer 1 |)) + |) + ] + |) + ] + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let ____ := M.copy (| γ |) in + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.use (M.alloc (| Value.Integer 0 |)) |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + value, + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell", + "u64_cell" + |); + M.read (| meta |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ is_wasm_input_op; M.read (| meta |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "wasm_input_helper: sel" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_wasm_input_op; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_wasm_output_op; + M.read (| meta |) + ] + |) + ] + |); + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ + M.read (| + M.use + (M.alloc (| + Value.Integer 1 + |)) + |) + ] + |) + ] + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "enable lookup bit" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + enable_input_table_lookup; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "add", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_public; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + is_wasm_output_op; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "push", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| Value.String "wasm input lookup aux" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + enable_input_table_lookup; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedCommonRangeCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + public_input_index; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + public_input_index_for_lookup; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Sub", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "sub", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Mul", + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ], + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "mul", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + enable_input_table_lookup; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "expr", + [] + |), + [ + value; + M.read (| meta |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + value_for_lookup; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::constraint_builder::ConstraintBuilder") + [ F ], + "lookup", + [] + |), + [ + M.read (| constraint_builder |); + M.read (| + M.get_constant (| + "delphinus_zkwasm::foreign::wasm_input_helper::circuits::WASM_INPUT_FOREIGN_TABLE_KEY" + |) + |); + M.read (| Value.String "lookup input table" |); + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::VirtualCells") + [ F ] + ] + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "halo2_proofs::plonk::circuit::Expression") + [ F ]; + Ty.path "alloc::alloc::Global" + ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let meta := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path + "halo2_proofs::plonk::circuit::Expression") + [ F ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + public_input_index_for_lookup; + M.read (| meta |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "expr", + [] + |), + [ + value_for_lookup; + M.read (| meta |) + ] + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + |) + |) in + M.alloc (| + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig") + [ F ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig" + [ + ("plugin_index", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfigBuilder", + "index" + |) + |)); + ("is_wasm_input_op", M.read (| is_wasm_input_op |)); + ("is_wasm_output_op", M.read (| is_wasm_output_op |)); + ("is_public", M.read (| is_public |)); + ("value", M.read (| value |)); + ("enable_input_table_lookup", M.read (| enable_input_table_lookup |)); + ("public_input_index_for_lookup", + M.read (| public_input_index_for_lookup |)); + ("value_for_lookup", M.read (| value_for_lookup |)); + ("lookup_read_stack", M.read (| lookup_read_stack |)); + ("lookup_write_stack", M.read (| lookup_write_stack |)) + ] + ] + |)) + |) + |)))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::foreign::EventTableForeignCallConfigBuilder" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) [ ("configure", InstanceField.Method (configure F)) ]. + End Impl_delphinus_zkwasm_foreign_EventTableForeignCallConfigBuilder_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_foreign_wasm_input_helper_etable_op_configure_ETableWasmInputHelperTableConfigBuilder. + + Module Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_foreign_wasm_input_helper_etable_op_configure_ETableWasmInputHelperTableConfig_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig") + [ F ]. + + (* + fn sp_diff(&self, meta: &mut VirtualCells<'_, F>) -> Option> { + Some(self.is_wasm_output_op.expr(meta)) + } + *) + Definition sp_diff (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig", + "is_wasm_output_op" + |); + M.read (| meta |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn opcode(&self, meta: &mut VirtualCells<'_, F>) -> Expression { + constant_from_bn!( + &(BigUint::from(OpcodeClass::ForeignPluginStart as u64 + self.plugin_index as u64) + << OPCODE_CLASS_SHIFT) + ) + self.is_wasm_output_op.expr(meta) + } + *) + Definition opcode (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ], + [ Ty.apply (Ty.path "halo2_proofs::plonk::circuit::Expression") [ F ] ], + "add", + [] + |), + [ + Value.StructTuple + "halo2_proofs::plonk::circuit::Expression::Constant" + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::utils::bn_to_field", + [ F ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::bit::Shl", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u32" ], + "shl", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "num_bigint::biguint::BigUint", + [ Ty.path "u64" ], + "from", + [] + |), + [ + BinOp.Panic.add (| + Integer.U64, + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "specs::itable::OpcodeClass::LocalGet_discriminant" + |), + Value.Integer 28 + |)), + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig", + "plugin_index" + |) + |)) + |) + ] + |); + M.read (| + M.get_constant (| "specs::itable::OPCODE_CLASS_SHIFT" |) + |) + ] + |) + |) + ] + |) + ]; + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig", + "is_wasm_output_op" + |); + M.read (| meta |) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn assign( + &self, + ctx: &mut Context<'_, F>, + step: &StepStatus, + entry: &EventTableEntryWithMemoryInfo, + ) -> Result<(), Error> { + match &entry.eentry.step_info { + StepInfo::CallHost { + args, + ret_val, + signature, + op_index_in_plugin, + .. + } => { + if *op_index_in_plugin == Op::WasmInput as usize { + let arg_type: VarType = ( *signature.params.get(0).unwrap()).into(); + let ret_type: VarType = signature.return_type.unwrap().into(); + + assert_eq!(args.len(), 1); + assert_eq!(arg_type, VarType::I32); + assert_eq!(ret_type, VarType::I64); + + let is_public = *args.get(0).unwrap() == 1; + let value = ret_val.unwrap(); + + self.is_wasm_input_op.assign_bool(ctx, true)?; + self.is_public.assign_bool(ctx, is_public)?; + self.value.assign(ctx, value)?; + + self.enable_input_table_lookup.assign_bool(ctx, is_public)?; + self.public_input_index_for_lookup.assign( + ctx, + (is_public as u64 * step.current.host_public_inputs as u64).into(), + )?; + self.value_for_lookup + .assign(ctx, ((is_public as u64) * value).into())?; + + self.lookup_read_stack.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + true, + *args.get(0).unwrap(), + )?; + + self.lookup_write_stack.assign( + ctx, + step.current.eid, + entry.memory_rw_entires[1].end_eid, + step.current.sp + 1, + LocationType::Stack, + false, + ret_val.unwrap(), + )?; + } else { + let arg_type: VarType = ( *signature.params.get(0).unwrap()).into(); + assert_eq!(args.len(), 1); + assert_eq!(arg_type, VarType::I64); + + let value = *args.first().unwrap(); + self.value.assign(ctx, value)?; + + self.is_wasm_output_op.assign_bool(ctx, true)?; + + self.enable_input_table_lookup.assign_bool(ctx, true)?; + self.public_input_index_for_lookup + .assign(ctx, (step.current.host_public_inputs as u64).into())?; + self.value_for_lookup.assign(ctx, value.into())?; + + self.lookup_read_stack.assign( + ctx, + entry.memory_rw_entires[0].start_eid, + step.current.eid, + entry.memory_rw_entires[0].end_eid, + step.current.sp + 1, + LocationType::Stack, + false, + value, + )?; + } + + Ok(()) + } + + _ => unreachable!(), + } + } + *) + Definition assign (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; ctx; step; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let ctx := M.alloc (| ctx |) in + let step := M.alloc (| step |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "eentry" + |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "args" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "ret_val" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "signature" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "op_index_in_plugin" + |) in + let args := M.alloc (| γ1_0 |) in + let ret_val := M.alloc (| γ1_1 |) in + let signature := M.alloc (| γ1_2 |) in + let op_index_in_plugin := M.alloc (| γ1_3 |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| M.read (| op_index_in_plugin |) |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::foreign::wasm_input_helper::Op::WasmInput_discriminant" + |), + Value.Integer 0 + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let arg_type := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ Ty.path "specs::types::ValueType" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::types::ValueType" ], + "get", + [ Ty.path "usize" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| signature |), + "specs::host_function::Signature", + "params" + |) + ] + |); + Value.Integer 0 + ] + |) + ] + |) + |) + ] + |) + |) in + let ret_type := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "specs::types::ValueType" ], + "unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| signature |), + "specs::host_function::Signature", + "return_type" + |) + |) + ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| args |) ] + |) + |); + M.alloc (| Value.Integer 1 |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| + M.read (| left_val |) + |)) + (M.read (| + M.read (| right_val |) + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ + Ty.path "usize"; + Ty.path "usize" + ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + arg_type; + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I32" [] + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "specs::mtable::VarType", + [ + Ty.path + "specs::mtable::VarType" + ], + "eq", + [] + |), + [ + M.read (| left_val |); + M.read (| right_val |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ + Ty.path + "specs::mtable::VarType"; + Ty.path + "specs::mtable::VarType" + ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + ret_type; + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I64" [] + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "specs::mtable::VarType", + [ + Ty.path + "specs::mtable::VarType" + ], + "eq", + [] + |), + [ + M.read (| left_val |); + M.read (| right_val |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ + Ty.path + "specs::mtable::VarType"; + Ty.path + "specs::mtable::VarType" + ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let is_public := + M.alloc (| + BinOp.Pure.eq + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.path "u64" ] ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u64" ], + "get", + [ Ty.path "usize" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| args |) ] + |); + Value.Integer 0 + ] + |) + ] + |) + |)) + (Value.Integer 1) + |) in + let value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ], + "unwrap", + [] + |), + [ M.read (| M.read (| ret_val |) |) ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig", + "is_wasm_input_op" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig", + "is_public" + |); + M.read (| ctx |); + M.read (| is_public |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig", + "value" + |); + M.read (| ctx |); + M.read (| value |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig", + "enable_input_table_lookup" + |); + M.read (| ctx |); + M.read (| is_public |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig", + "public_input_index_for_lookup" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ + BinOp.Panic.mul (| + Integer.U64, + M.rust_cast (M.read (| is_public |)), + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "host_public_inputs" + |) + |)) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig", + "value_for_lookup" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ + BinOp.Panic.mul (| + Integer.U64, + M.rust_cast (M.read (| is_public |)), + M.read (| value |) + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig", + "lookup_read_stack" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool true; + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ Ty.path "u64" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "u64" ], + "get", + [ Ty.path "usize" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| args |) ] + |); + Value.Integer 0 + ] + |) + ] + |) + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupWriteCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig", + "lookup_write_stack" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 1 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool false; + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ], + "unwrap", + [] + |), + [ M.read (| M.read (| ret_val |) |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let arg_type := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ Ty.path "specs::types::ValueType" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::types::ValueType" ], + "get", + [ Ty.path "usize" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| signature |), + "specs::host_function::Signature", + "params" + |) + ] + |); + Value.Integer 0 + ] + |) + ] + |) + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| args |) ] + |) + |); + M.alloc (| Value.Integer 1 |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| + M.read (| left_val |) + |)) + (M.read (| + M.read (| right_val |) + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ + Ty.path "usize"; + Ty.path "usize" + ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + arg_type; + M.alloc (| + Value.StructTuple "specs::mtable::VarType::I64" [] + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := + M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "specs::mtable::VarType", + [ + Ty.path + "specs::mtable::VarType" + ], + "eq", + [] + |), + [ + M.read (| left_val |); + M.read (| right_val |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ + Ty.path + "specs::mtable::VarType"; + Ty.path + "specs::mtable::VarType" + ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let value := + M.copy (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.path "u64" ] ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u64" ], + "first", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| args |) ] + |) + ] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedU64Cell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig", + "value" + |); + M.read (| ctx |); + M.read (| value |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig", + "is_wasm_output_op" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedBitCell") + [ F ], + [ F ], + "assign_bool", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig", + "enable_input_table_lookup" + |); + M.read (| ctx |); + Value.Bool true + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig", + "public_input_index_for_lookup" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "host_public_inputs" + |) + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "halo2_proofs::circuit::AssignedCell") + [ F; F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::cell::AllocatedUnlimitedCell") + [ F ], + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig", + "value_for_lookup" + |); + M.read (| ctx |); + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "u64", + [ F ], + "into", + [] + |), + [ M.read (| value |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::etable::allocator::AllocatedMemoryTableLookupReadCell") + [ F ], + "assign", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig", + "lookup_read_stack" + |); + M.read (| ctx |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "start_eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "eid" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "delphinus_zkwasm::circuits::utils::table_entry::EventTableEntryWithMemoryInfo", + "memory_rw_entires" + |); + Value.Integer 0 + ] + |), + "delphinus_zkwasm::circuits::utils::table_entry::MemoryRWEntry", + "end_eid" + |) + |); + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| step |), + "delphinus_zkwasm::circuits::utils::step_status::StepStatus", + "current" + |) + |), + "delphinus_zkwasm::circuits::utils::step_status::Status", + "sp" + |) + |), + Value.Integer 1 + |); + Value.StructTuple + "specs::mtable::LocationType::Stack" + []; + Value.Bool false; + M.read (| value |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path + "halo2_proofs::plonk::error::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn mops(&self, meta: &mut VirtualCells<'_, F>) -> Option> { + Some(self.is_wasm_input_op.expr(meta)) + } + *) + Definition mops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig", + "is_wasm_input_op" + |); + M.read (| meta |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn memory_writing_ops(&self, entry: &EventTableEntry) -> u32 { + match &entry.step_info { + StepInfo::CallHost { + plugin, + op_index_in_plugin, + .. + } => { + assert_eq!( *plugin, HostPlugin::HostInput); + + if *op_index_in_plugin == Op::WasmInput as usize { + 1 + } else { + 0 + } + } + _ => unreachable!(), + } + } + *) + Definition memory_writing_ops (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let entry := M.alloc (| entry |) in + M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "plugin" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "op_index_in_plugin" + |) in + let plugin := M.alloc (| γ1_0 |) in + let op_index_in_plugin := M.alloc (| γ1_1 |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.read (| plugin |); + M.alloc (| + Value.StructTuple + "specs::host_function::HostPlugin::HostInput" + [] + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::host_function::HostPlugin", + [ Ty.path "specs::host_function::HostPlugin" + ], + "eq", + [] + |), + [ M.read (| left_val |); M.read (| right_val |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ + Ty.path "specs::host_function::HostPlugin"; + Ty.path "specs::host_function::HostPlugin" + ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| M.read (| op_index_in_plugin |) |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::foreign::wasm_input_helper::Op::WasmInput_discriminant" + |), + Value.Integer 0 + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| Value.Integer 1 |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Integer 0 |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "internal error: entered unreachable code" |) + ] + |) + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + fn input_index_increase( + &self, + meta: &mut VirtualCells<'_, F>, + _common_config: &EventTableCommonConfig, + ) -> Option> { + // Public wasm input or wasm output + Some(self.enable_input_table_lookup.expr(meta)) + } + *) + Definition input_index_increase (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; meta; _common_config ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let meta := M.alloc (| meta |) in + let _common_config := M.alloc (| _common_config |) in + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::circuits::cell::CellExpression", + Ty.apply (Ty.path "delphinus_zkwasm::circuits::cell::AllocatedBitCell") [ F ], + [ F ], + "expr", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelperTableConfig", + "enable_input_table_lookup" + |); + M.read (| meta |) + ] + |) + ])) + | _, _ => M.impossible + end. + + (* + fn is_host_public_input(&self, entry: &EventTableEntry) -> bool { + match &entry.step_info { + StepInfo::CallHost { + plugin, + args, + op_index_in_plugin, + .. + } => { + assert_eq!( *plugin, HostPlugin::HostInput); + + *op_index_in_plugin == Op::WasmInput as usize && args[0] != 0 + || *op_index_in_plugin == Op::WasmOutput as usize + } + _ => unreachable!(), + } + } + *) + Definition is_host_public_input (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let entry := M.alloc (| entry |) in + M.read (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "plugin" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "args" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "op_index_in_plugin" + |) in + let plugin := M.alloc (| γ1_0 |) in + let args := M.alloc (| γ1_1 |) in + let op_index_in_plugin := M.alloc (| γ1_2 |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.read (| plugin |); + M.alloc (| + Value.StructTuple + "specs::host_function::HostPlugin::HostInput" + [] + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::host_function::HostPlugin", + [ Ty.path "specs::host_function::HostPlugin" + ], + "eq", + [] + |), + [ M.read (| left_val |); M.read (| right_val |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ + Ty.path "specs::host_function::HostPlugin"; + Ty.path "specs::host_function::HostPlugin" + ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| + LogicalOp.or (| + LogicalOp.and (| + BinOp.Pure.eq + (M.read (| M.read (| op_index_in_plugin |) |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::foreign::wasm_input_helper::Op::WasmInput_discriminant" + |), + Value.Integer 0 + |))), + ltac:(M.monadic + (BinOp.Pure.ne + (M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + [ Ty.path "usize" ], + "index", + [] + |), + [ M.read (| args |); Value.Integer 0 ] + |) + |)) + (Value.Integer 0))) + |), + ltac:(M.monadic + (BinOp.Pure.eq + (M.read (| M.read (| op_index_in_plugin |) |)) + (M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::foreign::wasm_input_helper::Op::WasmOutput_discriminant" + |), + Value.Integer 0 + |))))) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "internal error: entered unreachable code" |) + ] + |) + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "delphinus_zkwasm::circuits::etable::EventTableOpcodeConfig" + (Self F) + (* Trait polymorphic types *) [ (* F *) F ] + (* Instance *) + [ + ("sp_diff", InstanceField.Method (sp_diff F)); + ("opcode", InstanceField.Method (opcode F)); + ("assign", InstanceField.Method (assign F)); + ("mops", InstanceField.Method (mops F)); + ("memory_writing_ops", InstanceField.Method (memory_writing_ops F)); + ("input_index_increase", InstanceField.Method (input_index_increase F)); + ("is_host_public_input", InstanceField.Method (is_host_public_input F)) + ]. + End Impl_delphinus_zkwasm_circuits_etable_EventTableOpcodeConfig_where_pairing_bn256_arithmetic_fields_FieldExt_F_F_for_delphinus_zkwasm_foreign_wasm_input_helper_etable_op_configure_ETableWasmInputHelperTableConfig_F. + End etable_op_configure. + End wasm_input_helper. +End foreign. diff --git a/CoqOfRust/zkWasm/foreign/wasm_input_helper/mod.v b/CoqOfRust/zkWasm/foreign/wasm_input_helper/mod.v new file mode 100644 index 000000000..e7b282272 --- /dev/null +++ b/CoqOfRust/zkWasm/foreign/wasm_input_helper/mod.v @@ -0,0 +1,26 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module foreign. + Module wasm_input_helper. + (* + Enum Op + { + ty_params := []; + variants := + [ + { + name := "WasmInput"; + item := StructTuple []; + discriminant := Some 0; + }; + { + name := "WasmOutput"; + item := StructTuple []; + discriminant := Some 1; + } + ]; + } + *) + End wasm_input_helper. +End foreign. diff --git a/CoqOfRust/zkWasm/foreign/wasm_input_helper/runtime.v b/CoqOfRust/zkWasm/foreign/wasm_input_helper/runtime.v new file mode 100644 index 000000000..57a749604 --- /dev/null +++ b/CoqOfRust/zkWasm/foreign/wasm_input_helper/runtime.v @@ -0,0 +1,1184 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module foreign. + Module wasm_input_helper. + Module runtime. + (* StructRecord + { + name := "Context"; + ty_params := []; + fields := + [ + ("public_inputs", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ]); + ("private_inputs", + Ty.apply + (Ty.path "alloc::collections::vec_deque::VecDeque") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ]); + ("instance", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ]); + ("output", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ]) + ]; + } *) + + Module Impl_delphinus_zkwasm_foreign_wasm_input_helper_runtime_Context. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context". + + (* + pub fn new(public_inputs: Vec, private_inputs: Vec) -> Self { + Context { + public_inputs, + private_inputs: private_inputs.into(), + instance: vec![], + output: vec![], + } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ public_inputs; private_inputs ] => + ltac:(M.monadic + (let public_inputs := M.alloc (| public_inputs |) in + let private_inputs := M.alloc (| private_inputs |) in + Value.StructRecord + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context" + [ + ("public_inputs", M.read (| public_inputs |)); + ("private_inputs", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + [ + Ty.apply + (Ty.path "alloc::collections::vec_deque::VecDeque") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ] + ], + "into", + [] + |), + [ M.read (| private_inputs |) ] + |)); + ("instance", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |)); + ("output", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + + (* + pub fn pop_public(&mut self) -> u64 { + if self.public_inputs.is_empty() { + panic!("failed to read public input, please checkout your input"); + } + self.public_inputs.remove(0) + } + *) + Definition pop_public (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "is_empty", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context", + "public_inputs" + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic_fmt", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "failed to read public input, please checkout your input" + |) + ] + |)) + ] + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "remove", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context", + "public_inputs" + |); + Value.Integer 0 + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_pop_public : M.IsAssociatedFunction Self "pop_public" pop_public. + + (* + pub fn pop_private(&mut self) -> u64 { + if self.private_inputs.is_empty() { + panic!("failed to read private input, please checkout your input"); + } + self.private_inputs.pop_front().unwrap() + } + *) + Definition pop_private (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::vec_deque::VecDeque") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "is_empty", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context", + "private_inputs" + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic_fmt", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "failed to read private input, please checkout your input" + |) + ] + |)) + ] + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.path "u64" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::vec_deque::VecDeque") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "pop_front", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context", + "private_inputs" + |) + ] + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_pop_private : + M.IsAssociatedFunction Self "pop_private" pop_private. + + (* + fn push_public(&mut self, value: u64) { + self.instance.push(value) + } + *) + Definition push_public (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let value := M.alloc (| value |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context", + "instance" + |); + M.read (| value |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_push_public : + M.IsAssociatedFunction Self "push_public" push_public. + + (* + fn push_output(&mut self, value: u64) { + self.instance.push(value); + self.output.push(value); + } + *) + Definition push_output (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let value := M.alloc (| value |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context", + "instance" + |); + M.read (| value |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context", + "output" + |); + M.read (| value |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_push_output : + M.IsAssociatedFunction Self "push_output" push_output. + + (* + pub fn wasm_input(&mut self, arg: i32) -> u64 { + assert!(arg == 0 || arg == 1); + + let input = if arg == 1 { + let value = self.pop_public(); + self.push_public(value); + value + } else { + self.pop_private() + }; + + input + } + *) + Definition wasm_input (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; arg ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let arg := M.alloc (| arg |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (LogicalOp.or (| + BinOp.Pure.eq (M.read (| arg |)) (Value.Integer 0), + ltac:(M.monadic + (BinOp.Pure.eq (M.read (| arg |)) (Value.Integer 1))) + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "assertion failed: arg == 0 || arg == 1" |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let input := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq (M.read (| arg |)) (Value.Integer 1) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context", + "pop_public", + [] + |), + [ M.read (| self |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context", + "push_public", + [] + |), + [ M.read (| self |); M.read (| value |) ] + |) + |) in + value)); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context", + "pop_private", + [] + |), + [ M.read (| self |) ] + |) + |))) + ] + |) + |) in + input + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_wasm_input : M.IsAssociatedFunction Self "wasm_input" wasm_input. + + (* + pub fn wasm_output(&mut self, value: u64) { + self.push_output(value); + } + *) + Definition wasm_output (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let value := M.alloc (| value |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context", + "push_output", + [] + |), + [ M.read (| self |); M.read (| value |) ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_wasm_output : + M.IsAssociatedFunction Self "wasm_output" wasm_output. + End Impl_delphinus_zkwasm_foreign_wasm_input_helper_runtime_Context. + + Module Impl_delphinus_zkwasm_runtime_host_ForeignContext_for_delphinus_zkwasm_foreign_wasm_input_helper_runtime_Context. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context". + + (* + fn get_statics(&self) -> Option { + None + } + *) + Definition get_statics (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructTuple "core::option::Option::None" [])) + | _, _ => M.impossible + end. + + (* + fn expose_public_inputs_and_outputs(&self) -> Vec { + self.instance.clone() + } + *) + Definition expose_public_inputs_and_outputs (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context", + "instance" + |) + ] + |))) + | _, _ => M.impossible + end. + + (* + fn expose_outputs(&self) -> Vec { + self.output.clone() + } + *) + Definition expose_outputs (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context", + "output" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "delphinus_zkwasm::runtime::host::ForeignContext" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ + ("get_statics", InstanceField.Method get_statics); + ("expose_public_inputs_and_outputs", + InstanceField.Method expose_public_inputs_and_outputs); + ("expose_outputs", InstanceField.Method expose_outputs) + ]. + End Impl_delphinus_zkwasm_runtime_host_ForeignContext_for_delphinus_zkwasm_foreign_wasm_input_helper_runtime_Context. + + (* + pub fn register_wasm_input_foreign( + env: &mut HostEnv, + public_inputs: Vec, + private_inputs: Vec, + ) { + let wasm_input = Rc::new( + |_observer: &Observer, context: &mut dyn ForeignContext, args: wasmi::RuntimeArgs| { + let context = context.downcast_mut::().unwrap(); + let arg: i32 = args.nth(0); + let input = context.wasm_input(arg); + + Some(wasmi::RuntimeValue::I64(input as i64)) + }, + ); + + let wasm_output = Rc::new( + |_observer: &Observer, context: &mut dyn ForeignContext, args: wasmi::RuntimeArgs| { + let context = context.downcast_mut::().unwrap(); + + let value: i64 = args.nth(0); + context.wasm_output(value as u64); + + None + }, + ); + + env.internal_env.register_plugin( + "wasm input plugin", + HostPlugin::HostInput, + Box::new(Context::new(public_inputs, private_inputs)), + ); + + env.internal_env.register_function( + "wasm_input", + specs::host_function::Signature { + params: vec![ValueType::I32], + return_type: Some(ValueType::I64), + }, + HostPlugin::HostInput, + Op::WasmInput as usize, + wasm_input, + ); + + env.internal_env.register_function( + "wasm_output", + specs::host_function::Signature { + params: vec![ValueType::I64], + return_type: None, + }, + HostPlugin::HostInput, + Op::WasmOutput as usize, + wasm_output, + ); + } + *) + Definition register_wasm_input_foreign (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ env; public_inputs; private_inputs ] => + ltac:(M.monadic + (let env := M.alloc (| env |) in + let public_inputs := M.alloc (| public_inputs |) in + let private_inputs := M.alloc (| private_inputs |) in + M.read (| + let wasm_input := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ] + ]; + Ty.path "wasmi::host::RuntimeArgs" + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi_core::value::Value" ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let _observer := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let context := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α2 |), + [ + fun γ => + ltac:(M.monadic + (let args := M.copy (| γ |) in + M.read (| + let context := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ], + "downcast_mut", + [ + Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context" + ] + |), + [ M.read (| context |) ] + |) + ] + |) + |) in + let arg := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::host::RuntimeArgs", + "nth", + [ Ty.path "i32" ] + |), + [ args; Value.Integer 0 ] + |) + |) in + let input := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context", + "wasm_input", + [] + |), + [ + M.read (| context |); + M.read (| arg |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "wasmi_core::value::Value::I64" + [ M.rust_cast (M.read (| input |)) ] + ] + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let wasm_output := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ] + ]; + Ty.path "wasmi::host::RuntimeArgs" + ] + ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi_core::value::Value" ]); + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0; α1; α2 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let _observer := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α1 |), + [ + fun γ => + ltac:(M.monadic + (let context := M.copy (| γ |) in + M.match_operator (| + M.alloc (| α2 |), + [ + fun γ => + ltac:(M.monadic + (let args := M.copy (| γ |) in + M.read (| + let context := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ + Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ], + "downcast_mut", + [ + Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context" + ] + |), + [ M.read (| context |) ] + |) + ] + |) + |) in + let value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::host::RuntimeArgs", + "nth", + [ Ty.path "i64" ] + |), + [ args; Value.Integer 0 ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context", + "wasm_output", + [] + |), + [ + M.read (| context |); + M.rust_cast (M.read (| value |)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |) + |))) + ] + |))) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv", + "register_plugin", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| env |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "internal_env" + |); + M.read (| Value.String "wasm input plugin" |); + Value.StructTuple "specs::host_function::HostPlugin::HostInput" []; + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::Context", + "new", + [] + |), + [ M.read (| public_inputs |); M.read (| private_inputs |) ] + |) + ] + |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv", + "register_function", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| env |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "internal_env" + |); + M.read (| Value.String "wasm_input" |); + Value.StructRecord + "specs::host_function::Signature" + [ + ("params", + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "specs::types::ValueType" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::types::ValueType" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ Value.StructTuple "specs::types::ValueType::I32" [] ] + |) + ] + |) + |)) + ] + |)); + ("return_type", + Value.StructTuple + "core::option::Option::Some" + [ Value.StructTuple "specs::types::ValueType::I64" [] ]) + ]; + Value.StructTuple "specs::host_function::HostPlugin::HostInput" []; + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::foreign::wasm_input_helper::Op::WasmInput_discriminant" + |), + Value.Integer 0 + |)); + (* Unsize *) M.pointer_coercion (M.read (| wasm_input |)) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv", + "register_function", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| env |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "internal_env" + |); + M.read (| Value.String "wasm_output" |); + Value.StructRecord + "specs::host_function::Signature" + [ + ("params", + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "specs::types::ValueType" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::types::ValueType" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ Value.StructTuple "specs::types::ValueType::I64" [] ] + |) + ] + |) + |)) + ] + |)); + ("return_type", Value.StructTuple "core::option::Option::None" []) + ]; + Value.StructTuple "specs::host_function::HostPlugin::HostInput" []; + M.rust_cast + (BinOp.Panic.add (| + Integer.Isize, + M.get_constant (| + "delphinus_zkwasm::foreign::wasm_input_helper::Op::WasmOutput_discriminant" + |), + Value.Integer 0 + |)); + (* Unsize *) M.pointer_coercion (M.read (| wasm_output |)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + End runtime. + End wasm_input_helper. +End foreign. diff --git a/CoqOfRust/zkWasm/loader/err.v b/CoqOfRust/zkWasm/loader/err.v new file mode 100644 index 000000000..aae88b220 --- /dev/null +++ b/CoqOfRust/zkWasm/loader/err.v @@ -0,0 +1,222 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module loader. + Module err. + (* + Enum PreCheckErr + { + ty_params := []; + variants := + [ + { + name := "ZkmainNotExists"; + item := StructTuple []; + discriminant := None; + }; + { + name := "ZkmainIsNotFunction"; + item := StructTuple []; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_fmt_Debug_for_delphinus_zkwasm_loader_err_PreCheckErr. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::loader::err::PreCheckErr". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |), + [ + M.read (| f |); + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| M.read (| Value.String "ZkmainNotExists" |) |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| M.read (| Value.String "ZkmainIsNotFunction" |) |))) + ] + |) + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_delphinus_zkwasm_loader_err_PreCheckErr. + + (* + Enum RuntimeErr + { + ty_params := []; + variants := []; + } + *) + + Module Impl_core_fmt_Debug_for_delphinus_zkwasm_loader_err_RuntimeErr. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::loader::err::RuntimeErr". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.never_to_any (| M.read (| M.match_operator (| M.read (| self |), [] |) |) |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_delphinus_zkwasm_loader_err_RuntimeErr. + + (* + Enum Error + { + ty_params := []; + variants := + [ + { + name := "PreCheck"; + item := StructTuple [ Ty.path "delphinus_zkwasm::loader::err::PreCheckErr" ]; + discriminant := None; + } + ]; + } + *) + + Module Impl_core_fmt_Debug_for_delphinus_zkwasm_loader_err_Error. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::loader::err::Error". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "delphinus_zkwasm::loader::err::Error::PreCheck", + 0 + |) in + let __self_0 := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_tuple_field1_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "PreCheck" |); + (* Unsize *) M.pointer_coercion __self_0 + ] + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_delphinus_zkwasm_loader_err_Error. + + Module Impl_core_fmt_Display_for_delphinus_zkwasm_loader_err_Error. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::loader::err::Error". + + (* + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self) + } + *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_fmt", [] |), + [ + M.read (| f |); + M.call_closure (| + M.get_associated_function (| Ty.path "core::fmt::Arguments", "new_v1", [] |), + [ + (* Unsize *) + M.pointer_coercion (M.alloc (| Value.Array [ M.read (| Value.String "" |) ] |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "delphinus_zkwasm::loader::err::Error" ] + ] + |), + [ self ] + |) + ] + |)) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Display" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Display_for_delphinus_zkwasm_loader_err_Error. + End err. +End loader. diff --git a/CoqOfRust/zkWasm/loader/mod.v b/CoqOfRust/zkWasm/loader/mod.v new file mode 100644 index 000000000..2f17f9df6 --- /dev/null +++ b/CoqOfRust/zkWasm/loader/mod.v @@ -0,0 +1,1615 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module loader. + Definition value_ENTRY : Value.t := M.run ltac:(M.monadic (Value.String "zkmain")). + + (* StructRecord + { + name := "ExecutionReturn"; + ty_params := []; + fields := + [ + ("context_output", + Ty.apply (Ty.path "alloc::vec::Vec") [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ]) + ]; + } *) + + (* StructRecord + { + name := "ZkWasmLoader"; + ty_params := []; + fields := + [ + ("k", Ty.path "u32"); + ("entry", Ty.path "alloc::string::String"); + ("env", Ty.path "delphinus_zkwasm::runtime::host::host_env::HostEnv") + ]; + } *) + + Module Impl_delphinus_zkwasm_loader_ZkWasmLoader. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::loader::ZkWasmLoader". + + (* + pub fn parse_module(image: &Vec) -> Result { + fn precheck(_module: &Module) -> Result<()> { + #[allow(dead_code)] + fn check_zkmain_exists(module: &Module) -> Result<()> { + use parity_wasm::elements::Internal; + + let export = module.module().export_section().unwrap(); + + if let Some(entry) = export.entries().iter().find(|entry| entry.field() == ENTRY) { + match entry.internal() { + Internal::Function(_fid) => Ok(()), + _ => Err(anyhow!(Error::PreCheck(PreCheckErr::ZkmainIsNotFunction))), + } + } else { + Err(anyhow!(Error::PreCheck(PreCheckErr::ZkmainNotExists))) + } + } + + #[cfg(not(test))] + check_zkmain_exists(_module)?; + // TODO: check the signature of zkmain function. + // TODO: check the relation between maximal pages and K. + // TODO: check the instructions of phantom functions. + // TODO: check phantom functions exists. + // TODO: check if instructions are supported. + + Ok(()) + } + + let mut module = Module::from_buffer(&image)?; + if let Ok(parity_module) = module.module().clone().parse_names() { + module.module = parity_module; + } else { + warn!("Failed to parse name section of the wasm binary."); + } + + precheck(&module)?; + + Ok(module) + } + *) + Definition parse_module (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ image ] => + ltac:(M.monadic + (let image := M.alloc (| image |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let module := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "wasmi::Module"; Ty.path "wasmi::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::Module", + "from_buffer", + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ] + ] + ] + ] + |), + [ image ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "wasmi::Module"; Ty.path "anyhow::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "wasmi::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "parity_wasm::elements::module::Module", + "parse_names", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "parity_wasm::elements::module::Module", + [], + "clone", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::Module", + "module", + [] + |), + [ module ] + |) + ] + |) + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::result::Result::Ok", + 0 + |) in + let parity_module := M.copy (| γ0_0 |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + module, + "wasmi::Module", + "module" + |), + M.read (| parity_module |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + let lvl := M.alloc (| Value.StructTuple "log::Level::Warn" [] |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ lvl; M.get_constant (| "log::STATIC_MAX_LEVEL" |) ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ + lvl; + M.alloc (| + M.call_closure (| + M.get_function (| "log::max_level", [] |), + [] + |) + |) + ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "log::__private_api::log", + [ Ty.tuple [] ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "Failed to parse name section of the wasm binary." + |) + ] + |)) + ] + |); + M.read (| lvl |); + M.alloc (| + Value.Tuple + [ + M.read (| + Value.String "delphinus_zkwasm::loader" + |); + M.read (| + Value.String "delphinus_zkwasm::loader" + |); + M.read (| + Value.String "crates/zkwasm/src/loader/mod.rs" + |) + ] + |); + Value.Integer 94; + Value.Tuple [] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "anyhow::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| Self, "precheck.parse_module", [] |), + [ module ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "wasmi::Module"; Ty.path "anyhow::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "anyhow::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| module |) ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_parse_module : M.IsAssociatedFunction Self "parse_module" parse_module. + (* + pub fn compile<'a>( + &self, + module: &'a Module, + monitor: &mut dyn WasmiMonitor, + ) -> Result>> { + let imports = ImportsBuilder::new().with_resolver("env", &self.env); + + WasmInterpreter::compile(monitor, module, &imports, self.entry.as_str()) + } + *) + Definition compile (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; module; monitor ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let module := M.alloc (| module |) in + let monitor := M.alloc (| monitor |) in + M.read (| + let imports := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::imports::ImportsBuilder", + "with_resolver", + [ Ty.apply (Ty.path "&") [ Ty.path "str" ] ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::imports::ImportsBuilder", + "new", + [] + |), + [] + |); + M.read (| Value.String "env" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::ZkWasmLoader", + "env" + |)) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "delphinus_zkwasm::runtime::wasmi_interpreter::WasmiRuntime", + "compile", + [ Ty.path "wasmi::imports::ImportsBuilder" ] + |), + [ + (* Unsize *) M.pointer_coercion (M.read (| monitor |)); + M.read (| module |); + imports; + M.call_closure (| + M.get_associated_function (| Ty.path "alloc::string::String", "as_str", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::ZkWasmLoader", + "entry" + |) + ] + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_compile : M.IsAssociatedFunction Self "compile" compile. + + (* + pub fn circuit_without_witness( + &mut self, + _is_last_slice: bool, + ) -> Result, BuildingCircuitError> { + todo!() + /* + let k = self.k; + + let env = env_builder.create_env_without_value(k); + + let compiled_module = self.compile(&env, false, TraceBackend::Memory).unwrap(); + + ZkWasmCircuit::new( + k, + Slice { + itable: compiled_module.tables.itable.clone(), + br_table: compiled_module.tables.br_table.clone(), + elem_table: compiled_module.tables.elem_table.clone(), + configure_table: compiled_module.tables.configure_table.clone(), + static_jtable: compiled_module.tables.static_jtable.clone(), + imtable: compiled_module.tables.imtable.clone(), + initialization_state: compiled_module.tables.initialization_state.clone(), + post_imtable: compiled_module.tables.imtable.clone(), + post_initialization_state: compiled_module.tables.initialization_state.clone(), + + etable: Arc::new(EventTable::default()), + frame_table: Arc::new(JumpTable::default()), + + is_last_slice, + }, + ) + */ + } + *) + Definition circuit_without_witness (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ E ], [ self; _is_last_slice ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _is_last_slice := M.alloc (| _is_last_slice |) in + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_circuit_without_witness : + M.IsAssociatedFunction Self "circuit_without_witness" circuit_without_witness. + + (* + pub fn new(k: u32, env: HostEnv) -> Result { + let loader = Self { + k, + entry: ENTRY.to_string(), + env, + }; + + loader.init_env()?; + + Ok(loader) + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ k; env ] => + ltac:(M.monadic + (let k := M.alloc (| k |) in + let env := M.alloc (| env |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let loader := + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::loader::ZkWasmLoader" + [ + ("k", M.read (| k |)); + ("entry", + M.call_closure (| + M.get_trait_method (| + "alloc::string::ToString", + Ty.path "str", + [], + "to_string", + [] + |), + [ M.read (| M.get_constant (| "delphinus_zkwasm::loader::ENTRY" |) |) ] + |)); + ("env", M.read (| env |)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "anyhow::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "delphinus_zkwasm::loader::ZkWasmLoader", + "init_env", + [] + |), + [ loader ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "delphinus_zkwasm::loader::ZkWasmLoader"; + Ty.path "anyhow::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "anyhow::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ M.read (| loader |) ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + + (* + pub fn create_vkey( + &self, + params: &Params, + circuit: &ZkWasmCircuit, + ) -> Result> { + Ok(keygen_vk(¶ms, circuit).unwrap()) + } + *) + Definition create_vkey (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ E ], [ self; params; circuit ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let params := M.alloc (| params |) in + let circuit := M.alloc (| circuit |) in + Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::plonk::VerifyingKey") [ Ty.associated ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::keygen::keygen_vk", + [ + Ty.associated; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::ZkWasmCircuit") + [ Ty.associated ] + ] + |), + [ M.read (| params |); M.read (| circuit |) ] + |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_create_vkey : M.IsAssociatedFunction Self "create_vkey" create_vkey. + (* + pub fn run( + self, + compiled_module: CompiledImage>, + monitor: &mut dyn WasmiMonitor, + ) -> Result> { + compiled_module.run(monitor, self.env) + } + *) + Definition run (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; compiled_module; monitor ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let compiled_module := M.alloc (| compiled_module |) in + let monitor := M.alloc (| monitor |) in + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::runtime::wasmi_interpreter::Execution", + Ty.apply + (Ty.path "delphinus_zkwasm::runtime::CompiledImage") + [ Ty.path "wasmi::module::NotStartedModuleRef" ], + [ Ty.path "wasmi_core::value::Value" ], + "run", + [] + |), + [ + M.read (| compiled_module |); + (* Unsize *) M.pointer_coercion (M.read (| monitor |)); + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::loader::ZkWasmLoader", + "env" + |) + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_run : M.IsAssociatedFunction Self "run" run. + + (* + pub fn slice( + &self, + _execution_result: ExecutionResult, + ) -> Result, BuildingCircuitError> { + todo!() + // Slices::new(self.k, execution_result.tables) + } + *) + Definition slice (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ E ], [ self; _execution_result ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _execution_result := M.alloc (| _execution_result |) in + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_slice : M.IsAssociatedFunction Self "slice" slice. + + (* + pub fn mock_test( + &self, + circuit: &ZkWasmCircuit, + instances: &Vec, + ) -> Result<()> { + let prover = MockProver::run(self.k, circuit, vec![instances.clone()])?; + assert_eq!(prover.verify(), Ok(())); + + Ok(()) + } + *) + Definition mock_test (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ E ], [ self; circuit; instances ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let circuit := M.alloc (| circuit |) in + let instances := M.alloc (| instances |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let prover := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::MockVerifier") + [ Ty.associated ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::dev::MockProver") + [ Ty.associated ], + "run", + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::ZkWasmCircuit") + [ Ty.associated ] + ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::ZkWasmLoader", + "k" + |) + |); + M.read (| circuit |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.associated; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ M.read (| instances |) ] + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "anyhow::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::dev::MockVerifier") + [ Ty.associated ], + "verify", + [] + |), + [ prover ] + |) + |); + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::dev::VerifyFailure"; + Ty.path "alloc::alloc::Global" + ] + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::dev::VerifyFailure"; + Ty.path "alloc::alloc::Global" + ] + ] + ], + "eq", + [] + |), + [ M.read (| left_val |); M.read (| right_val |) ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple "core::panicking::AssertKind::Eq" [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::dev::VerifyFailure"; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "halo2_proofs::dev::VerifyFailure"; + Ty.path "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple "core::option::Option::None" [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_mock_test : M.IsAssociatedFunction Self "mock_test" mock_test. + + (* + pub fn create_proof( + &self, + params: &Params, + pk: &ProvingKey, + circuit: &ZkWasmCircuit, + instances: &Vec, + ) -> Result> { + let mut transcript = Blake2bWrite::init(vec![]); + + create_proof( + params, + pk, + std::slice::from_ref(circuit), + &[&[&instances[..]]], + OsRng, + &mut transcript, + )?; + + Ok(transcript.finalize()) + } + *) + Definition create_proof (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ E ], [ self; params; pk; circuit; instances ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let params := M.alloc (| params |) in + let pk := M.alloc (| pk |) in + let circuit := M.alloc (| circuit |) in + let instances := M.alloc (| instances |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let transcript := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::transcript::Blake2bWrite") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ]; + Ty.associated; + Ty.apply + (Ty.path "halo2_proofs::transcript::Challenge255") + [ Ty.associated ] + ], + "init", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::prover::create_proof", + [ + Ty.associated; + Ty.apply + (Ty.path "halo2_proofs::transcript::Challenge255") + [ Ty.associated ]; + Ty.path "rand_core::os::OsRng"; + Ty.apply + (Ty.path "halo2_proofs::transcript::Blake2bWrite") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ]; + Ty.associated; + Ty.apply + (Ty.path "halo2_proofs::transcript::Challenge255") + [ Ty.associated ] + ]; + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::ZkWasmCircuit") + [ Ty.associated ] + ] + |), + [ + M.read (| params |); + M.read (| pk |); + M.call_closure (| + M.get_function (| + "core::slice::raw::from_ref", + [ + Ty.apply + (Ty.path "delphinus_zkwasm::circuits::ZkWasmCircuit") + [ Ty.associated ] + ] + |), + [ M.read (| circuit |) ] + |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" + ], + [ Ty.path "core::ops::range::RangeFull" ], + "index", + [] + |), + [ + M.read (| instances |); + Value.StructTuple "core::ops::range::RangeFull" [] + ] + |) + ] + |)) + ] + |)); + Value.StructTuple "rand_core::os::OsRng" []; + transcript + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ]; + Ty.path "anyhow::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::transcript::Blake2bWrite") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ]; + Ty.associated; + Ty.apply + (Ty.path "halo2_proofs::transcript::Challenge255") + [ Ty.associated ] + ], + "finalize", + [] + |), + [ M.read (| transcript |) ] + |) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_create_proof : M.IsAssociatedFunction Self "create_proof" create_proof. + + (* + fn init_env(&self) -> Result<()> { + init_zkwasm_runtime(self.k); + + Ok(()) + } + *) + Definition init_env (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::config::init_zkwasm_runtime", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::ZkWasmLoader", + "k" + |) + |) + ] + |) + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_init_env : M.IsAssociatedFunction Self "init_env" init_env. + + (* + pub fn verify_proof( + &self, + params: &Params, + vkey: &VerifyingKey, + instances: &Vec, + proof: Vec, + ) -> Result<()> { + let params_verifier: ParamsVerifier = params.verifier(instances.len()).unwrap(); + let strategy = SingleVerifier::new(¶ms_verifier); + + verify_proof( + ¶ms_verifier, + vkey, + strategy, + &[&[&instances]], + &mut Blake2bRead::init(&proof[..]), + ) + .unwrap(); + + Ok(()) + } + *) + Definition verify_proof (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ E ], [ self; params; vkey; instances; proof ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let params := M.alloc (| params |) in + let vkey := M.alloc (| vkey |) in + let instances := M.alloc (| instances |) in + let proof := M.alloc (| proof |) in + M.read (| + let params_verifier := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "halo2_proofs::poly::commitment::ParamsVerifier") [ E ]; + Ty.path "std::io::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::poly::commitment::Params") + [ Ty.associated ], + "verifier", + [ E ] + |), + [ + M.read (| params |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ M.read (| instances |) ] + |) + ] + |) + ] + |) + |) in + let strategy := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "halo2_proofs::plonk::verifier::SingleVerifier") [ E ], + "new", + [] + |), + [ params_verifier ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "halo2_proofs::plonk::error::Error" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_function (| + "halo2_proofs::plonk::verifier::verify_proof", + [ + E; + Ty.apply + (Ty.path "halo2_proofs::transcript::Challenge255") + [ Ty.associated ]; + Ty.apply + (Ty.path "halo2_proofs::transcript::Blake2bRead") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]; + Ty.associated; + Ty.apply + (Ty.path "halo2_proofs::transcript::Challenge255") + [ Ty.associated ] + ]; + Ty.apply (Ty.path "halo2_proofs::plonk::verifier::SingleVerifier") [ E ] + ] + |), + [ + params_verifier; + M.read (| vkey |); + M.read (| strategy |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.associated; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ M.read (| instances |) ] + |) + ] + |)) + ] + |)); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::transcript::Blake2bRead") + [ + Ty.apply + (Ty.path "&") + [ Ty.apply (Ty.path "slice") [ Ty.path "u8" ] ]; + Ty.associated; + Ty.apply + (Ty.path "halo2_proofs::transcript::Challenge255") + [ Ty.associated ] + ], + "init", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u8"; Ty.path "alloc::alloc::Global" ], + [ Ty.path "core::ops::range::RangeFull" ], + "index", + [] + |), + [ proof; Value.StructTuple "core::ops::range::RangeFull" [] ] + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_verify_proof : M.IsAssociatedFunction Self "verify_proof" verify_proof. + + (* + pub fn checksum( + &self, + params: &Params, + compilation_table: &CompilationTable, + ) -> Result> { + Ok(compilation_table.checksum(self.k, params)) + } + *) + Definition checksum (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ C ], [ self; params; compilation_table ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let params := M.alloc (| params |) in + let compilation_table := M.alloc (| compilation_table |) in + Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::checksum::ImageCheckSum", + Ty.path "specs::CompilationTable", + [ C; Ty.apply (Ty.path "alloc::vec::Vec") [ C; Ty.path "alloc::alloc::Global" ] ], + "checksum", + [] + |), + [ + M.read (| compilation_table |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::ZkWasmLoader", + "k" + |) + |); + M.read (| params |) + ] + |) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_checksum : M.IsAssociatedFunction Self "checksum" checksum. + End Impl_delphinus_zkwasm_loader_ZkWasmLoader. + + +End loader. diff --git a/CoqOfRust/zkWasm/loader/slice.v b/CoqOfRust/zkWasm/loader/slice.v new file mode 100644 index 000000000..58f5fb157 --- /dev/null +++ b/CoqOfRust/zkWasm/loader/slice.v @@ -0,0 +1,1695 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module loader. + Module slice. + (* StructRecord + { + name := "Slices"; + ty_params := [ "F" ]; + fields := + [ + ("k", Ty.path "u32"); + ("itable", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ Ty.path "specs::itable::InstructionTable"; Ty.path "alloc::alloc::Global" ]); + ("br_table", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ Ty.path "specs::brtable::BrTable"; Ty.path "alloc::alloc::Global" ]); + ("elem_table", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ Ty.path "specs::brtable::ElemTable"; Ty.path "alloc::alloc::Global" ]); + ("configure_table", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ Ty.path "specs::configure_table::ConfigureTable"; Ty.path "alloc::alloc::Global" + ]); + ("static_jtable", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply (Ty.path "array") [ Ty.path "specs::jtable::StaticFrameEntry" ]; + Ty.path "alloc::alloc::Global" + ]); + ("frame_table", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ Ty.path "specs::jtable::JumpTable"; Ty.path "alloc::alloc::Global" ]); + ("imtable", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ Ty.path "specs::imtable::InitMemoryTable"; Ty.path "alloc::alloc::Global" ]); + ("initialization_state", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ Ty.path "u32"; Ty.path "num_bigint::biguint::BigUint" ]; + Ty.path "alloc::alloc::Global" + ]); + ("etables", + Ty.apply + (Ty.path "alloc::collections::vec_deque::VecDeque") + [ Ty.path "specs::etable::EventTableBackend"; Ty.path "alloc::alloc::Global" ]); + ("_marker", Ty.apply (Ty.path "core::marker::PhantomData") [ F ]) + ]; + } *) + + Module Impl_delphinus_zkwasm_loader_slice_Slices_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::loader::slice::Slices") [ F ]. + + (* + pub fn new(k: u32, tables: Tables) -> Result { + if cfg!(not(feature = "continuation")) { + let slices = tables.execution_tables.etable.len(); + + if slices != 1 { + return Err(BuildingCircuitError::MultiSlicesNotSupport(slices)); + } + } + + Ok(Self { + k, + + itable: tables.compilation_tables.itable, + br_table: tables.compilation_tables.br_table, + elem_table: tables.compilation_tables.elem_table, + configure_table: tables.compilation_tables.configure_table, + static_jtable: tables.compilation_tables.static_jtable, + frame_table: Arc::new(tables.execution_tables.jtable), + + imtable: tables.compilation_tables.imtable, + initialization_state: tables.compilation_tables.initialization_state, + + etables: tables.execution_tables.etable.into(), + + _marker: std::marker::PhantomData, + }) + } + *) + Definition new (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ k; tables ] => + ltac:(M.monadic + (let k := M.alloc (| k |) in + let tables := M.alloc (| tables |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use (M.alloc (| Value.Bool true |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let slices := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::etable::EventTableBackend"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + tables, + "specs::Tables", + "execution_tables" + |), + "specs::ExecutionTable", + "etable" + |) + ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne (M.read (| slices |)) (Value.Integer 1) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "delphinus_zkwasm::error::BuildingCircuitError::MultiSlicesNotSupport" + [ M.read (| slices |) ] + ] + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "delphinus_zkwasm::loader::slice::Slices" + [ + ("k", M.read (| k |)); + ("itable", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + tables, + "specs::Tables", + "compilation_tables" + |), + "specs::CompilationTable", + "itable" + |) + |)); + ("br_table", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + tables, + "specs::Tables", + "compilation_tables" + |), + "specs::CompilationTable", + "br_table" + |) + |)); + ("elem_table", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + tables, + "specs::Tables", + "compilation_tables" + |), + "specs::CompilationTable", + "elem_table" + |) + |)); + ("configure_table", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + tables, + "specs::Tables", + "compilation_tables" + |), + "specs::CompilationTable", + "configure_table" + |) + |)); + ("static_jtable", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + tables, + "specs::Tables", + "compilation_tables" + |), + "specs::CompilationTable", + "static_jtable" + |) + |)); + ("frame_table", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::jtable::JumpTable"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + tables, + "specs::Tables", + "execution_tables" + |), + "specs::ExecutionTable", + "jtable" + |) + |) + ] + |)); + ("imtable", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + tables, + "specs::Tables", + "compilation_tables" + |), + "specs::CompilationTable", + "imtable" + |) + |)); + ("initialization_state", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + tables, + "specs::Tables", + "compilation_tables" + |), + "specs::CompilationTable", + "initialization_state" + |) + |)); + ("etables", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::etable::EventTableBackend"; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.apply + (Ty.path "alloc::collections::vec_deque::VecDeque") + [ + Ty.path "specs::etable::EventTableBackend"; + Ty.path "alloc::alloc::Global" + ] + ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + tables, + "specs::Tables", + "execution_tables" + |), + "specs::ExecutionTable", + "etable" + |) + |) + ] + |)); + ("_marker", Value.StructTuple "core::marker::PhantomData" []) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "new" (new F). + + (* + pub fn mock_test_all(self, instances: Vec) -> anyhow::Result<()> { + use halo2_proofs::dev::MockProver; + + let k = self.k; + let mut iter = self.into_iter(); + + while let Some(slice) = iter.next() { + let prover = MockProver::run(k, &slice?, vec![instances.clone()])?; + assert_eq!(prover.verify(), Ok(())); + } + + Ok(()) + } + *) + Definition mock_test_all (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self; instances ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let instances := M.alloc (| instances |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let k := + M.copy (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::loader::slice::Slices", + "k" + |) + |) in + let iter := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "delphinus_zkwasm::loader::slice::Slices") [ F ], + [], + "into_iter", + [] + |), + [ M.read (| self |) ] + |) + |) in + let _ := + M.loop (| + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "delphinus_zkwasm::loader::slice::Slices") + [ F ], + [], + "next", + [] + |), + [ iter ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let slice := M.copy (| γ0_0 |) in + let prover := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "halo2_proofs::dev::MockVerifier") + [ F ]; + Ty.path "halo2_proofs::plonk::error::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::dev::MockProver") + [ F ], + "run", + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::ZkWasmCircuit") + [ F ] + ] + |), + [ + M.read (| k |); + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::circuits::ZkWasmCircuit") + [ F ]; + Ty.path + "delphinus_zkwasm::error::BuildingCircuitError" + ], + [], + "branch", + [] + |), + [ M.read (| slice |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path "anyhow::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "delphinus_zkwasm::error::BuildingCircuitError" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ F; Ty.path "alloc::alloc::Global" ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + F; + Ty.path + "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ instances ] + |) + ] + |) + ] + |) + |)) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "anyhow::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path + "halo2_proofs::plonk::error::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "halo2_proofs::dev::MockVerifier") + [ F ], + "verify", + [] + |), + [ prover ] + |) + |); + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ Value.Tuple [] ] + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure"; + Ty.path "alloc::alloc::Global" + ] + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure"; + Ty.path + "alloc::alloc::Global" + ] + ] + ], + "eq", + [] + |), + [ + M.read (| left_val |); + M.read (| right_val |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure"; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "halo2_proofs::dev::VerifyFailure"; + Ty.path + "alloc::alloc::Global" + ] + ] + ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + let _ := + M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |) in + M.alloc (| Value.Tuple [] |) + |) + |) + |))) + ] + |))) + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_mock_test_all : + forall (F : Ty.t), + M.IsAssociatedFunction (Self F) "mock_test_all" (mock_test_all F). + End Impl_delphinus_zkwasm_loader_slice_Slices_F. + + Module Impl_core_iter_traits_iterator_Iterator_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_loader_slice_Slices_F. + Definition Self (F : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::loader::slice::Slices") [ F ]. + + (* type Item = Result, BuildingCircuitError>; *) + Definition _Item (F : Ty.t) : Ty.t := + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply (Ty.path "delphinus_zkwasm::circuits::ZkWasmCircuit") [ F ]; + Ty.path "delphinus_zkwasm::error::BuildingCircuitError" + ]. + + (* + fn next(&mut self) -> Option { + if self.etables.is_empty() { + return None; + } + + let etable = match self.etables.pop_front().unwrap() { + EventTableBackend::Memory(etable) => etable, + EventTableBackend::Json(path) => EventTable::read(&path).unwrap(), + }; + + let post_imtable = Arc::new(self.imtable.update_init_memory_table(&etable)); + let post_initialization_state = Arc::new({ + let next_event_entry = if let Some(next_event_table) = self.etables.front() { + match next_event_table { + EventTableBackend::Memory(etable) => etable.entries().first().cloned(), + EventTableBackend::Json(path) => { + let etable = EventTable::read(&path).unwrap(); + etable.entries().first().cloned() + } + } + } else { + None + }; + + self.initialization_state.update_initialization_state( + &etable, + &self.configure_table, + next_event_entry.as_ref(), + ) + }); + + let slice = Slice { + itable: self.itable.clone(), + br_table: self.br_table.clone(), + elem_table: self.elem_table.clone(), + configure_table: self.configure_table.clone(), + static_jtable: self.static_jtable.clone(), + frame_table: self.frame_table.clone(), + + imtable: self.imtable.clone(), + post_imtable: post_imtable.clone(), + + initialization_state: self.initialization_state.clone(), + post_initialization_state: post_initialization_state.clone(), + + etable: Arc::new(etable), + is_last_slice: self.etables.is_empty(), + }; + + self.imtable = post_imtable; + self.initialization_state = post_initialization_state; + + let circuit = ZkWasmCircuit::new(self.k, slice); + + Some(circuit) + } + *) + Definition next (F : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self F in + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::vec_deque::VecDeque") + [ + Ty.path "specs::etable::EventTableBackend"; + Ty.path "alloc::alloc::Global" + ], + "is_empty", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::slice::Slices", + "etables" + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| Value.StructTuple "core::option::Option::None" [] |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let etable := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "specs::etable::EventTableBackend" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::vec_deque::VecDeque") + [ + Ty.path "specs::etable::EventTableBackend"; + Ty.path "alloc::alloc::Global" + ], + "pop_front", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::slice::Slices", + "etables" + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "specs::etable::EventTableBackend::Memory", + 0 + |) in + let etable := M.copy (| γ0_0 |) in + etable)); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "specs::etable::EventTableBackend::Json", + 0 + |) in + let path := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "specs::etable::EventTable"; + Ty.path "std::io::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::etable::EventTable", + "read", + [] + |), + [ path ] + |) + ] + |) + |))) + ] + |) + |) in + let post_imtable := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::imtable::InitMemoryTable"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::runtime::state::UpdateInitMemoryTable", + Ty.path "specs::imtable::InitMemoryTable", + [], + "update_init_memory_table", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::imtable::InitMemoryTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::slice::Slices", + "imtable" + |) + ] + |); + etable + ] + |) + ] + |) + |) in + let post_initialization_state := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ Ty.path "u32"; Ty.path "num_bigint::biguint::BigUint" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.read (| + let next_event_entry := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::vec_deque::VecDeque") + [ + Ty.path "specs::etable::EventTableBackend"; + Ty.path "alloc::alloc::Global" + ], + "front", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::slice::Slices", + "etables" + |) + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let next_event_table := M.copy (| γ0_0 |) in + M.match_operator (| + next_event_table, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "specs::etable::EventTableBackend::Memory", + 0 + |) in + let etable := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "specs::etable::EventTableEntry" + ] + ], + "cloned", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "specs::etable::EventTableEntry" + ], + "first", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::etable::EventTableEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::etable::EventTable", + "entries", + [] + |), + [ M.read (| etable |) ] + |) + ] + |) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "specs::etable::EventTableBackend::Json", + 0 + |) in + let path := M.alloc (| γ1_0 |) in + let etable := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "specs::etable::EventTable"; + Ty.path "std::io::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::etable::EventTable", + "read", + [] + |), + [ M.read (| path |) ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "specs::etable::EventTableEntry" + ] + ], + "cloned", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "specs::etable::EventTableEntry" + ], + "first", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::etable::EventTableEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::etable::EventTable", + "entries", + [] + |), + [ etable ] + |) + ] + |) + ] + |) + ] + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple "core::option::Option::None" [] + |))) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::runtime::state::UpdateInitializationState", + Ty.apply + (Ty.path "specs::state::InitializationState") + [ Ty.path "u32"; Ty.path "num_bigint::biguint::BigUint" ], + [], + "update_initialization_state", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ Ty.path "u32"; Ty.path "num_bigint::biguint::BigUint" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::slice::Slices", + "initialization_state" + |) + ] + |); + etable; + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::configure_table::ConfigureTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::slice::Slices", + "configure_table" + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "specs::etable::EventTableEntry" ], + "as_ref", + [] + |), + [ next_event_entry ] + |) + ] + |) + |) + |) + ] + |) + |) in + let slice := + M.alloc (| + Value.StructRecord + "specs::slice::Slice" + [ + ("itable", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::itable::InstructionTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::slice::Slices", + "itable" + |) + ] + |)); + ("br_table", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::brtable::BrTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::slice::Slices", + "br_table" + |) + ] + |)); + ("elem_table", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::brtable::ElemTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::slice::Slices", + "elem_table" + |) + ] + |)); + ("configure_table", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::configure_table::ConfigureTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::slice::Slices", + "configure_table" + |) + ] + |)); + ("static_jtable", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::jtable::StaticFrameEntry" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::slice::Slices", + "static_jtable" + |) + ] + |)); + ("frame_table", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::jtable::JumpTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::slice::Slices", + "frame_table" + |) + ] + |)); + ("imtable", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::imtable::InitMemoryTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::slice::Slices", + "imtable" + |) + ] + |)); + ("post_imtable", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::imtable::InitMemoryTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ post_imtable ] + |)); + ("initialization_state", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ Ty.path "u32"; Ty.path "num_bigint::biguint::BigUint" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::slice::Slices", + "initialization_state" + |) + ] + |)); + ("post_initialization_state", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ Ty.path "u32"; Ty.path "num_bigint::biguint::BigUint" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ post_initialization_state ] + |)); + ("etable", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::etable::EventTable"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| etable |) ] + |)); + ("is_last_slice", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::vec_deque::VecDeque") + [ + Ty.path "specs::etable::EventTableBackend"; + Ty.path "alloc::alloc::Global" + ], + "is_empty", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::slice::Slices", + "etables" + |) + ] + |)) + ] + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::slice::Slices", + "imtable" + |), + M.read (| post_imtable |) + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::slice::Slices", + "initialization_state" + |), + M.read (| post_initialization_state |) + |) in + let circuit := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "delphinus_zkwasm::circuits::ZkWasmCircuit") [ F ], + "new", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::loader::slice::Slices", + "k" + |) + |); + M.read (| slice |) + ] + |) + |) in + M.alloc (| + Value.StructTuple "core::option::Option::Some" [ M.read (| circuit |) ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + forall (F : Ty.t), + M.IsTraitInstance + "core::iter::traits::iterator::Iterator" + (Self F) + (* Trait polymorphic types *) [] + (* Instance *) + [ ("Item", InstanceField.Ty (_Item F)); ("next", InstanceField.Method (next F)) ]. + End Impl_core_iter_traits_iterator_Iterator_where_pairing_bn256_arithmetic_fields_FieldExt_F_for_delphinus_zkwasm_loader_slice_Slices_F. + End slice. +End loader. diff --git a/CoqOfRust/zkWasm/profile/mod.v b/CoqOfRust/zkWasm/profile/mod.v new file mode 100644 index 000000000..27c53bcbc --- /dev/null +++ b/CoqOfRust/zkWasm/profile/mod.v @@ -0,0 +1,32 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module profile. + (* Trait *) + (* Empty module 'Profiler' *) + + Module Impl_delphinus_zkwasm_profile_Profiler_for_specs_Tables. + Definition Self : Ty.t := Ty.path "specs::Tables". + + (* + fn profile_tables(&self) { + //self.profile_instruction(); + } + *) + Definition profile_tables (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.Tuple [])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "delphinus_zkwasm::profile::Profiler" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("profile_tables", InstanceField.Method profile_tables) ]. + End Impl_delphinus_zkwasm_profile_Profiler_for_specs_Tables. +End profile. diff --git a/CoqOfRust/zkWasm/runtime/host/default_env.v b/CoqOfRust/zkWasm/runtime/host/default_env.v new file mode 100644 index 000000000..b473995f5 --- /dev/null +++ b/CoqOfRust/zkWasm/runtime/host/default_env.v @@ -0,0 +1,366 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module runtime. + Module host. + Module default_env. + (* StructRecord + { + name := "ExecutionArg"; + ty_params := []; + fields := + [ + ("public_inputs", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ]); + ("private_inputs", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ]); + ("context_inputs", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ]) + ]; + } *) + + Module Impl_core_clone_Clone_for_delphinus_zkwasm_runtime_host_default_env_ExecutionArg. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::host::default_env::ExecutionArg". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::runtime::host::default_env::ExecutionArg" + [ + ("public_inputs", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::default_env::ExecutionArg", + "public_inputs" + |) + ] + |)); + ("private_inputs", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::default_env::ExecutionArg", + "private_inputs" + |) + ] + |)); + ("context_inputs", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::default_env::ExecutionArg", + "context_inputs" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_delphinus_zkwasm_runtime_host_default_env_ExecutionArg. + + (* StructTuple + { + name := "DefaultHostEnvBuilder"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_runtime_host_HostEnvBuilder_for_delphinus_zkwasm_runtime_host_default_env_DefaultHostEnvBuilder. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::host::default_env::DefaultHostEnvBuilder". + + (* + fn create_env_without_value(&self, k: u32) -> HostEnv { + let mut env = HostEnv::new(k); + register_wasm_input_foreign(&mut env, vec![], vec![]); + register_require_foreign(&mut env); + register_log_foreign(&mut env); + register_context_foreign(&mut env, vec![]); + env.finalize(); + + env + } + *) + Definition create_env_without_value (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; k ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let k := M.alloc (| k |) in + M.read (| + let env := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "new", + [] + |), + [ M.read (| k |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::register_wasm_input_foreign", + [] + |), + [ + env; + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::foreign::require_helper::register_require_foreign", + [] + |), + [ env ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::foreign::log_helper::register_log_foreign", + [] + |), + [ env ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::foreign::context::runtime::register_context_foreign", + [] + |), + [ + env; + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "finalize", + [] + |), + [ env ] + |) + |) in + env + |))) + | _, _ => M.impossible + end. + + (* + fn create_env(&self, k: u32, arg: ExecutionArg) -> HostEnv { + let mut env = HostEnv::new(k); + register_wasm_input_foreign(&mut env, arg.public_inputs, arg.private_inputs); + register_require_foreign(&mut env); + register_log_foreign(&mut env); + register_context_foreign(&mut env, arg.context_inputs); + env.finalize(); + + env + } + *) + Definition create_env (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; k; arg ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let k := M.alloc (| k |) in + let arg := M.alloc (| arg |) in + M.read (| + let env := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "new", + [] + |), + [ M.read (| k |) ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::foreign::wasm_input_helper::runtime::register_wasm_input_foreign", + [] + |), + [ + env; + M.read (| + M.SubPointer.get_struct_record_field (| + arg, + "delphinus_zkwasm::runtime::host::default_env::ExecutionArg", + "public_inputs" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + arg, + "delphinus_zkwasm::runtime::host::default_env::ExecutionArg", + "private_inputs" + |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::foreign::require_helper::register_require_foreign", + [] + |), + [ env ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::foreign::log_helper::register_log_foreign", + [] + |), + [ env ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::foreign::context::runtime::register_context_foreign", + [] + |), + [ + env; + M.read (| + M.SubPointer.get_struct_record_field (| + arg, + "delphinus_zkwasm::runtime::host::default_env::ExecutionArg", + "context_inputs" + |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "finalize", + [] + |), + [ env ] + |) + |) in + env + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "delphinus_zkwasm::runtime::host::HostEnvBuilder" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ + ("create_env_without_value", InstanceField.Method create_env_without_value); + ("create_env", InstanceField.Method create_env) + ]. + End Impl_delphinus_zkwasm_runtime_host_HostEnvBuilder_for_delphinus_zkwasm_runtime_host_default_env_DefaultHostEnvBuilder. + End default_env. + End host. +End runtime. diff --git a/CoqOfRust/zkWasm/runtime/host/external_circuit_plugin.v b/CoqOfRust/zkWasm/runtime/host/external_circuit_plugin.v new file mode 100644 index 000000000..21d41d454 --- /dev/null +++ b/CoqOfRust/zkWasm/runtime/host/external_circuit_plugin.v @@ -0,0 +1,1069 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module runtime. + Module host. + Module external_circuit_plugin. + (* StructRecord + { + name := "ForeignOp"; + ty_params := []; + fields := + [ + ("op_index", Ty.path "usize"); + ("sig", Ty.path "specs::external_host_call_table::ExternalHostCallSignature"); + ("plugin", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.path "delphinus_zkwasm::runtime::host::ForeignPlugin"; + Ty.path "alloc::alloc::Global" + ]); + ("cb", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + (* StructRecord + { + name := "ExternalCircuitEnv"; + ty_params := []; + fields := + [ + ("functions", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "delphinus_zkwasm::runtime::host::external_circuit_plugin::ForeignOp"; + Ty.path "std::hash::random::RandomState" + ]); + ("finalized", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply (Ty.path "core::cell::RefCell") [ Ty.path "bool" ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_delphinus_zkwasm_runtime_host_external_circuit_plugin_ExternalCircuitEnv. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::host::external_circuit_plugin::ExternalCircuitEnv". + + (* + pub(super) fn new(finalized: Rc>) -> Self { + Self { + functions: HashMap::new(), + finalized, + } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ finalized ] => + ltac:(M.monadic + (let finalized := M.alloc (| finalized |) in + Value.StructRecord + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ExternalCircuitEnv" + [ + ("functions", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ForeignOp"; + Ty.path "std::hash::random::RandomState" + ], + "new", + [] + |), + [] + |)); + ("finalized", M.read (| finalized |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + + (* + pub fn register_plugin( + &mut self, + name: &str, + ctx: Box, + ) -> Rc { + Rc::new(ForeignPlugin { + name: name.to_string(), + ctx: Rc::new(RefCell::new(ctx)), + }) + } + *) + Definition register_plugin (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; name; ctx ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + let ctx := M.alloc (| ctx |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.path "delphinus_zkwasm::runtime::host::ForeignPlugin"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "delphinus_zkwasm::runtime::host::ForeignPlugin" + [ + ("name", + M.call_closure (| + M.get_trait_method (| + "alloc::string::ToString", + Ty.path "str", + [], + "to_string", + [] + |), + [ M.read (| name |) ] + |)); + ("ctx", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "new", + [] + |), + [ (* Unsize *) M.pointer_coercion (M.read (| ctx |)) ] + |)) + ] + |)) + ] + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_register_plugin : + M.IsAssociatedFunction Self "register_plugin" register_plugin. + + (* + pub fn register_function( + &mut self, + name: &str, + op_index: usize, + sig: ExternalHostCallSignature, + plugin: Rc, + cb: Rc Option>, + ) { + assert!(!*self.finalized.borrow()); + + self.functions.insert( + name.to_owned(), + ForeignOp { + op_index, + sig, + plugin, + cb, + }, + ); + } + *) + Definition register_function (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; name; op_index; sig; plugin; cb ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + let op_index := M.alloc (| op_index |) in + let sig := M.alloc (| sig |) in + let plugin := M.alloc (| plugin |) in + let cb := M.alloc (| cb |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (UnOp.Pure.not + (M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply (Ty.path "core::cell::Ref") [ Ty.path "bool" ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ Ty.path "bool" ], + "borrow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ Ty.path "bool" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ExternalCircuitEnv", + "finalized" + |) + ] + |) + ] + |) + |) + ] + |) + |))) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "assertion failed: !*self.finalized.borrow()" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ForeignOp"; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ExternalCircuitEnv", + "functions" + |); + M.call_closure (| + M.get_trait_method (| + "alloc::borrow::ToOwned", + Ty.path "str", + [], + "to_owned", + [] + |), + [ M.read (| name |) ] + |); + Value.StructRecord + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ForeignOp" + [ + ("op_index", M.read (| op_index |)); + ("sig", M.read (| sig |)); + ("plugin", M.read (| plugin |)); + ("cb", (* Unsize *) M.pointer_coercion (M.read (| cb |))) + ] + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_register_function : + M.IsAssociatedFunction Self "register_function" register_function. + + (* + pub fn get_statics(&self) -> HashMap { + let mut m = HashMap::new(); + for (_, v) in &self.functions { + let plugin_name = &v.plugin.name; + + if !m.contains_key(plugin_name) { + if let Some(stat) = (v.plugin.ctx).as_ref().borrow().get_statics() { + m.insert(plugin_name.to_string(), stat); + } + } + } + m + } + *) + Definition get_statics (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let m := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "delphinus_zkwasm::runtime::host::ForeignStatics"; + Ty.path "std::hash::random::RandomState" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ForeignOp"; + Ty.path "std::hash::random::RandomState" + ] + ], + [], + "into_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ExternalCircuitEnv", + "functions" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path "alloc::string::String"; + Ty.path + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ForeignOp" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let v := M.copy (| γ1_1 |) in + let plugin_name := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.path + "delphinus_zkwasm::runtime::host::ForeignPlugin"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| v |), + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ForeignOp", + "plugin" + |) + ] + |), + "delphinus_zkwasm::runtime::host::ForeignPlugin", + "name" + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path + "delphinus_zkwasm::runtime::host::ForeignStatics"; + Ty.path + "std::hash::random::RandomState" + ], + "contains_key", + [ Ty.path "alloc::string::String" ] + |), + [ m; M.read (| plugin_name |) ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::runtime::host::ForeignContext", + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ], + [], + "get_statics", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "core::cell::Ref") + [ + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path + "alloc::alloc::Global" + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path + "alloc::alloc::Global" + ] + ], + "borrow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::AsRef", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path + "alloc::alloc::Global" + ] + ] + ], + "as_ref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.path + "delphinus_zkwasm::runtime::host::ForeignPlugin"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + v + |), + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ForeignOp", + "plugin" + |) + ] + |), + "delphinus_zkwasm::runtime::host::ForeignPlugin", + "ctx" + |) + ] + |) + ] + |) + |) + ] + |) + |) + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let stat := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path + "alloc::string::String"; + Ty.path + "delphinus_zkwasm::runtime::host::ForeignStatics"; + Ty.path + "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + m; + M.call_closure (| + M.get_trait_method (| + "alloc::string::ToString", + Ty.path + "alloc::string::String", + [], + "to_string", + [] + |), + [ M.read (| plugin_name |) ] + |); + M.read (| stat |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + m + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get_statics : + M.IsAssociatedFunction Self "get_statics" get_statics. + End Impl_delphinus_zkwasm_runtime_host_external_circuit_plugin_ExternalCircuitEnv. + + Module Impl_wasmi_imports_ModuleImportResolver_for_delphinus_zkwasm_runtime_host_external_circuit_plugin_ExternalCircuitEnv. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::host::external_circuit_plugin::ExternalCircuitEnv". + + (* + fn resolve_func( + &self, + function_name: &str, + signature: &wasmi::Signature, + ) -> Result { + if let Some(function) = self.functions.get(function_name) { + if function.sig.match_wasmi_signature(signature) { + Ok(FuncInstance::alloc_host( + signature.clone(), + function.op_index, + )) + } else { + Err(wasmi::Error::Instantiation(format!( + "Export `{}` doesn't match expected type {:?}", + function_name, signature + ))) + } + } else { + Err(wasmi::Error::Instantiation(format!( + "Export {} not found", + function_name + ))) + } + } + *) + Definition resolve_func (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; function_name; signature ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let function_name := M.alloc (| function_name |) in + let signature := M.alloc (| signature |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ForeignOp"; + Ty.path "std::hash::random::RandomState" + ], + "get", + [ Ty.path "str" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ExternalCircuitEnv", + "functions" + |); + M.read (| function_name |) + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let function := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::runtime::host::MatchForeignOpSignature", + Ty.path + "specs::external_host_call_table::ExternalHostCallSignature", + [], + "match_wasmi_signature", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| function |), + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ForeignOp", + "sig" + |); + M.read (| signature |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::func::FuncInstance", + "alloc_host", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "wasmi::types::Signature", + [], + "clone", + [] + |), + [ M.read (| signature |) ] + |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| function |), + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ForeignOp", + "op_index" + |) + |) + ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "wasmi::Error::Instantiation" + [ + M.read (| + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String "Export `" + |); + M.read (| + Value.String + "` doesn't match expected type " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ function_name ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_debug", + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "wasmi::types::Signature" + ] + ] + |), + [ signature ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) + ] + ] + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "wasmi::Error::Instantiation" + [ + M.read (| + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "Export " |); + M.read (| Value.String " not found" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ function_name ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) + ] + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "wasmi::imports::ModuleImportResolver" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("resolve_func", InstanceField.Method resolve_func) ]. + End Impl_wasmi_imports_ModuleImportResolver_for_delphinus_zkwasm_runtime_host_external_circuit_plugin_ExternalCircuitEnv. + End external_circuit_plugin. + End host. +End runtime. diff --git a/CoqOfRust/zkWasm/runtime/host/host_env.v b/CoqOfRust/zkWasm/runtime/host/host_env.v new file mode 100644 index 000000000..1b6c56397 --- /dev/null +++ b/CoqOfRust/zkWasm/runtime/host/host_env.v @@ -0,0 +1,2173 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module runtime. + Module host. + Module host_env. + (* StructRecord + { + name := "HostEnv"; + ty_params := []; + fields := + [ + ("k", Ty.path "u32"); + ("internal_env", + Ty.path + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv"); + ("external_env", + Ty.path + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ExternalCircuitEnv"); + ("finalized", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply (Ty.path "core::cell::RefCell") [ Ty.path "bool" ]; + Ty.path "alloc::alloc::Global" + ]); + ("cached_lookup", + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "delphinus_zkwasm::runtime::host::HostFunction"; + Ty.path "std::hash::random::RandomState" + ] + ]); + ("time_profile", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ Ty.path "alloc::string::String"; Ty.path "u128"; Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_delphinus_zkwasm_runtime_host_host_env_HostEnv. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::runtime::host::host_env::HostEnv". + + (* + pub fn new(k: u32) -> Self { + let finalized = Rc::new(RefCell::new(false)); + + Self { + k, + internal_env: InternalCircuitEnv::new(finalized.clone()), + external_env: ExternalCircuitEnv::new(finalized.clone()), + cached_lookup: None, + finalized, + time_profile: BTreeMap::new(), + } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ k ] => + ltac:(M.monadic + (let k := M.alloc (| k |) in + M.read (| + let finalized := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply (Ty.path "core::cell::RefCell") [ Ty.path "bool" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::cell::RefCell") [ Ty.path "bool" ], + "new", + [] + |), + [ Value.Bool false ] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::runtime::host::host_env::HostEnv" + [ + ("k", M.read (| k |)); + ("internal_env", + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv", + "new", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply (Ty.path "core::cell::RefCell") [ Ty.path "bool" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ finalized ] + |) + ] + |)); + ("external_env", + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ExternalCircuitEnv", + "new", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply (Ty.path "core::cell::RefCell") [ Ty.path "bool" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ finalized ] + |) + ] + |)); + ("cached_lookup", Value.StructTuple "core::option::Option::None" []); + ("finalized", M.read (| finalized |)); + ("time_profile", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "alloc::string::String"; + Ty.path "u128"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + + (* + pub fn finalize(&mut self) { + let mut lookup = HashMap::::new(); + + let mut internal_op_allocator_offset = 0; + + for (name, op) in &self.external_env.functions { + internal_op_allocator_offset = usize::max(internal_op_allocator_offset, op.op_index); + + lookup + .insert( + op.op_index, + HostFunction { + desc: HostFunctionDesc::External { + name: name.to_owned(), + op: op.op_index, + sig: op.sig.into(), + }, + execution_env: HostFunctionExecutionEnv { + ctx: op.plugin.ctx.clone(), + cb: op.cb.clone(), + }, + }, + ) + .map(|_| panic!("conflicting op index of foreign function")); + } + + internal_op_allocator_offset += 1; + + for (name, op) in &mut self.internal_env.functions { + op.index = Some(internal_op_allocator_offset); + + lookup.insert( + internal_op_allocator_offset, + HostFunction { + desc: HostFunctionDesc::Internal { + name: name.to_owned(), + op_index_in_plugin: op.index_within_plugin, + plugin: op.plugin, + }, + execution_env: HostFunctionExecutionEnv { + ctx: self + .internal_env + .plugins + .get(&op.plugin) + .unwrap() + .ctx + .clone(), + cb: op.cb.clone(), + }, + }, + ); + + internal_op_allocator_offset += 1; + } + + self.cached_lookup = Some(lookup); + + let mut finalized = self.finalized.borrow_mut(); + *finalized = true; + } + *) + Definition finalize (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let lookup := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "delphinus_zkwasm::runtime::host::HostFunction"; + Ty.path "std::hash::random::RandomState" + ], + "new", + [] + |), + [] + |) + |) in + let internal_op_allocator_offset := M.alloc (| Value.Integer 0 |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ForeignOp"; + Ty.path "std::hash::random::RandomState" + ] + ], + [], + "into_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "external_env" + |), + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ExternalCircuitEnv", + "functions" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path "alloc::string::String"; + Ty.path + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ForeignOp" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let name := M.copy (| γ1_0 |) in + let op := M.copy (| γ1_1 |) in + let _ := + M.write (| + internal_op_allocator_offset, + M.call_closure (| + M.get_trait_method (| + "core::cmp::Ord", + Ty.path "usize", + [], + "max", + [] + |), + [ + M.read (| internal_op_allocator_offset |); + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| op |), + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ForeignOp", + "op_index" + |) + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::host::HostFunction" + ], + "map", + [ + Ty.tuple []; + Ty.function + [ + Ty.tuple + [ + Ty.path + "delphinus_zkwasm::runtime::host::HostFunction" + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path + "delphinus_zkwasm::runtime::host::HostFunction"; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + lookup; + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| op |), + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ForeignOp", + "op_index" + |) + |); + Value.StructRecord + "delphinus_zkwasm::runtime::host::HostFunction" + [ + ("desc", + Value.StructRecord + "specs::host_function::HostFunctionDesc::External" + [ + ("name", + M.call_closure (| + M.get_trait_method (| + "alloc::borrow::ToOwned", + Ty.path + "alloc::string::String", + [], + "to_owned", + [] + |), + [ M.read (| name |) ] + |)); + ("op", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| op |), + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ForeignOp", + "op_index" + |) + |)); + ("sig", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "specs::external_host_call_table::ExternalHostCallSignature", + [ + Ty.path + "specs::external_host_call_table::ExternalHostCallSignature" + ], + "into", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| op |), + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ForeignOp", + "sig" + |) + |) + ] + |)) + ]); + ("execution_env", + Value.StructRecord + "delphinus_zkwasm::runtime::host::HostFunctionExecutionEnv" + [ + ("ctx", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::rc::Rc") + [ + Ty.path + "delphinus_zkwasm::runtime::host::ForeignPlugin"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| op |), + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ForeignOp", + "plugin" + |) + ] + |), + "delphinus_zkwasm::runtime::host::ForeignPlugin", + "ctx" + |) + ] + |)); + ("cb", + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| op |), + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ForeignOp", + "cb" + |) + ] + |))) + ]) + ] + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic_fmt", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "conflicting op index of foreign function" + |) + ] + |)) + ] + |) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + let β := internal_op_allocator_offset in + M.write (| + β, + BinOp.Panic.add (| Integer.Usize, M.read (| β |), Value.Integer 1 |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&mut") + [ + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::ForeignOp"; + Ty.path "std::hash::random::RandomState" + ] + ], + [], + "into_iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "internal_env" + |), + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv", + "functions" + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "std::collections::hash::map::IterMut") + [ + Ty.path "alloc::string::String"; + Ty.path + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::ForeignOp" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let name := M.copy (| γ1_0 |) in + let op := M.copy (| γ1_1 |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.read (| op |), + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::ForeignOp", + "index" + |), + Value.StructTuple + "core::option::Option::Some" + [ M.read (| internal_op_allocator_offset |) ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path + "delphinus_zkwasm::runtime::host::HostFunction"; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + lookup; + M.read (| internal_op_allocator_offset |); + Value.StructRecord + "delphinus_zkwasm::runtime::host::HostFunction" + [ + ("desc", + Value.StructRecord + "specs::host_function::HostFunctionDesc::Internal" + [ + ("name", + M.call_closure (| + M.get_trait_method (| + "alloc::borrow::ToOwned", + Ty.path "alloc::string::String", + [], + "to_owned", + [] + |), + [ M.read (| name |) ] + |)); + ("op_index_in_plugin", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| op |), + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::ForeignOp", + "index_within_plugin" + |) + |)); + ("plugin", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| op |), + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::ForeignOp", + "plugin" + |) + |)) + ]); + ("execution_env", + Value.StructRecord + "delphinus_zkwasm::runtime::host::HostFunctionExecutionEnv" + [ + ("ctx", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path + "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::runtime::host::ForeignPlugin" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path + "specs::host_function::HostPlugin"; + Ty.path + "delphinus_zkwasm::runtime::host::ForeignPlugin"; + Ty.path + "std::hash::random::RandomState" + ], + "get", + [ + Ty.path + "specs::host_function::HostPlugin" + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "internal_env" + |), + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv", + "plugins" + |); + M.SubPointer.get_struct_record_field (| + M.read (| op |), + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::ForeignOp", + "plugin" + |) + ] + |) + ] + |), + "delphinus_zkwasm::runtime::host::ForeignPlugin", + "ctx" + |) + ] + |)); + ("cb", + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.dyn + [ + ("existential predicate with variables", + []); + ("existential predicate with variables", + []) + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| op |), + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::ForeignOp", + "cb" + |) + ] + |))) + ]) + ] + ] + |) + |) in + let _ := + let β := internal_op_allocator_offset in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "cached_lookup" + |), + Value.StructTuple "core::option::Option::Some" [ M.read (| lookup |) ] + |) in + let finalized := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::cell::RefCell") [ Ty.path "bool" ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply (Ty.path "core::cell::RefCell") [ Ty.path "bool" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "finalized" + |) + ] + |) + ] + |) + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply (Ty.path "core::cell::RefMut") [ Ty.path "bool" ], + [], + "deref_mut", + [] + |), + [ finalized ] + |), + Value.Bool true + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_finalize : M.IsAssociatedFunction Self "finalize" finalize. + + (* + pub fn function_description_table(&self) -> HashMap { + assert!( + *self.finalized.borrow(), + "HostEnv has not been finalized. Please invoke finalized() first." + ); + + self.cached_lookup + .clone() + .unwrap() + .iter() + .map(|(idx, host_function)| ( *idx, host_function.desc.clone())) + .collect() + } + *) + Definition function_description_table (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply (Ty.path "core::cell::Ref") [ Ty.path "bool" ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ Ty.path "bool" ], + "borrow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ Ty.path "bool" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "finalized" + |) + ] + |) + ] + |) + |) + ] + |) + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic_fmt", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "HostEnv has not been finalized. Please invoke finalized() first." + |) + ] + |)) + ] + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path "usize"; + Ty.path "delphinus_zkwasm::runtime::host::HostFunction" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "usize" ]; + Ty.apply + (Ty.path "&") + [ Ty.path "delphinus_zkwasm::runtime::host::HostFunction" ] + ] + ] + ] + (Ty.tuple + [ Ty.path "usize"; Ty.path "specs::host_function::HostFunctionDesc" ]) + ], + [], + "collect", + [ + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "specs::host_function::HostFunctionDesc"; + Ty.path "std::hash::random::RandomState" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "std::collections::hash::map::Iter") + [ + Ty.path "usize"; + Ty.path "delphinus_zkwasm::runtime::host::HostFunction" + ], + [], + "map", + [ + Ty.tuple + [ Ty.path "usize"; Ty.path "specs::host_function::HostFunctionDesc" ]; + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "usize" ]; + Ty.apply + (Ty.path "&") + [ Ty.path "delphinus_zkwasm::runtime::host::HostFunction" + ] + ] + ] + ] + (Ty.tuple + [ Ty.path "usize"; Ty.path "specs::host_function::HostFunctionDesc" + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "delphinus_zkwasm::runtime::host::HostFunction"; + Ty.path "std::hash::random::RandomState" + ], + "iter", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "delphinus_zkwasm::runtime::host::HostFunction"; + Ty.path "std::hash::random::RandomState" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path + "delphinus_zkwasm::runtime::host::HostFunction"; + Ty.path "std::hash::random::RandomState" + ] + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "cached_lookup" + |) + ] + |) + ] + |) + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let idx := M.copy (| γ0_0 |) in + let host_function := M.copy (| γ0_1 |) in + Value.Tuple + [ + M.read (| M.read (| idx |) |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "specs::host_function::HostFunctionDesc", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| host_function |), + "delphinus_zkwasm::runtime::host::HostFunction", + "desc" + |) + ] + |) + ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_function_description_table : + M.IsAssociatedFunction Self "function_description_table" function_description_table. + + (* + pub fn display_time_profile(&self) { + debug!("Execution time(ms) of Foreign Functions:"); + self.time_profile.iter().for_each(|(func, ms)| { + debug!("{}:\t{}", func, ms); + }) + } + *) + Definition display_time_profile (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let _ := + let lvl := M.alloc (| Value.StructTuple "log::Level::Debug" [] |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ lvl; M.get_constant (| "log::STATIC_MAX_LEVEL" |) ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ + lvl; + M.alloc (| + M.call_closure (| + M.get_function (| "log::max_level", [] |), + [] + |) + |) + ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| "log::__private_api::log", [ Ty.tuple [] ] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "Execution time(ms) of Foreign Functions:" + |) + ] + |)) + ] + |); + M.read (| lvl |); + M.alloc (| + Value.Tuple + [ + M.read (| + Value.String "delphinus_zkwasm::runtime::host::host_env" + |); + M.read (| + Value.String "delphinus_zkwasm::runtime::host::host_env" + |); + M.read (| + Value.String "crates/zkwasm/src/runtime/host/host_env.rs" + |) + ] + |); + Value.Integer 138; + Value.Tuple [] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::Iter") + [ Ty.path "alloc::string::String"; Ty.path "u128" ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "alloc::string::String" ]; + Ty.apply (Ty.path "&") [ Ty.path "u128" ] + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "alloc::string::String"; + Ty.path "u128"; + Ty.path "alloc::alloc::Global" + ], + "iter", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "time_profile" + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let func := M.copy (| γ0_0 |) in + let ms := M.copy (| γ0_1 |) in + M.read (| + let _ := + let lvl := + M.alloc (| + Value.StructTuple "log::Level::Debug" [] + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ + lvl; + M.get_constant (| + "log::STATIC_MAX_LEVEL" + |) + ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialOrd", + Ty.path "log::Level", + [ Ty.path "log::LevelFilter" ], + "le", + [] + |), + [ + lvl; + M.alloc (| + M.call_closure (| + M.get_function (| + "log::max_level", + [] + |), + [] + |) + |) + ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| + "log::__private_api::log", + [ Ty.tuple [] ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "" |); + M.read (| Value.String ": " |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "alloc::string::String" + ] + ] + |), + [ func ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "u128" ] + ] + |), + [ ms ] + |) + ] + |)) + ] + |); + M.read (| lvl |); + M.alloc (| + Value.Tuple + [ + M.read (| + Value.String + "delphinus_zkwasm::runtime::host::host_env" + |); + M.read (| + Value.String + "delphinus_zkwasm::runtime::host::host_env" + |); + M.read (| + Value.String + "crates/zkwasm/src/runtime/host/host_env.rs" + |) + ] + |); + Value.Integer 140; + Value.Tuple [] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_display_time_profile : + M.IsAssociatedFunction Self "display_time_profile" display_time_profile. + End Impl_delphinus_zkwasm_runtime_host_host_env_HostEnv. + + Module Impl_wasmi_imports_ModuleImportResolver_for_delphinus_zkwasm_runtime_host_host_env_HostEnv. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::runtime::host::host_env::HostEnv". + + (* + fn resolve_func( + &self, + function_name: &str, + signature: &wasmi::Signature, + ) -> Result { + self.external_env + .resolve_func(function_name, signature) + .or_else(|_| self.internal_env.resolve_func(function_name, signature)) + } + *) + Definition resolve_func (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; function_name; signature ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let function_name := M.alloc (| function_name |) in + let signature := M.alloc (| signature |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "wasmi::func::FuncRef"; Ty.path "wasmi::Error" ], + "or_else", + [ + Ty.path "wasmi::Error"; + Ty.function + [ Ty.tuple [ Ty.path "wasmi::Error" ] ] + (Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "wasmi::func::FuncRef"; Ty.path "wasmi::Error" ]) + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "wasmi::imports::ModuleImportResolver", + Ty.path + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ExternalCircuitEnv", + [], + "resolve_func", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "external_env" + |); + M.read (| function_name |); + M.read (| signature |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "wasmi::imports::ModuleImportResolver", + Ty.path + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv", + [], + "resolve_func", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "internal_env" + |); + M.read (| function_name |); + M.read (| signature |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "wasmi::imports::ModuleImportResolver" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("resolve_func", InstanceField.Method resolve_func) ]. + End Impl_wasmi_imports_ModuleImportResolver_for_delphinus_zkwasm_runtime_host_host_env_HostEnv. + + (* StructRecord + { + name := "ExecEnv"; + ty_params := []; + fields := + [ + ("host_env", Ty.path "delphinus_zkwasm::runtime::host::host_env::HostEnv"); + ("observer", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ Ty.path "delphinus_zkwasm::runtime::monitor::observer::Observer" ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_wasmi_host_Externals_for_delphinus_zkwasm_runtime_host_host_env_ExecEnv. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::runtime::host::host_env::ExecEnv". + + (* + fn invoke_index( + &mut self, + index: usize, + args: RuntimeArgs, + ) -> Result, Trap> { + match self + .host_env + .cached_lookup + .as_ref() + .unwrap() + .get(&index) + .clone() + { + Some(HostFunction { + desc: _desc, + execution_env: HostFunctionExecutionEnv { ctx, cb }, + }) => { + let mut ctx = ( *ctx).borrow_mut(); + let ctx = ctx.as_mut(); + + #[cfg(feature = "profile")] + let start = Instant::now(); + + let r = cb(&self.observer.borrow(), ctx, args); + + #[cfg(feature = "profile")] + let duration = start.elapsed(); + + #[cfg(feature = "profile")] + self.host_env + .time_profile + .entry(_desc.name().to_string()) + .and_modify(|d| *d += duration.as_millis()) + .or_insert(duration.as_millis()); + + Ok(r) + } + None => unreachable!(), + } + } + *) + Definition invoke_index (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; index; args ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let index := M.alloc (| index |) in + let args := M.alloc (| args |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ Ty.path "delphinus_zkwasm::runtime::host::HostFunction" ] + ], + [], + "clone", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "delphinus_zkwasm::runtime::host::HostFunction"; + Ty.path "std::hash::random::RandomState" + ], + "get", + [ Ty.path "usize" ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path + "delphinus_zkwasm::runtime::host::HostFunction"; + Ty.path "std::hash::random::RandomState" + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path + "delphinus_zkwasm::runtime::host::HostFunction"; + Ty.path "std::hash::random::RandomState" + ] + ], + "as_ref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::host_env::ExecEnv", + "host_env" + |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "cached_lookup" + |) + ] + |) + ] + |); + index + ] + |) + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "delphinus_zkwasm::runtime::host::HostFunction", + "desc" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "delphinus_zkwasm::runtime::host::HostFunction", + "execution_env" + |) in + let _desc := M.alloc (| γ2_0 |) in + let γ3_0 := + M.SubPointer.get_struct_record_field (| + γ2_1, + "delphinus_zkwasm::runtime::host::HostFunctionExecutionEnv", + "ctx" + |) in + let γ3_1 := + M.SubPointer.get_struct_record_field (| + γ2_1, + "delphinus_zkwasm::runtime::host::HostFunctionExecutionEnv", + "cb" + |) in + let ctx := M.alloc (| γ3_0 |) in + let cb := M.alloc (| γ3_1 |) in + let ctx := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| ctx |) ] + |) + ] + |) + |) in + let ctx := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::AsMut", + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.dyn + [ ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", []) + ] + ], + "as_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "core::cell::RefMut") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref_mut", + [] + |), + [ ctx ] + |) + ] + |) + |) in + let r := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ], + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ]; + Ty.apply + (Ty.path "&mut") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ] + ]; + Ty.path "wasmi::host::RuntimeArgs" + ] + ], + "call", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| cb |) ] + |); + Value.Tuple + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "core::cell::Ref") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ], + "borrow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::host_env::ExecEnv", + "observer" + |) + ] + |) + ] + |) + |) + ] + |); + (* Unsize *) M.pointer_coercion (M.read (| ctx |)); + M.read (| args |) + ] + ] + |) + |) in + M.alloc (| + Value.StructTuple "core::result::Result::Ok" [ M.read (| r |) ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "internal error: entered unreachable code" |) + ] + |) + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "wasmi::host::Externals" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("invoke_index", InstanceField.Method invoke_index) ]. + End Impl_wasmi_host_Externals_for_delphinus_zkwasm_runtime_host_host_env_ExecEnv. + End host_env. + End host. +End runtime. diff --git a/CoqOfRust/zkWasm/runtime/host/internal_circuit_plugin.v b/CoqOfRust/zkWasm/runtime/host/internal_circuit_plugin.v new file mode 100644 index 000000000..9d4525a16 --- /dev/null +++ b/CoqOfRust/zkWasm/runtime/host/internal_circuit_plugin.v @@ -0,0 +1,790 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module runtime. + Module host. + Module internal_circuit_plugin. + (* StructRecord + { + name := "ForeignOp"; + ty_params := []; + fields := + [ + ("index", Ty.apply (Ty.path "core::option::Option") [ Ty.path "usize" ]); + ("index_within_plugin", Ty.path "usize"); + ("sig", Ty.path "specs::host_function::Signature"); + ("plugin", Ty.path "specs::host_function::HostPlugin"); + ("cb", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + (* StructRecord + { + name := "InternalCircuitEnv"; + ty_params := []; + fields := + [ + ("plugins", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "specs::host_function::HostPlugin"; + Ty.path "delphinus_zkwasm::runtime::host::ForeignPlugin"; + Ty.path "std::hash::random::RandomState" + ]); + ("functions", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "delphinus_zkwasm::runtime::host::internal_circuit_plugin::ForeignOp"; + Ty.path "std::hash::random::RandomState" + ]); + ("finalized", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply (Ty.path "core::cell::RefCell") [ Ty.path "bool" ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_delphinus_zkwasm_runtime_host_internal_circuit_plugin_InternalCircuitEnv. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv". + + (* + pub(super) fn new(finalized: Rc>) -> Self { + Self { + plugins: HashMap::new(), + functions: HashMap::new(), + finalized, + } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ finalized ] => + ltac:(M.monadic + (let finalized := M.alloc (| finalized |) in + Value.StructRecord + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv" + [ + ("plugins", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "specs::host_function::HostPlugin"; + Ty.path "delphinus_zkwasm::runtime::host::ForeignPlugin"; + Ty.path "std::hash::random::RandomState" + ], + "new", + [] + |), + [] + |)); + ("functions", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::ForeignOp"; + Ty.path "std::hash::random::RandomState" + ], + "new", + [] + |), + [] + |)); + ("finalized", M.read (| finalized |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + + (* + pub(crate) fn get_context_of_plugin( + &self, + plugin: HostPlugin, + ) -> Rc>> { + self.plugins.get(&plugin).unwrap().ctx.clone() + } + *) + Definition get_context_of_plugin (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; plugin ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let plugin := M.alloc (| plugin |) in + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ Ty.path "delphinus_zkwasm::runtime::host::ForeignPlugin" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "specs::host_function::HostPlugin"; + Ty.path "delphinus_zkwasm::runtime::host::ForeignPlugin"; + Ty.path "std::hash::random::RandomState" + ], + "get", + [ Ty.path "specs::host_function::HostPlugin" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv", + "plugins" + |); + plugin + ] + |) + ] + |), + "delphinus_zkwasm::runtime::host::ForeignPlugin", + "ctx" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_get_context_of_plugin : + M.IsAssociatedFunction Self "get_context_of_plugin" get_context_of_plugin. + + (* + pub fn register_plugin( + &mut self, + name: &str, + plugin: HostPlugin, + context: Box, + ) { + let _ = self.plugins.insert( + plugin, + ForeignPlugin { + name: name.to_string(), + ctx: Rc::new(RefCell::new(context)), + }, + ); + } + *) + Definition register_plugin (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; name; plugin; context ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let name := M.alloc (| name |) in + let plugin := M.alloc (| plugin |) in + let context := M.alloc (| context |) in + M.read (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "specs::host_function::HostPlugin"; + Ty.path "delphinus_zkwasm::runtime::host::ForeignPlugin"; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv", + "plugins" + |); + M.read (| plugin |); + Value.StructRecord + "delphinus_zkwasm::runtime::host::ForeignPlugin" + [ + ("name", + M.call_closure (| + M.get_trait_method (| + "alloc::string::ToString", + Ty.path "str", + [], + "to_string", + [] + |), + [ M.read (| name |) ] + |)); + ("ctx", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "new", + [] + |), + [ (* Unsize *) M.pointer_coercion (M.read (| context |)) ] + |)) + ] + |)) + ] + ] + |) + |), + [ fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_register_plugin : + M.IsAssociatedFunction Self "register_plugin" register_plugin. + + (* + pub fn register_function( + &mut self, + function_name: &str, + sig: Signature, + plugin: HostPlugin, + index_within_plugin: usize, + cb: Rc Option>, + ) { + assert!(!*self.finalized.borrow()); + + self.functions.insert( + function_name.to_owned(), + ForeignOp { + index: None, + index_within_plugin, + sig, + plugin, + cb, + }, + ); + } + *) + Definition register_function (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; function_name; sig; plugin; index_within_plugin; cb ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let function_name := M.alloc (| function_name |) in + let sig := M.alloc (| sig |) in + let plugin := M.alloc (| plugin |) in + let index_within_plugin := M.alloc (| index_within_plugin |) in + let cb := M.alloc (| cb |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (UnOp.Pure.not + (M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply (Ty.path "core::cell::Ref") [ Ty.path "bool" ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ Ty.path "bool" ], + "borrow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ Ty.path "bool" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv", + "finalized" + |) + ] + |) + ] + |) + |) + ] + |) + |))) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "assertion failed: !*self.finalized.borrow()" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::ForeignOp"; + Ty.path "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv", + "functions" + |); + M.call_closure (| + M.get_trait_method (| + "alloc::borrow::ToOwned", + Ty.path "str", + [], + "to_owned", + [] + |), + [ M.read (| function_name |) ] + |); + Value.StructRecord + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::ForeignOp" + [ + ("index", Value.StructTuple "core::option::Option::None" []); + ("index_within_plugin", M.read (| index_within_plugin |)); + ("sig", M.read (| sig |)); + ("plugin", M.read (| plugin |)); + ("cb", (* Unsize *) M.pointer_coercion (M.read (| cb |))) + ] + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_register_function : + M.IsAssociatedFunction Self "register_function" register_function. + End Impl_delphinus_zkwasm_runtime_host_internal_circuit_plugin_InternalCircuitEnv. + + Module Impl_wasmi_imports_ModuleImportResolver_for_delphinus_zkwasm_runtime_host_internal_circuit_plugin_InternalCircuitEnv. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv". + + (* + fn resolve_func( + &self, + function_name: &str, + signature: &wasmi::Signature, + ) -> Result { + if let Some(ForeignOp { index, sig, .. }) = self.functions.get(function_name) { + if *sig == signature.clone().into() { + Ok(FuncInstance::alloc_host( + signature.clone(), + index.expect("Unsolved host function index."), + )) + } else { + Err(wasmi::Error::Instantiation(format!("Signature not match",))) + } + } else { + Err(wasmi::Error::Instantiation(format!( + "Export {} not found", + function_name + ))) + } + } + *) + Definition resolve_func (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; function_name; signature ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let function_name := M.alloc (| function_name |) in + let signature := M.alloc (| signature |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::ForeignOp"; + Ty.path "std::hash::random::RandomState" + ], + "get", + [ Ty.path "str" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv", + "functions" + |); + M.read (| function_name |) + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ0_0 := M.read (| γ0_0 |) in + let γ2_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::ForeignOp", + "index" + |) in + let γ2_1 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::ForeignOp", + "sig" + |) in + let index := M.alloc (| γ2_0 |) in + let sig := M.alloc (| γ2_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::host_function::Signature", + [ Ty.path "specs::host_function::Signature" ], + "eq", + [] + |), + [ + M.read (| sig |); + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "wasmi::types::Signature", + [ Ty.path "specs::host_function::Signature" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "wasmi::types::Signature", + [], + "clone", + [] + |), + [ M.read (| signature |) ] + |) + ] + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::func::FuncInstance", + "alloc_host", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "wasmi::types::Signature", + [], + "clone", + [] + |), + [ M.read (| signature |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "usize" ], + "expect", + [] + |), + [ + M.read (| M.read (| index |) |); + M.read (| + Value.String "Unsolved host function index." + |) + ] + |) + ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "wasmi::Error::Instantiation" + [ + M.read (| + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String "Signature not match" + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) + ] + ] + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "wasmi::Error::Instantiation" + [ + M.read (| + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "Export " |); + M.read (| Value.String " not found" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ] + |), + [ function_name ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + |) + ] + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "wasmi::imports::ModuleImportResolver" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("resolve_func", InstanceField.Method resolve_func) ]. + End Impl_wasmi_imports_ModuleImportResolver_for_delphinus_zkwasm_runtime_host_internal_circuit_plugin_InternalCircuitEnv. + End internal_circuit_plugin. + End host. +End runtime. diff --git a/CoqOfRust/zkWasm/runtime/host/mod.v b/CoqOfRust/zkWasm/runtime/host/mod.v new file mode 100644 index 000000000..fd3b672b3 --- /dev/null +++ b/CoqOfRust/zkWasm/runtime/host/mod.v @@ -0,0 +1,602 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module runtime. + Module host. + (* Trait *) + (* Empty module 'MatchForeignOpSignature' *) + + Module Impl_delphinus_zkwasm_runtime_host_MatchForeignOpSignature_for_specs_external_host_call_table_ExternalHostCallSignature. + Definition Self : Ty.t := + Ty.path "specs::external_host_call_table::ExternalHostCallSignature". + + (* + fn match_wasmi_signature(&self, signature: &Signature) -> bool { + match self { + ExternalHostCallSignature::Argument => { + signature.params().len() == 1 + && signature.params()[0] == wasmi::ValueType::I64 + && signature.return_type() == None + } + ExternalHostCallSignature::Return => { + signature.params().len() == 0 + && signature.return_type() == Some(wasmi::ValueType::I64) + } + } + } + *) + Definition match_wasmi_signature (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; signature ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let signature := M.alloc (| signature |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + LogicalOp.and (| + LogicalOp.and (| + BinOp.Pure.eq + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "wasmi_core::value::ValueType" ], + "len", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::types::Signature", + "params", + [] + |), + [ M.read (| signature |) ] + |) + ] + |)) + (Value.Integer 1), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "wasmi_core::value::ValueType", + [ Ty.path "wasmi_core::value::ValueType" ], + "eq", + [] + |), + [ + M.SubPointer.get_array_field (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::types::Signature", + "params", + [] + |), + [ M.read (| signature |) ] + |), + M.alloc (| Value.Integer 0 |) + |); + M.alloc (| + Value.StructTuple "wasmi_core::value::ValueType::I64" [] + |) + ] + |))) + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi_core::value::ValueType" ], + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi_core::value::ValueType" ] + ], + "eq", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::types::Signature", + "return_type", + [] + |), + [ M.read (| signature |) ] + |) + |); + M.alloc (| Value.StructTuple "core::option::Option::None" [] |) + ] + |))) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + LogicalOp.and (| + BinOp.Pure.eq + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "wasmi_core::value::ValueType" ], + "len", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::types::Signature", + "params", + [] + |), + [ M.read (| signature |) ] + |) + ] + |)) + (Value.Integer 0), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi_core::value::ValueType" ], + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi_core::value::ValueType" ] + ], + "eq", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::types::Signature", + "return_type", + [] + |), + [ M.read (| signature |) ] + |) + |); + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ Value.StructTuple "wasmi_core::value::ValueType::I64" [] ] + |) + ] + |))) + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "delphinus_zkwasm::runtime::host::MatchForeignOpSignature" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("match_wasmi_signature", InstanceField.Method match_wasmi_signature) ]. + End Impl_delphinus_zkwasm_runtime_host_MatchForeignOpSignature_for_specs_external_host_call_table_ExternalHostCallSignature. + + (* StructRecord + { + name := "ForeignStatics"; + ty_params := []; + fields := [ ("used_round", Ty.path "usize"); ("max_round", Ty.path "usize") ]; + } *) + + Module Impl_core_clone_Clone_for_delphinus_zkwasm_runtime_host_ForeignStatics. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::runtime::host::ForeignStatics". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::runtime::host::ForeignStatics" + [ + ("used_round", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "usize", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::ForeignStatics", + "used_round" + |) + ] + |)); + ("max_round", + M.call_closure (| + M.get_trait_method (| "core::clone::Clone", Ty.path "usize", [], "clone", [] |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::ForeignStatics", + "max_round" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_delphinus_zkwasm_runtime_host_ForeignStatics. + + Module Impl_core_fmt_Debug_for_delphinus_zkwasm_runtime_host_ForeignStatics. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::runtime::host::ForeignStatics". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "ForeignStatics" |); + M.read (| Value.String "used_round" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::ForeignStatics", + "used_round" + |)); + M.read (| Value.String "max_round" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::ForeignStatics", + "max_round" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_delphinus_zkwasm_runtime_host_ForeignStatics. + + (* Trait *) + Module ForeignContext. + Definition get_statics (Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructTuple "core::option::Option::None" [])) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_get_statics : + M.IsProvidedMethod + "delphinus_zkwasm::runtime::host::ForeignContext" + "get_statics" + get_statics. + Definition expose_public_inputs_and_outputs + (Self : Ty.t) + (τ : list Ty.t) + (α : list Value.t) + : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "internal error: entered unreachable code" |) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_expose_public_inputs_and_outputs : + M.IsProvidedMethod + "delphinus_zkwasm::runtime::host::ForeignContext" + "expose_public_inputs_and_outputs" + expose_public_inputs_and_outputs. + Definition expose_outputs (Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "internal error: entered unreachable code" |) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_expose_outputs : + M.IsProvidedMethod + "delphinus_zkwasm::runtime::host::ForeignContext" + "expose_outputs" + expose_outputs. + Definition expose_context_outputs (Self : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "internal error: entered unreachable code" |) ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom ProvidedMethod_expose_context_outputs : + M.IsProvidedMethod + "delphinus_zkwasm::runtime::host::ForeignContext" + "expose_context_outputs" + expose_context_outputs. + End ForeignContext. + + (* StructRecord + { + name := "ForeignPlugin"; + ty_params := []; + fields := + [ + ("name", Ty.path "alloc::string::String"); + ("ctx", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn [ ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + (* StructRecord + { + name := "HostFunctionExecutionEnv"; + ty_params := []; + fields := + [ + ("ctx", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn [ ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", []) ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ]); + ("cb", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_core_clone_Clone_for_delphinus_zkwasm_runtime_host_HostFunctionExecutionEnv. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::runtime::host::HostFunctionExecutionEnv". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::runtime::host::HostFunctionExecutionEnv" + [ + ("ctx", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::HostFunctionExecutionEnv", + "ctx" + |) + ] + |)); + ("cb", + (* Unsize *) + M.pointer_coercion + (M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::HostFunctionExecutionEnv", + "cb" + |) + ] + |))) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_delphinus_zkwasm_runtime_host_HostFunctionExecutionEnv. + + (* StructRecord + { + name := "HostFunction"; + ty_params := []; + fields := + [ + ("desc", Ty.path "specs::host_function::HostFunctionDesc"); + ("execution_env", Ty.path "delphinus_zkwasm::runtime::host::HostFunctionExecutionEnv") + ]; + } *) + + Module Impl_core_clone_Clone_for_delphinus_zkwasm_runtime_host_HostFunction. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::runtime::host::HostFunction". + + (* Clone *) + Definition clone (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "delphinus_zkwasm::runtime::host::HostFunction" + [ + ("desc", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "specs::host_function::HostFunctionDesc", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::HostFunction", + "desc" + |) + ] + |)); + ("execution_env", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "delphinus_zkwasm::runtime::host::HostFunctionExecutionEnv", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::host::HostFunction", + "execution_env" + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::clone::Clone" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("clone", InstanceField.Method clone) ]. + End Impl_core_clone_Clone_for_delphinus_zkwasm_runtime_host_HostFunction. + + (* Trait *) + (* Empty module 'HostEnvArg' *) + + (* Trait *) + (* Empty module 'HostEnvBuilder' *) + End host. +End runtime. diff --git a/CoqOfRust/zkWasm/runtime/mod.v b/CoqOfRust/zkWasm/runtime/mod.v new file mode 100644 index 000000000..2903d3b59 --- /dev/null +++ b/CoqOfRust/zkWasm/runtime/mod.v @@ -0,0 +1,7457 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module runtime. + (* StructRecord + { + name := "CompiledImage"; + ty_params := [ "I" ]; + fields := [ ("entry", Ty.path "alloc::string::String"); ("instance", I) ]; + } *) + + (* StructRecord + { + name := "ExecutionResult"; + ty_params := [ "R" ]; + fields := + [ + ("result", Ty.apply (Ty.path "core::option::Option") [ R ]); + ("public_inputs_and_outputs", + Ty.apply (Ty.path "alloc::vec::Vec") [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ]); + ("host_statics", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "alloc::string::String"; + Ty.path "delphinus_zkwasm::runtime::host::ForeignStatics"; + Ty.path "std::hash::random::RandomState" + ]); + ("guest_statics", Ty.path "usize"); + ("outputs", + Ty.apply (Ty.path "alloc::vec::Vec") [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ]); + ("context_outputs", Ty.path "delphinus_zkwasm::foreign::context::ContextOutput") + ]; + } *) + + Module Impl_delphinus_zkwasm_runtime_ExecutionResult_R. + Definition Self (R : Ty.t) : Ty.t := + Ty.apply (Ty.path "delphinus_zkwasm::runtime::ExecutionResult") [ R ]. + + (* + pub fn public_inputs_and_outputs(&self) -> Vec { + self.public_inputs_and_outputs + .iter() + .map(|v| F::from( *v)) + .collect() + } + *) + Definition public_inputs_and_outputs (R : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := + let Self : Ty.t := Self R in + match τ, α with + | [ F ], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.path "u64" ]; + Ty.function [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "u64" ] ] ] F + ], + [], + "collect", + [ Ty.apply (Ty.path "alloc::vec::Vec") [ F; Ty.path "alloc::alloc::Global" ] ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply (Ty.path "core::slice::iter::Iter") [ Ty.path "u64" ], + [], + "map", + [ F; Ty.function [ Ty.tuple [ Ty.apply (Ty.path "&") [ Ty.path "u64" ] ] ] F ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u64" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::ExecutionResult", + "public_inputs_and_outputs" + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let v := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + F, + [ Ty.path "u64" ], + "from", + [] + |), + [ M.read (| M.read (| v |) |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_public_inputs_and_outputs : + forall (R : Ty.t), + M.IsAssociatedFunction (Self R) "public_inputs_and_outputs" (public_inputs_and_outputs R). + End Impl_delphinus_zkwasm_runtime_ExecutionResult_R. + + Axiom WasmInterpreter : + (Ty.path "delphinus_zkwasm::runtime::WasmInterpreter") = + (Ty.path "delphinus_zkwasm::runtime::wasmi_interpreter::WasmiRuntime"). + + (* + pub fn memory_event_of_step(event: &EventTableEntry) -> Vec { + let eid = event.eid; + let sp_before_execution = event.sp; + + match &event.step_info { + StepInfo::Br { + drop, + keep, + keep_values, + .. + } => { + assert_eq!(keep.len(), keep_values.len()); + assert!(keep.len() <= 1); + + let mut sp = sp_before_execution + 1; + let mut ops = vec![]; + + { + for i in 0..keep.len() { + ops.push(MemoryTableEntry { + eid, + offset: sp, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: keep[i].into(), + is_mutable: true, + value: keep_values[i], + }); + + sp = sp + 1; + } + } + + sp += drop; + sp -= 1; + + { + for i in 0..keep.len() { + ops.push(MemoryTableEntry { + eid, + offset: sp, + ltype: LocationType::Stack, + atype: AccessType::Write, + vtype: keep[i].into(), + is_mutable: true, + value: keep_values[i], + }); + + sp = sp - 1; + } + } + + ops + } + StepInfo::BrIfEqz { + condition, + drop, + keep, + keep_values, + .. + } => { + assert_eq!(keep.len(), keep_values.len()); + assert!(keep.len() <= 1); + + let mut sp = sp_before_execution + 1; + + let mut ops = vec![MemoryTableEntry { + eid, + offset: sp, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: VarType::I32, + is_mutable: true, + value: *condition as u32 as u64, + }]; + + sp = sp + 1; + + if *condition != 0 { + return ops; + } + + { + for i in 0..keep.len() { + ops.push(MemoryTableEntry { + eid, + offset: sp, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: keep[i].into(), + is_mutable: true, + value: keep_values[i], + }); + + sp = sp + 1; + } + } + + sp += drop; + sp -= 1; + + { + for i in 0..keep.len() { + ops.push(MemoryTableEntry { + eid, + offset: sp, + ltype: LocationType::Stack, + atype: AccessType::Write, + vtype: keep[i].into(), + is_mutable: true, + value: keep_values[i], + }); + + sp = sp - 1; + } + } + + ops + } + StepInfo::BrIfNez { + condition, + drop, + keep, + keep_values, + .. + } => { + assert_eq!(keep.len(), keep_values.len()); + assert!(keep.len() <= 1); + + let mut sp = sp_before_execution + 1; + + let mut ops = vec![MemoryTableEntry { + eid, + offset: sp, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: VarType::I32, + is_mutable: true, + value: *condition as u32 as u64, + }]; + + sp = sp + 1; + + if *condition == 0 { + return ops; + } + + { + for i in 0..keep.len() { + ops.push(MemoryTableEntry { + eid, + offset: sp, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: keep[i].into(), + is_mutable: true, + value: keep_values[i], + }); + + sp = sp + 1; + } + } + + sp += drop; + sp -= 1; + + { + for i in 0..keep.len() { + ops.push(MemoryTableEntry { + eid, + offset: sp, + ltype: LocationType::Stack, + atype: AccessType::Write, + vtype: keep[i].into(), + is_mutable: true, + value: keep_values[i], + }); + + sp = sp - 1; + } + } + + ops + } + StepInfo::BrTable { + index, + drop, + keep, + keep_values, + .. + } => { + assert_eq!(keep.len(), keep_values.len()); + assert!(keep.len() <= 1); + + let mut sp = sp_before_execution + 1; + + let mut ops = vec![MemoryTableEntry { + eid, + offset: sp, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: VarType::I32, + is_mutable: true, + value: *index as u32 as u64, + }]; + + sp = sp + 1; + + { + for i in 0..keep.len() { + ops.push(MemoryTableEntry { + eid, + offset: sp, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: keep[i].into(), + is_mutable: true, + value: keep_values[i], + }); + + sp = sp + 1; + } + } + + sp += drop; + sp -= 1; + + { + for i in 0..keep.len() { + ops.push(MemoryTableEntry { + eid, + offset: sp, + ltype: LocationType::Stack, + atype: AccessType::Write, + vtype: keep[i].into(), + is_mutable: true, + value: keep_values[i], + }); + + sp = sp - 1; + } + } + + ops + } + StepInfo::Return { + drop, + keep, + keep_values, + } => { + assert_eq!(keep.len(), keep_values.len()); + assert!(keep.len() <= 1); + + let mut sp = sp_before_execution + 1; + let mut ops = vec![]; + + { + for i in 0..keep.len() { + ops.push(MemoryTableEntry { + eid, + offset: sp, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: keep[i].into(), + is_mutable: true, + value: keep_values[i], + }); + + sp = sp + 1; + } + } + + sp += drop; + sp -= 1; + + { + for i in 0..keep.len() { + ops.push(MemoryTableEntry { + eid, + offset: sp, + ltype: LocationType::Stack, + atype: AccessType::Write, + vtype: keep[i].into(), + is_mutable: true, + value: keep_values[i], + }); + + sp = sp - 1; + } + } + + ops + } + StepInfo::Drop { .. } => vec![], + StepInfo::Select { + val1, + val2, + cond, + result, + vtype, + } => { + let mut sp = sp_before_execution + 1; + let mut ops = vec![]; + + ops.push(MemoryTableEntry { + eid, + offset: sp, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: VarType::I32, + is_mutable: true, + value: *cond, + }); + sp = sp + 1; + + ops.push(MemoryTableEntry { + eid, + offset: sp, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: *vtype, + is_mutable: true, + value: *val2, + }); + sp = sp + 1; + + ops.push(MemoryTableEntry { + eid, + offset: sp, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: *vtype, + is_mutable: true, + value: *val1, + }); + + ops.push(MemoryTableEntry { + eid, + offset: sp, + ltype: LocationType::Stack, + atype: AccessType::Write, + vtype: *vtype, + is_mutable: true, + value: *result, + }); + + ops + } + StepInfo::Call { index: _ } => { + vec![] + } + StepInfo::CallIndirect { offset, .. } => { + let stack_read = MemoryTableEntry { + eid, + offset: sp_before_execution + 1, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: VarType::I32, + is_mutable: true, + value: *offset as u64, + }; + + vec![stack_read] + } + StepInfo::CallHost { + args, + ret_val, + signature, + .. + } => { + let mut mops = vec![]; + let mut sp = sp_before_execution; + + for (i, (ty, val)) in signature.params.iter().zip(args.iter()).enumerate() { + mops.push(MemoryTableEntry { + eid, + offset: sp_before_execution + args.len() as u32 - i as u32, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: ( *ty).into(), + is_mutable: true, + value: *val, + }); + } + + sp = sp + args.len() as u32; + + if let Some(ty) = signature.return_type { + mops.push(MemoryTableEntry { + eid, + offset: sp, + ltype: LocationType::Stack, + atype: AccessType::Write, + vtype: ty.into(), + is_mutable: true, + value: ret_val.unwrap(), + }); + } + + mops + } + StepInfo::ExternalHostCall { value, sig, .. } => match sig { + ExternalHostCallSignature::Argument => { + let stack_read = MemoryTableEntry { + eid, + offset: sp_before_execution + 1, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: VarType::I64, + is_mutable: true, + value: value.unwrap(), + }; + + vec![stack_read] + } + ExternalHostCallSignature::Return => { + let stack_write = MemoryTableEntry { + eid, + offset: sp_before_execution, + ltype: LocationType::Stack, + atype: AccessType::Write, + vtype: VarType::I64, + is_mutable: true, + value: value.unwrap(), + }; + + vec![stack_write] + } + }, + + StepInfo::GetLocal { + vtype, + depth, + value, + } => { + let read = MemoryTableEntry { + eid, + offset: sp_before_execution + depth, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: *vtype, + is_mutable: true, + value: *value, + }; + + let write = MemoryTableEntry { + eid, + offset: sp_before_execution, + ltype: LocationType::Stack, + atype: AccessType::Write, + vtype: *vtype, + is_mutable: true, + value: *value, + }; + vec![read, write] + } + StepInfo::SetLocal { + vtype, + depth, + value, + } => { + let mut sp = sp_before_execution; + + let read = MemoryTableEntry { + eid, + offset: sp + 1, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: *vtype, + is_mutable: true, + value: *value, + }; + + sp += 1; + + let write = MemoryTableEntry { + eid, + offset: sp + depth, + ltype: LocationType::Stack, + atype: AccessType::Write, + vtype: *vtype, + is_mutable: true, + value: *value, + }; + + vec![read, write] + } + StepInfo::TeeLocal { + vtype, + depth, + value, + } => { + let read = MemoryTableEntry { + eid, + offset: sp_before_execution + 1, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: *vtype, + is_mutable: true, + value: *value, + }; + + let write = MemoryTableEntry { + eid, + offset: sp_before_execution + depth, + ltype: LocationType::Stack, + atype: AccessType::Write, + vtype: *vtype, + is_mutable: true, + value: *value, + }; + + vec![read, write] + } + + StepInfo::GetGlobal { + idx, + vtype, + is_mutable, + value, + .. + } => { + let global_get = MemoryTableEntry { + eid, + offset: *idx, + ltype: LocationType::Global, + atype: AccessType::Read, + vtype: *vtype, + is_mutable: *is_mutable, + value: *value, + }; + + let stack_write = MemoryTableEntry { + eid, + offset: sp_before_execution, + ltype: LocationType::Stack, + atype: AccessType::Write, + vtype: *vtype, + is_mutable: true, + value: *value, + }; + + vec![global_get, stack_write] + } + StepInfo::SetGlobal { + idx, + vtype, + is_mutable, + value, + } => { + let stack_read = MemoryTableEntry { + eid, + offset: sp_before_execution + 1, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: *vtype, + is_mutable: true, + value: *value, + }; + + let global_set = MemoryTableEntry { + eid, + offset: *idx, + ltype: LocationType::Global, + atype: AccessType::Write, + vtype: *vtype, + is_mutable: *is_mutable, + value: *value, + }; + + vec![stack_read, global_set] + } + + StepInfo::Load { + vtype, + load_size, + raw_address, + effective_address, + value, + block_value1, + block_value2, + .. + } => { + let load_address_from_stack = MemoryTableEntry { + eid, + offset: sp_before_execution + 1, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: VarType::I32, + is_mutable: true, + value: *raw_address as u64, + }; + + let load_value1 = MemoryTableEntry { + eid, + offset: ( *effective_address) / 8, + ltype: LocationType::Heap, + atype: AccessType::Read, + // Load u64 from address which align with 8 + vtype: VarType::I64, + is_mutable: true, + // The value will be used to lookup within imtable, hence block_value is given here + value: *block_value1, + }; + + let load_value2 = if *effective_address % 8 + load_size.byte_size() as u32 > 8 { + Some(MemoryTableEntry { + eid, + offset: effective_address / 8 + 1, + ltype: LocationType::Heap, + atype: AccessType::Read, + // Load u64 from address which align with 8 + vtype: VarType::I64, + is_mutable: true, + // The value will be used to lookup within imtable, hence block_value is given here + value: *block_value2, + }) + } else { + None + }; + + let push_value = MemoryTableEntry { + eid, + offset: sp_before_execution + 1, + ltype: LocationType::Stack, + atype: AccessType::Write, + vtype: *vtype, + is_mutable: true, + value: *value, + }; + + vec![ + vec![load_address_from_stack, load_value1], + load_value2.map_or(vec![], |v| vec![v]), + vec![push_value], + ] + .concat() + } + StepInfo::Store { + vtype, + store_size, + raw_address, + effective_address, + value, + pre_block_value1, + updated_block_value1, + pre_block_value2, + updated_block_value2, + .. + } => { + let load_value_from_stack = MemoryTableEntry { + eid, + offset: sp_before_execution + 1, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: *vtype, + is_mutable: true, + value: *value, + }; + + let load_address_from_stack = MemoryTableEntry { + eid, + offset: sp_before_execution + 2, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: VarType::I32, + is_mutable: true, + value: *raw_address as u64, + }; + + let load_value1 = MemoryTableEntry { + eid, + offset: effective_address / 8, + ltype: LocationType::Heap, + atype: AccessType::Read, + // Load u64 from address which align with 8 + vtype: VarType::I64, + is_mutable: true, + // The value will be used to lookup within imtable, hence block_value is given here + value: *pre_block_value1, + }; + + let write_value1 = MemoryTableEntry { + eid, + offset: effective_address / 8, + ltype: LocationType::Heap, + atype: AccessType::Write, + // Load u64 from address which align with 8 + vtype: VarType::I64, + is_mutable: true, + // The value will be used to lookup within imtable, hence block_value is given here + value: *updated_block_value1, + }; + + if *effective_address % 8 + store_size.byte_size() as u32 > 8 { + let load_value2 = MemoryTableEntry { + eid, + offset: effective_address / 8 + 1, + ltype: LocationType::Heap, + atype: AccessType::Read, + // Load u64 from address which align with 8 + vtype: VarType::I64, + is_mutable: true, + // The value will be used to lookup within imtable, hence block_value is given here + value: *pre_block_value2, + }; + + let write_value2 = MemoryTableEntry { + eid, + offset: effective_address / 8 + 1, + ltype: LocationType::Heap, + atype: AccessType::Write, + // Load u64 from address which align with 8 + vtype: VarType::I64, + is_mutable: true, + // The value will be used to lookup within imtable, hence block_value is given here + value: *updated_block_value2, + }; + vec![ + load_value_from_stack, + load_address_from_stack, + load_value1, + write_value1, + load_value2, + write_value2, + ] + } else { + vec![ + load_value_from_stack, + load_address_from_stack, + load_value1, + write_value1, + ] + } + } + + StepInfo::MemorySize => mem_op_from_stack_only_step( + sp_before_execution, + eid, + VarType::I32, + VarType::I32, + &[], + &[event.allocated_memory_pages as u32 as u64], + ), + StepInfo::MemoryGrow { grow_size, result } => mem_op_from_stack_only_step( + sp_before_execution, + eid, + VarType::I32, + VarType::I32, + &[*grow_size as u32 as u64], + &[*result as u32 as u64], + ), + + StepInfo::I32Const { value } => mem_op_from_stack_only_step( + sp_before_execution, + eid, + VarType::I32, + VarType::I32, + &[], + &[*value as u32 as u64], + ), + StepInfo::I32BinOp { + left, right, value, .. + } + | StepInfo::I32BinShiftOp { + left, right, value, .. + } + | StepInfo::I32BinBitOp { + left, right, value, .. + } => mem_op_from_stack_only_step( + sp_before_execution, + eid, + VarType::I32, + VarType::I32, + &[*right as u32 as u64, *left as u32 as u64], + &[*value as u32 as u64], + ), + StepInfo::I32Comp { + left, right, value, .. + } => mem_op_from_stack_only_step( + sp_before_execution, + eid, + VarType::I32, + VarType::I32, + &[*right as u32 as u64, *left as u32 as u64], + &[*value as u32 as u64], + ), + + StepInfo::I64BinOp { + left, right, value, .. + } + | StepInfo::I64BinShiftOp { + left, right, value, .. + } + | StepInfo::I64BinBitOp { + left, right, value, .. + } => mem_op_from_stack_only_step( + sp_before_execution, + eid, + VarType::I64, + VarType::I64, + &[*right as u64, *left as u64], + &[*value as u64], + ), + + StepInfo::I64Const { value } => mem_op_from_stack_only_step( + sp_before_execution, + eid, + VarType::I64, + VarType::I64, + &[], + &[*value as u64], + ), + StepInfo::I64Comp { + left, right, value, .. + } => mem_op_from_stack_only_step( + sp_before_execution, + eid, + VarType::I64, + VarType::I32, + &[*right as u64, *left as u64], + &[*value as u32 as u64], + ), + StepInfo::UnaryOp { + vtype, + operand, + result, + .. + } => mem_op_from_stack_only_step( + sp_before_execution, + eid, + *vtype, + *vtype, + &[*operand], + &[*result], + ), + + StepInfo::Test { + vtype, + value, + result, + } => mem_op_from_stack_only_step( + sp_before_execution, + eid, + *vtype, + VarType::I32, + &[*value], + &[*result as u32 as u64], + ), + + StepInfo::I32WrapI64 { value, result } => mem_op_from_stack_only_step( + sp_before_execution, + eid, + VarType::I64, + VarType::I32, + &[*value as u64], + &[*result as u32 as u64], + ), + StepInfo::I64ExtendI32 { value, result, .. } => mem_op_from_stack_only_step( + sp_before_execution, + eid, + VarType::I32, + VarType::I64, + &[*value as u32 as u64], + &[*result as u64], + ), + StepInfo::I32SignExtendI8 { value, result } + | StepInfo::I32SignExtendI16 { value, result } => mem_op_from_stack_only_step( + sp_before_execution, + eid, + VarType::I32, + VarType::I32, + &[*value as u32 as u64], + &[*result as u32 as u64], + ), + StepInfo::I64SignExtendI8 { value, result } + | StepInfo::I64SignExtendI16 { value, result } + | StepInfo::I64SignExtendI32 { value, result } => mem_op_from_stack_only_step( + sp_before_execution, + eid, + VarType::I64, + VarType::I64, + &[*value as u64], + &[*result as u64], + ), + } + } + *) + Definition memory_event_of_step (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ event ] => + ltac:(M.monadic + (let event := M.alloc (| event |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| event |), + "specs::etable::EventTableEntry", + "eid" + |) + |) in + let sp_before_execution := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| event |), + "specs::etable::EventTableEntry", + "sp" + |) + |) in + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| event |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Br", + "drop" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Br", + "keep" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Br", + "keep_values" + |) in + let drop := M.alloc (| γ1_0 |) in + let keep := M.alloc (| γ1_1 |) in + let keep_values := M.alloc (| γ1_2 |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |) + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ M.read (| keep_values |) ] + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.le + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + (Value.Integer 1)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "assertion failed: keep.len() <= 1" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let sp := + M.alloc (| + BinOp.Panic.add (| + Integer.U32, + M.read (| sp_before_execution |), + Value.Integer 1 + |) + |) in + let ops := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + ops; + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp |)); + ("ltype", + Value.StructTuple + "specs::mtable::LocationType::Stack" + []); + ("atype", + Value.StructTuple + "specs::mtable::AccessType::Read" + []); + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::types::ValueType", + [ Ty.path "specs::mtable::VarType" + ], + "into", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + M.read (| i |) + ] + |) + |) + ] + |)); + ("is_mutable", Value.Bool true); + ("value", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + M.read (| i |) + ] + |) + |)) + ] + ] + |) + |) in + let _ := + M.write (| + sp, + BinOp.Panic.add (| + Integer.U32, + M.read (| sp |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::AddAssign", + Ty.path "u32", + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ], + "add_assign", + [] + |), + [ sp; M.read (| drop |) ] + |) + |) in + let _ := + let β := sp in + M.write (| + β, + BinOp.Panic.sub (| Integer.U32, M.read (| β |), Value.Integer 1 |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + ops; + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp |)); + ("ltype", + Value.StructTuple + "specs::mtable::LocationType::Stack" + []); + ("atype", + Value.StructTuple + "specs::mtable::AccessType::Write" + []); + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::types::ValueType", + [ Ty.path "specs::mtable::VarType" + ], + "into", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + M.read (| i |) + ] + |) + |) + ] + |)); + ("is_mutable", Value.Bool true); + ("value", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + M.read (| i |) + ] + |) + |)) + ] + ] + |) + |) in + let _ := + M.write (| + sp, + BinOp.Panic.sub (| + Integer.U32, + M.read (| sp |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + ops)); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfEqz", + "condition" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfEqz", + "drop" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfEqz", + "keep" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfEqz", + "keep_values" + |) in + let condition := M.alloc (| γ1_0 |) in + let drop := M.alloc (| γ1_1 |) in + let keep := M.alloc (| γ1_2 |) in + let keep_values := M.alloc (| γ1_3 |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |) + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ M.read (| keep_values |) ] + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.le + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + (Value.Integer 1)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "assertion failed: keep.len() <= 1" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let sp := + M.alloc (| + BinOp.Panic.add (| + Integer.U32, + M.read (| sp_before_execution |), + Value.Integer 1 + |) + |) in + let ops := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::mtable::MemoryTableEntry" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::mtable::MemoryTableEntry" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp |)); + ("ltype", + Value.StructTuple + "specs::mtable::LocationType::Stack" + []); + ("atype", + Value.StructTuple + "specs::mtable::AccessType::Read" + []); + ("vtype", + Value.StructTuple + "specs::mtable::VarType::I32" + []); + ("is_mutable", Value.Bool true); + ("value", + M.rust_cast + (M.rust_cast + (M.read (| M.read (| condition |) |)))) + ] + ] + |) + ] + |) + |)) + ] + |) + |) in + let _ := + M.write (| + sp, + BinOp.Panic.add (| Integer.U32, M.read (| sp |), Value.Integer 1 |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.read (| M.read (| condition |) |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| M.read (| M.return_ (| M.read (| ops |) |) |) |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + ops; + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp |)); + ("ltype", + Value.StructTuple + "specs::mtable::LocationType::Stack" + []); + ("atype", + Value.StructTuple + "specs::mtable::AccessType::Read" + []); + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::types::ValueType", + [ Ty.path "specs::mtable::VarType" + ], + "into", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + M.read (| i |) + ] + |) + |) + ] + |)); + ("is_mutable", Value.Bool true); + ("value", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + M.read (| i |) + ] + |) + |)) + ] + ] + |) + |) in + let _ := + M.write (| + sp, + BinOp.Panic.add (| + Integer.U32, + M.read (| sp |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::AddAssign", + Ty.path "u32", + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ], + "add_assign", + [] + |), + [ sp; M.read (| drop |) ] + |) + |) in + let _ := + let β := sp in + M.write (| + β, + BinOp.Panic.sub (| Integer.U32, M.read (| β |), Value.Integer 1 |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + ops; + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp |)); + ("ltype", + Value.StructTuple + "specs::mtable::LocationType::Stack" + []); + ("atype", + Value.StructTuple + "specs::mtable::AccessType::Write" + []); + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::types::ValueType", + [ Ty.path "specs::mtable::VarType" + ], + "into", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + M.read (| i |) + ] + |) + |) + ] + |)); + ("is_mutable", Value.Bool true); + ("value", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + M.read (| i |) + ] + |) + |)) + ] + ] + |) + |) in + let _ := + M.write (| + sp, + BinOp.Panic.sub (| + Integer.U32, + M.read (| sp |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + ops)); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfNez", + "condition" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfNez", + "drop" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfNez", + "keep" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrIfNez", + "keep_values" + |) in + let condition := M.alloc (| γ1_0 |) in + let drop := M.alloc (| γ1_1 |) in + let keep := M.alloc (| γ1_2 |) in + let keep_values := M.alloc (| γ1_3 |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |) + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ M.read (| keep_values |) ] + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.le + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + (Value.Integer 1)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "assertion failed: keep.len() <= 1" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let sp := + M.alloc (| + BinOp.Panic.add (| + Integer.U32, + M.read (| sp_before_execution |), + Value.Integer 1 + |) + |) in + let ops := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::mtable::MemoryTableEntry" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::mtable::MemoryTableEntry" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp |)); + ("ltype", + Value.StructTuple + "specs::mtable::LocationType::Stack" + []); + ("atype", + Value.StructTuple + "specs::mtable::AccessType::Read" + []); + ("vtype", + Value.StructTuple + "specs::mtable::VarType::I32" + []); + ("is_mutable", Value.Bool true); + ("value", + M.rust_cast + (M.rust_cast + (M.read (| M.read (| condition |) |)))) + ] + ] + |) + ] + |) + |)) + ] + |) + |) in + let _ := + M.write (| + sp, + BinOp.Panic.add (| Integer.U32, M.read (| sp |), Value.Integer 1 |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.read (| M.read (| condition |) |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| M.read (| M.return_ (| M.read (| ops |) |) |) |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + ops; + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp |)); + ("ltype", + Value.StructTuple + "specs::mtable::LocationType::Stack" + []); + ("atype", + Value.StructTuple + "specs::mtable::AccessType::Read" + []); + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::types::ValueType", + [ Ty.path "specs::mtable::VarType" + ], + "into", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + M.read (| i |) + ] + |) + |) + ] + |)); + ("is_mutable", Value.Bool true); + ("value", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + M.read (| i |) + ] + |) + |)) + ] + ] + |) + |) in + let _ := + M.write (| + sp, + BinOp.Panic.add (| + Integer.U32, + M.read (| sp |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::AddAssign", + Ty.path "u32", + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ], + "add_assign", + [] + |), + [ sp; M.read (| drop |) ] + |) + |) in + let _ := + let β := sp in + M.write (| + β, + BinOp.Panic.sub (| Integer.U32, M.read (| β |), Value.Integer 1 |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + ops; + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp |)); + ("ltype", + Value.StructTuple + "specs::mtable::LocationType::Stack" + []); + ("atype", + Value.StructTuple + "specs::mtable::AccessType::Write" + []); + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::types::ValueType", + [ Ty.path "specs::mtable::VarType" + ], + "into", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + M.read (| i |) + ] + |) + |) + ] + |)); + ("is_mutable", Value.Bool true); + ("value", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + M.read (| i |) + ] + |) + |)) + ] + ] + |) + |) in + let _ := + M.write (| + sp, + BinOp.Panic.sub (| + Integer.U32, + M.read (| sp |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + ops)); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrTable", + "index" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrTable", + "drop" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrTable", + "keep" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::BrTable", + "keep_values" + |) in + let index := M.alloc (| γ1_0 |) in + let drop := M.alloc (| γ1_1 |) in + let keep := M.alloc (| γ1_2 |) in + let keep_values := M.alloc (| γ1_3 |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |) + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ M.read (| keep_values |) ] + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.le + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + (Value.Integer 1)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "assertion failed: keep.len() <= 1" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let sp := + M.alloc (| + BinOp.Panic.add (| + Integer.U32, + M.read (| sp_before_execution |), + Value.Integer 1 + |) + |) in + let ops := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::mtable::MemoryTableEntry" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::mtable::MemoryTableEntry" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp |)); + ("ltype", + Value.StructTuple + "specs::mtable::LocationType::Stack" + []); + ("atype", + Value.StructTuple + "specs::mtable::AccessType::Read" + []); + ("vtype", + Value.StructTuple + "specs::mtable::VarType::I32" + []); + ("is_mutable", Value.Bool true); + ("value", + M.rust_cast + (M.rust_cast (M.read (| M.read (| index |) |)))) + ] + ] + |) + ] + |) + |)) + ] + |) + |) in + let _ := + M.write (| + sp, + BinOp.Panic.add (| Integer.U32, M.read (| sp |), Value.Integer 1 |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + ops; + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp |)); + ("ltype", + Value.StructTuple + "specs::mtable::LocationType::Stack" + []); + ("atype", + Value.StructTuple + "specs::mtable::AccessType::Read" + []); + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::types::ValueType", + [ Ty.path "specs::mtable::VarType" + ], + "into", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + M.read (| i |) + ] + |) + |) + ] + |)); + ("is_mutable", Value.Bool true); + ("value", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + M.read (| i |) + ] + |) + |)) + ] + ] + |) + |) in + let _ := + M.write (| + sp, + BinOp.Panic.add (| + Integer.U32, + M.read (| sp |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::AddAssign", + Ty.path "u32", + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ], + "add_assign", + [] + |), + [ sp; M.read (| drop |) ] + |) + |) in + let _ := + let β := sp in + M.write (| + β, + BinOp.Panic.sub (| Integer.U32, M.read (| β |), Value.Integer 1 |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + ops; + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp |)); + ("ltype", + Value.StructTuple + "specs::mtable::LocationType::Stack" + []); + ("atype", + Value.StructTuple + "specs::mtable::AccessType::Write" + []); + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::types::ValueType", + [ Ty.path "specs::mtable::VarType" + ], + "into", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + M.read (| i |) + ] + |) + |) + ] + |)); + ("is_mutable", Value.Bool true); + ("value", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + M.read (| i |) + ] + |) + |)) + ] + ] + |) + |) in + let _ := + M.write (| + sp, + BinOp.Panic.sub (| + Integer.U32, + M.read (| sp |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + ops)); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Return", + "drop" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Return", + "keep" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Return", + "keep_values" + |) in + let drop := M.alloc (| γ1_0 |) in + let keep := M.alloc (| γ1_1 |) in + let keep_values := M.alloc (| γ1_2 |) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |) + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ M.read (| keep_values |) ] + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.le + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + (Value.Integer 1)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "assertion failed: keep.len() <= 1" + |) + ] + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let sp := + M.alloc (| + BinOp.Panic.add (| + Integer.U32, + M.read (| sp_before_execution |), + Value.Integer 1 + |) + |) in + let ops := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + ops; + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp |)); + ("ltype", + Value.StructTuple + "specs::mtable::LocationType::Stack" + []); + ("atype", + Value.StructTuple + "specs::mtable::AccessType::Read" + []); + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::types::ValueType", + [ Ty.path "specs::mtable::VarType" + ], + "into", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + M.read (| i |) + ] + |) + |) + ] + |)); + ("is_mutable", Value.Bool true); + ("value", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + M.read (| i |) + ] + |) + |)) + ] + ] + |) + |) in + let _ := + M.write (| + sp, + BinOp.Panic.add (| + Integer.U32, + M.read (| sp |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::AddAssign", + Ty.path "u32", + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ], + "add_assign", + [] + |), + [ sp; M.read (| drop |) ] + |) + |) in + let _ := + let β := sp in + M.write (| + β, + BinOp.Panic.sub (| Integer.U32, M.read (| β |), Value.Integer 1 |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| keep |) ] + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + ops; + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp |)); + ("ltype", + Value.StructTuple + "specs::mtable::LocationType::Stack" + []); + ("atype", + Value.StructTuple + "specs::mtable::AccessType::Write" + []); + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::types::ValueType", + [ Ty.path "specs::mtable::VarType" + ], + "into", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep |); + M.read (| i |) + ] + |) + |) + ] + |)); + ("is_mutable", Value.Bool true); + ("value", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path + "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.read (| keep_values |); + M.read (| i |) + ] + |) + |)) + ] + ] + |) + |) in + let _ := + M.write (| + sp, + BinOp.Panic.sub (| + Integer.U32, + M.read (| sp |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + ops)); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Select", + "val1" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Select", + "val2" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Select", + "cond" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Select", + "result" + |) in + let γ1_4 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Select", + "vtype" + |) in + let val1 := M.alloc (| γ1_0 |) in + let val2 := M.alloc (| γ1_1 |) in + let cond := M.alloc (| γ1_2 |) in + let result := M.alloc (| γ1_3 |) in + let vtype := M.alloc (| γ1_4 |) in + let sp := + M.alloc (| + BinOp.Panic.add (| + Integer.U32, + M.read (| sp_before_execution |), + Value.Integer 1 + |) + |) in + let ops := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + ops; + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp |)); + ("ltype", + Value.StructTuple "specs::mtable::LocationType::Stack" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Read" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| cond |) |)) + ] + ] + |) + |) in + let _ := + M.write (| + sp, + BinOp.Panic.add (| Integer.U32, M.read (| sp |), Value.Integer 1 |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + ops; + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp |)); + ("ltype", + Value.StructTuple "specs::mtable::LocationType::Stack" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Read" []); + ("vtype", M.read (| M.read (| vtype |) |)); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| val2 |) |)) + ] + ] + |) + |) in + let _ := + M.write (| + sp, + BinOp.Panic.add (| Integer.U32, M.read (| sp |), Value.Integer 1 |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + ops; + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp |)); + ("ltype", + Value.StructTuple "specs::mtable::LocationType::Stack" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Read" []); + ("vtype", M.read (| M.read (| vtype |) |)); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| val1 |) |)) + ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + ops; + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp |)); + ("ltype", + Value.StructTuple "specs::mtable::LocationType::Stack" []); + ("atype", + Value.StructTuple "specs::mtable::AccessType::Write" []); + ("vtype", M.read (| M.read (| vtype |) |)); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| result |) |)) + ] + ] + |) + |) in + ops)); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Call", + "index" + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallIndirect", + "offset" + |) in + let offset := M.alloc (| γ1_0 |) in + let stack_read := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", + BinOp.Panic.add (| + Integer.U32, + M.read (| sp_before_execution |), + Value.Integer 1 + |)); + ("ltype", Value.StructTuple "specs::mtable::LocationType::Stack" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Read" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []); + ("is_mutable", Value.Bool true); + ("value", M.rust_cast (M.read (| M.read (| offset |) |))) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::mtable::MemoryTableEntry" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::mtable::MemoryTableEntry" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.alloc (| Value.Array [ M.read (| stack_read |) ] |) ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "args" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "ret_val" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "signature" + |) in + let args := M.alloc (| γ1_0 |) in + let ret_val := M.alloc (| γ1_1 |) in + let signature := M.alloc (| γ1_2 |) in + let mops := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let sp := M.copy (| sp_before_execution |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "specs::types::ValueType" ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "u64" ] + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "specs::types::ValueType" ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "u64" ] + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "specs::types::ValueType" ], + [], + "zip", + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "u64" ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::types::ValueType" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| signature |), + "specs::host_function::Signature", + "params" + |) + ] + |) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u64" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| args |) ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::iter::adapters::zip::Zip") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "specs::types::ValueType" ]; + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "u64" ] + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let i := M.copy (| γ1_0 |) in + let γ2_0 := + M.SubPointer.get_tuple_field (| γ1_1, 0 |) in + let γ2_1 := + M.SubPointer.get_tuple_field (| γ1_1, 1 |) in + let ty := M.copy (| γ2_0 |) in + let val := M.copy (| γ2_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + mops; + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", + BinOp.Panic.sub (| + Integer.U32, + BinOp.Panic.add (| + Integer.U32, + M.read (| sp_before_execution |), + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path + "alloc::alloc::Global" + ], + "len", + [] + |), + [ M.read (| args |) ] + |)) + |), + M.rust_cast (M.read (| i |)) + |)); + ("ltype", + Value.StructTuple + "specs::mtable::LocationType::Stack" + []); + ("atype", + Value.StructTuple + "specs::mtable::AccessType::Read" + []); + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::types::ValueType", + [ Ty.path "specs::mtable::VarType" + ], + "into", + [] + |), + [ M.read (| M.read (| ty |) |) ] + |)); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| val |) |)) + ] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.write (| + sp, + BinOp.Panic.add (| + Integer.U32, + M.read (| sp |), + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ M.read (| args |) ] + |)) + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.SubPointer.get_struct_record_field (| + M.read (| signature |), + "specs::host_function::Signature", + "return_type" + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let ty := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + mops; + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp |)); + ("ltype", + Value.StructTuple + "specs::mtable::LocationType::Stack" + []); + ("atype", + Value.StructTuple + "specs::mtable::AccessType::Write" + []); + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ M.read (| ty |) ] + |)); + ("is_mutable", Value.Bool true); + ("value", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ], + "unwrap", + [] + |), + [ M.read (| M.read (| ret_val |) |) ] + |)) + ] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + mops)); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::ExternalHostCall", + "value" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::ExternalHostCall", + "sig" + |) in + let value := M.alloc (| γ1_0 |) in + let sig := M.alloc (| γ1_1 |) in + M.match_operator (| + sig, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let stack_read := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", + BinOp.Panic.add (| + Integer.U32, + M.read (| sp_before_execution |), + Value.Integer 1 + |)); + ("ltype", + Value.StructTuple "specs::mtable::LocationType::Stack" []); + ("atype", + Value.StructTuple "specs::mtable::AccessType::Read" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []); + ("is_mutable", Value.Bool true); + ("value", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ], + "unwrap", + [] + |), + [ M.read (| M.read (| value |) |) ] + |)) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::mtable::MemoryTableEntry" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::mtable::MemoryTableEntry" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.alloc (| Value.Array [ M.read (| stack_read |) ] |) ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let stack_write := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp_before_execution |)); + ("ltype", + Value.StructTuple "specs::mtable::LocationType::Stack" []); + ("atype", + Value.StructTuple "specs::mtable::AccessType::Write" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []); + ("is_mutable", Value.Bool true); + ("value", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ], + "unwrap", + [] + |), + [ M.read (| M.read (| value |) |) ] + |)) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::mtable::MemoryTableEntry" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::mtable::MemoryTableEntry" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.alloc (| Value.Array [ M.read (| stack_write |) ] |) ] + |) + |)) + ] + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::GetLocal", + "vtype" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::GetLocal", + "depth" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::GetLocal", + "value" + |) in + let vtype := M.alloc (| γ1_0 |) in + let depth := M.alloc (| γ1_1 |) in + let value := M.alloc (| γ1_2 |) in + let read := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.path "u32", + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ], + "add", + [] + |), + [ M.read (| sp_before_execution |); M.read (| depth |) ] + |)); + ("ltype", Value.StructTuple "specs::mtable::LocationType::Stack" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Read" []); + ("vtype", M.read (| M.read (| vtype |) |)); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| value |) |)) + ] + |) in + let write := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp_before_execution |)); + ("ltype", Value.StructTuple "specs::mtable::LocationType::Stack" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Write" []); + ("vtype", M.read (| M.read (| vtype |) |)); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| value |) |)) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::mtable::MemoryTableEntry" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::mtable::MemoryTableEntry" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array [ M.read (| read |); M.read (| write |) ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::SetLocal", + "vtype" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::SetLocal", + "depth" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::SetLocal", + "value" + |) in + let vtype := M.alloc (| γ1_0 |) in + let depth := M.alloc (| γ1_1 |) in + let value := M.alloc (| γ1_2 |) in + let sp := M.copy (| sp_before_execution |) in + let read := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", + BinOp.Panic.add (| + Integer.U32, + M.read (| sp |), + Value.Integer 1 + |)); + ("ltype", Value.StructTuple "specs::mtable::LocationType::Stack" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Read" []); + ("vtype", M.read (| M.read (| vtype |) |)); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| value |) |)) + ] + |) in + let _ := + let β := sp in + M.write (| + β, + BinOp.Panic.add (| Integer.U32, M.read (| β |), Value.Integer 1 |) + |) in + let write := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.path "u32", + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ], + "add", + [] + |), + [ M.read (| sp |); M.read (| depth |) ] + |)); + ("ltype", Value.StructTuple "specs::mtable::LocationType::Stack" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Write" []); + ("vtype", M.read (| M.read (| vtype |) |)); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| value |) |)) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::mtable::MemoryTableEntry" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::mtable::MemoryTableEntry" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array [ M.read (| read |); M.read (| write |) ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::TeeLocal", + "vtype" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::TeeLocal", + "depth" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::TeeLocal", + "value" + |) in + let vtype := M.alloc (| γ1_0 |) in + let depth := M.alloc (| γ1_1 |) in + let value := M.alloc (| γ1_2 |) in + let read := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", + BinOp.Panic.add (| + Integer.U32, + M.read (| sp_before_execution |), + Value.Integer 1 + |)); + ("ltype", Value.StructTuple "specs::mtable::LocationType::Stack" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Read" []); + ("vtype", M.read (| M.read (| vtype |) |)); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| value |) |)) + ] + |) in + let write := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Add", + Ty.path "u32", + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ], + "add", + [] + |), + [ M.read (| sp_before_execution |); M.read (| depth |) ] + |)); + ("ltype", Value.StructTuple "specs::mtable::LocationType::Stack" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Write" []); + ("vtype", M.read (| M.read (| vtype |) |)); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| value |) |)) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::mtable::MemoryTableEntry" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::mtable::MemoryTableEntry" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array [ M.read (| read |); M.read (| write |) ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::GetGlobal", + "idx" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::GetGlobal", + "vtype" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::GetGlobal", + "is_mutable" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::GetGlobal", + "value" + |) in + let idx := M.alloc (| γ1_0 |) in + let vtype := M.alloc (| γ1_1 |) in + let is_mutable := M.alloc (| γ1_2 |) in + let value := M.alloc (| γ1_3 |) in + let global_get := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| M.read (| idx |) |)); + ("ltype", Value.StructTuple "specs::mtable::LocationType::Global" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Read" []); + ("vtype", M.read (| M.read (| vtype |) |)); + ("is_mutable", M.read (| M.read (| is_mutable |) |)); + ("value", M.read (| M.read (| value |) |)) + ] + |) in + let stack_write := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp_before_execution |)); + ("ltype", Value.StructTuple "specs::mtable::LocationType::Stack" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Write" []); + ("vtype", M.read (| M.read (| vtype |) |)); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| value |) |)) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::mtable::MemoryTableEntry" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::mtable::MemoryTableEntry" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ M.read (| global_get |); M.read (| stack_write |) ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::SetGlobal", + "idx" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::SetGlobal", + "vtype" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::SetGlobal", + "is_mutable" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::SetGlobal", + "value" + |) in + let idx := M.alloc (| γ1_0 |) in + let vtype := M.alloc (| γ1_1 |) in + let is_mutable := M.alloc (| γ1_2 |) in + let value := M.alloc (| γ1_3 |) in + let stack_read := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", + BinOp.Panic.add (| + Integer.U32, + M.read (| sp_before_execution |), + Value.Integer 1 + |)); + ("ltype", Value.StructTuple "specs::mtable::LocationType::Stack" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Read" []); + ("vtype", M.read (| M.read (| vtype |) |)); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| value |) |)) + ] + |) in + let global_set := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| M.read (| idx |) |)); + ("ltype", Value.StructTuple "specs::mtable::LocationType::Global" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Write" []); + ("vtype", M.read (| M.read (| vtype |) |)); + ("is_mutable", M.read (| M.read (| is_mutable |) |)); + ("value", M.read (| M.read (| value |) |)) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::mtable::MemoryTableEntry" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::mtable::MemoryTableEntry" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ M.read (| stack_read |); M.read (| global_set |) ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Load", + "vtype" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Load", + "load_size" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Load", + "raw_address" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Load", + "effective_address" + |) in + let γ1_4 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Load", + "value" + |) in + let γ1_5 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Load", + "block_value1" + |) in + let γ1_6 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Load", + "block_value2" + |) in + let vtype := M.alloc (| γ1_0 |) in + let load_size := M.alloc (| γ1_1 |) in + let raw_address := M.alloc (| γ1_2 |) in + let effective_address := M.alloc (| γ1_3 |) in + let value := M.alloc (| γ1_4 |) in + let block_value1 := M.alloc (| γ1_5 |) in + let block_value2 := M.alloc (| γ1_6 |) in + let load_address_from_stack := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", + BinOp.Panic.add (| + Integer.U32, + M.read (| sp_before_execution |), + Value.Integer 1 + |)); + ("ltype", Value.StructTuple "specs::mtable::LocationType::Stack" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Read" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []); + ("is_mutable", Value.Bool true); + ("value", M.rust_cast (M.read (| M.read (| raw_address |) |))) + ] + |) in + let load_value1 := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", + BinOp.Panic.div (| + Integer.U32, + M.read (| M.read (| effective_address |) |), + Value.Integer 8 + |)); + ("ltype", Value.StructTuple "specs::mtable::LocationType::Heap" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Read" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| block_value1 |) |)) + ] + |) in + let load_value2 := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (BinOp.Panic.add (| + Integer.U32, + BinOp.Panic.rem (| + Integer.U32, + M.read (| M.read (| effective_address |) |), + Value.Integer 8 + |), + M.read (| + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::mtable::MemoryReadSize", + "byte_size", + [] + |), + [ M.read (| load_size |) ] + |) + |)) + |) + |)) + (Value.Integer 8) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", + BinOp.Panic.add (| + Integer.U32, + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Div", + Ty.apply (Ty.path "&") [ Ty.path "u32" ], + [ Ty.path "u32" ], + "div", + [] + |), + [ M.read (| effective_address |); Value.Integer 8 + ] + |), + Value.Integer 1 + |)); + ("ltype", + Value.StructTuple + "specs::mtable::LocationType::Heap" + []); + ("atype", + Value.StructTuple + "specs::mtable::AccessType::Read" + []); + ("vtype", + Value.StructTuple "specs::mtable::VarType::I64" []); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| block_value2 |) |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "core::option::Option::None" [] |))) + ] + |) + |) in + let push_value := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", + BinOp.Panic.add (| + Integer.U32, + M.read (| sp_before_execution |), + Value.Integer 1 + |)); + ("ltype", Value.StructTuple "specs::mtable::LocationType::Stack" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Write" []); + ("vtype", M.read (| M.read (| vtype |) |)); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| value |) |)) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ] + ], + "concat", + [ Ty.path "specs::mtable::MemoryTableEntry" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ] + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "specs::mtable::MemoryTableEntry" + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.path + "specs::mtable::MemoryTableEntry" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.read (| + load_address_from_stack + |); + M.read (| load_value1 |) + ] + |) + ] + |) + |)) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "specs::mtable::MemoryTableEntry" + ], + "map_or", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.path + "specs::mtable::MemoryTableEntry" + ] + ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ]) + ] + |), + [ + M.read (| load_value2 |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let v := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "specs::mtable::MemoryTableEntry" + ], + "into_vec", + [ + Ty.path + "alloc::alloc::Global" + ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.path + "specs::mtable::MemoryTableEntry" + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.read (| + v + |) + ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "specs::mtable::MemoryTableEntry" + ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.path + "specs::mtable::MemoryTableEntry" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ M.read (| push_value |) ] + |) + ] + |) + |)) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |) + ] + |) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "vtype" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "store_size" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "raw_address" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "effective_address" + |) in + let γ1_4 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "value" + |) in + let γ1_5 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "pre_block_value1" + |) in + let γ1_6 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "updated_block_value1" + |) in + let γ1_7 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "pre_block_value2" + |) in + let γ1_8 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Store", + "updated_block_value2" + |) in + let vtype := M.alloc (| γ1_0 |) in + let store_size := M.alloc (| γ1_1 |) in + let raw_address := M.alloc (| γ1_2 |) in + let effective_address := M.alloc (| γ1_3 |) in + let value := M.alloc (| γ1_4 |) in + let pre_block_value1 := M.alloc (| γ1_5 |) in + let updated_block_value1 := M.alloc (| γ1_6 |) in + let pre_block_value2 := M.alloc (| γ1_7 |) in + let updated_block_value2 := M.alloc (| γ1_8 |) in + let load_value_from_stack := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", + BinOp.Panic.add (| + Integer.U32, + M.read (| sp_before_execution |), + Value.Integer 1 + |)); + ("ltype", Value.StructTuple "specs::mtable::LocationType::Stack" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Read" []); + ("vtype", M.read (| M.read (| vtype |) |)); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| value |) |)) + ] + |) in + let load_address_from_stack := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", + BinOp.Panic.add (| + Integer.U32, + M.read (| sp_before_execution |), + Value.Integer 2 + |)); + ("ltype", Value.StructTuple "specs::mtable::LocationType::Stack" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Read" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []); + ("is_mutable", Value.Bool true); + ("value", M.rust_cast (M.read (| M.read (| raw_address |) |))) + ] + |) in + let load_value1 := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Div", + Ty.apply (Ty.path "&") [ Ty.path "u32" ], + [ Ty.path "u32" ], + "div", + [] + |), + [ M.read (| effective_address |); Value.Integer 8 ] + |)); + ("ltype", Value.StructTuple "specs::mtable::LocationType::Heap" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Read" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| pre_block_value1 |) |)) + ] + |) in + let write_value1 := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Div", + Ty.apply (Ty.path "&") [ Ty.path "u32" ], + [ Ty.path "u32" ], + "div", + [] + |), + [ M.read (| effective_address |); Value.Integer 8 ] + |)); + ("ltype", Value.StructTuple "specs::mtable::LocationType::Heap" []); + ("atype", Value.StructTuple "specs::mtable::AccessType::Write" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| updated_block_value1 |) |)) + ] + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (BinOp.Panic.add (| + Integer.U32, + BinOp.Panic.rem (| + Integer.U32, + M.read (| M.read (| effective_address |) |), + Value.Integer 8 + |), + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path "specs::mtable::MemoryStoreSize", + "byte_size", + [] + |), + [ M.read (| store_size |) ] + |)) + |)) + (Value.Integer 8) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let load_value2 := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", + BinOp.Panic.add (| + Integer.U32, + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Div", + Ty.apply (Ty.path "&") [ Ty.path "u32" ], + [ Ty.path "u32" ], + "div", + [] + |), + [ M.read (| effective_address |); Value.Integer 8 ] + |), + Value.Integer 1 + |)); + ("ltype", + Value.StructTuple "specs::mtable::LocationType::Heap" []); + ("atype", + Value.StructTuple "specs::mtable::AccessType::Read" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| pre_block_value2 |) |)) + ] + |) in + let write_value2 := + M.alloc (| + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", + BinOp.Panic.add (| + Integer.U32, + M.call_closure (| + M.get_trait_method (| + "core::ops::arith::Div", + Ty.apply (Ty.path "&") [ Ty.path "u32" ], + [ Ty.path "u32" ], + "div", + [] + |), + [ M.read (| effective_address |); Value.Integer 8 ] + |), + Value.Integer 1 + |)); + ("ltype", + Value.StructTuple "specs::mtable::LocationType::Heap" []); + ("atype", + Value.StructTuple "specs::mtable::AccessType::Write" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []); + ("is_mutable", Value.Bool true); + ("value", M.read (| M.read (| updated_block_value2 |) |)) + ] + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::mtable::MemoryTableEntry" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::mtable::MemoryTableEntry" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.read (| load_value_from_stack |); + M.read (| load_address_from_stack |); + M.read (| load_value1 |); + M.read (| write_value1 |); + M.read (| load_value2 |); + M.read (| write_value2 |) + ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::mtable::MemoryTableEntry" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::mtable::MemoryTableEntry" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.read (| load_value_from_stack |); + M.read (| load_address_from_stack |); + M.read (| load_value1 |); + M.read (| write_value1 |) + ] + |) + ] + |) + |)) + ] + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::runtime::mem_op_from_stack_only_step", + [] + |), + [ + M.read (| sp_before_execution |); + M.read (| eid |); + Value.StructTuple "specs::mtable::VarType::I32" []; + Value.StructTuple "specs::mtable::VarType::I32" []; + (* Unsize *) M.pointer_coercion (M.alloc (| Value.Array [] |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.rust_cast + (M.read (| + M.use + (M.SubPointer.get_struct_record_field (| + M.read (| event |), + "specs::etable::EventTableEntry", + "allocated_memory_pages" + |)) + |)) + ] + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::MemoryGrow", + "grow_size" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::MemoryGrow", + "result" + |) in + let grow_size := M.alloc (| γ1_0 |) in + let result := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::runtime::mem_op_from_stack_only_step", + [] + |), + [ + M.read (| sp_before_execution |); + M.read (| eid |); + Value.StructTuple "specs::mtable::VarType::I32" []; + Value.StructTuple "specs::mtable::VarType::I32" []; + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ M.rust_cast (M.rust_cast (M.read (| M.read (| grow_size |) |))) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ M.rust_cast (M.rust_cast (M.read (| M.read (| result |) |))) ] + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32Const", + "value" + |) in + let value := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::runtime::mem_op_from_stack_only_step", + [] + |), + [ + M.read (| sp_before_execution |); + M.read (| eid |); + Value.StructTuple "specs::mtable::VarType::I32" []; + Value.StructTuple "specs::mtable::VarType::I32" []; + (* Unsize *) M.pointer_coercion (M.alloc (| Value.Array [] |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ M.rust_cast (M.rust_cast (M.read (| M.read (| value |) |))) ] + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinOp", + "left" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinOp", + "right" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinOp", + "value" + |) in + let left := M.alloc (| γ1_0 |) in + let right := M.alloc (| γ1_1 |) in + let value := M.alloc (| γ1_2 |) in + Value.Tuple [ left; right; value ])); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinShiftOp", + "left" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinShiftOp", + "right" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinShiftOp", + "value" + |) in + let left := M.alloc (| γ1_0 |) in + let right := M.alloc (| γ1_1 |) in + let value := M.alloc (| γ1_2 |) in + Value.Tuple [ left; right; value ])); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinBitOp", + "left" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinBitOp", + "right" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32BinBitOp", + "value" + |) in + let left := M.alloc (| γ1_0 |) in + let right := M.alloc (| γ1_1 |) in + let value := M.alloc (| γ1_2 |) in + Value.Tuple [ left; right; value ])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ _ as left; _ as right; value ] => + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::runtime::mem_op_from_stack_only_step", + [] + |), + [ + M.read (| sp_before_execution |); + M.read (| eid |); + Value.StructTuple "specs::mtable::VarType::I32" []; + Value.StructTuple "specs::mtable::VarType::I32" []; + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.rust_cast + (M.rust_cast (M.read (| M.read (| right |) |))); + M.rust_cast + (M.rust_cast (M.read (| M.read (| left |) |))) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.rust_cast + (M.rust_cast (M.read (| M.read (| value |) |))) + ] + |)) + ] + |) + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32Comp", + "left" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32Comp", + "right" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32Comp", + "value" + |) in + let left := M.alloc (| γ1_0 |) in + let right := M.alloc (| γ1_1 |) in + let value := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::runtime::mem_op_from_stack_only_step", + [] + |), + [ + M.read (| sp_before_execution |); + M.read (| eid |); + Value.StructTuple "specs::mtable::VarType::I32" []; + Value.StructTuple "specs::mtable::VarType::I32" []; + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.rust_cast (M.rust_cast (M.read (| M.read (| right |) |))); + M.rust_cast (M.rust_cast (M.read (| M.read (| left |) |))) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ M.rust_cast (M.rust_cast (M.read (| M.read (| value |) |))) ] + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinOp", + "left" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinOp", + "right" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinOp", + "value" + |) in + let left := M.alloc (| γ1_0 |) in + let right := M.alloc (| γ1_1 |) in + let value := M.alloc (| γ1_2 |) in + Value.Tuple [ left; right; value ])); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinShiftOp", + "left" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinShiftOp", + "right" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinShiftOp", + "value" + |) in + let left := M.alloc (| γ1_0 |) in + let right := M.alloc (| γ1_1 |) in + let value := M.alloc (| γ1_2 |) in + Value.Tuple [ left; right; value ])); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinBitOp", + "left" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinBitOp", + "right" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64BinBitOp", + "value" + |) in + let left := M.alloc (| γ1_0 |) in + let right := M.alloc (| γ1_1 |) in + let value := M.alloc (| γ1_2 |) in + Value.Tuple [ left; right; value ])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ _ as left; _ as right; value ] => + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::runtime::mem_op_from_stack_only_step", + [] + |), + [ + M.read (| sp_before_execution |); + M.read (| eid |); + Value.StructTuple "specs::mtable::VarType::I64" []; + Value.StructTuple "specs::mtable::VarType::I64" []; + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.rust_cast (M.read (| M.read (| right |) |)); + M.rust_cast (M.read (| M.read (| left |) |)) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ M.rust_cast (M.read (| M.read (| value |) |)) ] + |)) + ] + |) + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64Const", + "value" + |) in + let value := M.alloc (| γ1_0 |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::runtime::mem_op_from_stack_only_step", + [] + |), + [ + M.read (| sp_before_execution |); + M.read (| eid |); + Value.StructTuple "specs::mtable::VarType::I64" []; + Value.StructTuple "specs::mtable::VarType::I64" []; + (* Unsize *) M.pointer_coercion (M.alloc (| Value.Array [] |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array [ M.rust_cast (M.read (| M.read (| value |) |)) ] + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64Comp", + "left" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64Comp", + "right" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64Comp", + "value" + |) in + let left := M.alloc (| γ1_0 |) in + let right := M.alloc (| γ1_1 |) in + let value := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::runtime::mem_op_from_stack_only_step", + [] + |), + [ + M.read (| sp_before_execution |); + M.read (| eid |); + Value.StructTuple "specs::mtable::VarType::I64" []; + Value.StructTuple "specs::mtable::VarType::I32" []; + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.rust_cast (M.read (| M.read (| right |) |)); + M.rust_cast (M.read (| M.read (| left |) |)) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ M.rust_cast (M.rust_cast (M.read (| M.read (| value |) |))) ] + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::UnaryOp", + "vtype" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::UnaryOp", + "operand" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::UnaryOp", + "result" + |) in + let vtype := M.alloc (| γ1_0 |) in + let operand := M.alloc (| γ1_1 |) in + let result := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::runtime::mem_op_from_stack_only_step", + [] + |), + [ + M.read (| sp_before_execution |); + M.read (| eid |); + M.read (| M.read (| vtype |) |); + M.read (| M.read (| vtype |) |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| Value.Array [ M.read (| M.read (| operand |) |) ] |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| Value.Array [ M.read (| M.read (| result |) |) ] |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Test", + "vtype" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Test", + "value" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Test", + "result" + |) in + let vtype := M.alloc (| γ1_0 |) in + let value := M.alloc (| γ1_1 |) in + let result := M.alloc (| γ1_2 |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::runtime::mem_op_from_stack_only_step", + [] + |), + [ + M.read (| sp_before_execution |); + M.read (| eid |); + M.read (| M.read (| vtype |) |); + Value.StructTuple "specs::mtable::VarType::I32" []; + (* Unsize *) + M.pointer_coercion + (M.alloc (| Value.Array [ M.read (| M.read (| value |) |) ] |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ M.rust_cast (M.rust_cast (M.read (| M.read (| result |) |))) ] + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32WrapI64", + "value" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32WrapI64", + "result" + |) in + let value := M.alloc (| γ1_0 |) in + let result := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::runtime::mem_op_from_stack_only_step", + [] + |), + [ + M.read (| sp_before_execution |); + M.read (| eid |); + Value.StructTuple "specs::mtable::VarType::I64" []; + Value.StructTuple "specs::mtable::VarType::I32" []; + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array [ M.rust_cast (M.read (| M.read (| value |) |)) ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ M.rust_cast (M.rust_cast (M.read (| M.read (| result |) |))) ] + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64ExtendI32", + "value" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64ExtendI32", + "result" + |) in + let value := M.alloc (| γ1_0 |) in + let result := M.alloc (| γ1_1 |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::runtime::mem_op_from_stack_only_step", + [] + |), + [ + M.read (| sp_before_execution |); + M.read (| eid |); + Value.StructTuple "specs::mtable::VarType::I32" []; + Value.StructTuple "specs::mtable::VarType::I64" []; + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ M.rust_cast (M.rust_cast (M.read (| M.read (| value |) |))) ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array [ M.rust_cast (M.read (| M.read (| result |) |)) ] + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32SignExtendI8", + "value" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32SignExtendI8", + "result" + |) in + let value := M.alloc (| γ1_0 |) in + let result := M.alloc (| γ1_1 |) in + Value.Tuple [ value; result ])); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32SignExtendI16", + "value" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I32SignExtendI16", + "result" + |) in + let value := M.alloc (| γ1_0 |) in + let result := M.alloc (| γ1_1 |) in + Value.Tuple [ value; result ])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ value; result ] => + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::runtime::mem_op_from_stack_only_step", + [] + |), + [ + M.read (| sp_before_execution |); + M.read (| eid |); + Value.StructTuple "specs::mtable::VarType::I32" []; + Value.StructTuple "specs::mtable::VarType::I32" []; + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.rust_cast + (M.rust_cast (M.read (| M.read (| value |) |))) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.rust_cast + (M.rust_cast (M.read (| M.read (| result |) |))) + ] + |)) + ] + |) + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64SignExtendI8", + "value" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64SignExtendI8", + "result" + |) in + let value := M.alloc (| γ1_0 |) in + let result := M.alloc (| γ1_1 |) in + Value.Tuple [ value; result ])); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64SignExtendI16", + "value" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64SignExtendI16", + "result" + |) in + let value := M.alloc (| γ1_0 |) in + let result := M.alloc (| γ1_1 |) in + Value.Tuple [ value; result ])); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64SignExtendI32", + "value" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::I64SignExtendI32", + "result" + |) in + let value := M.alloc (| γ1_0 |) in + let result := M.alloc (| γ1_1 |) in + Value.Tuple [ value; result ])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ value; result ] => + M.alloc (| + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::runtime::mem_op_from_stack_only_step", + [] + |), + [ + M.read (| sp_before_execution |); + M.read (| eid |); + Value.StructTuple "specs::mtable::VarType::I64" []; + Value.StructTuple "specs::mtable::VarType::I64" []; + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ M.rust_cast (M.read (| M.read (| value |) |)) ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ M.rust_cast (M.read (| M.read (| result |) |)) ] + |)) + ] + |) + |) + | _ => M.impossible (||) + end)) + |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + pub(crate) fn mem_op_from_stack_only_step( + sp_before_execution: u32, + eid: u32, + inputs_type: VarType, + outputs_type: VarType, + pop_value: &[u64], + push_value: &[u64], + ) -> Vec { + let mut mem_op = vec![]; + let mut sp = sp_before_execution; + + for i in 0..pop_value.len() { + mem_op.push(MemoryTableEntry { + eid, + offset: sp + 1, + ltype: LocationType::Stack, + atype: AccessType::Read, + vtype: inputs_type, + is_mutable: true, + value: pop_value[i], + }); + sp = sp + 1; + } + + for i in 0..push_value.len() { + mem_op.push(MemoryTableEntry { + eid, + offset: sp, + ltype: LocationType::Stack, + atype: AccessType::Write, + vtype: outputs_type, + is_mutable: true, + value: push_value[i], + }); + sp = sp - 1; + } + + mem_op + } + *) + Definition mem_op_from_stack_only_step (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ sp_before_execution; eid; inputs_type; outputs_type; pop_value; push_value ] => + ltac:(M.monadic + (let sp_before_execution := M.alloc (| sp_before_execution |) in + let eid := M.alloc (| eid |) in + let inputs_type := M.alloc (| inputs_type |) in + let outputs_type := M.alloc (| outputs_type |) in + let pop_value := M.alloc (| pop_value |) in + let push_value := M.alloc (| push_value |) in + M.read (| + let mem_op := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "specs::mtable::MemoryTableEntry"; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |) + |) in + let sp := M.copy (| sp_before_execution |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u64" ], + "len", + [] + |), + [ M.read (| pop_value |) ] + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + mem_op; + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", + BinOp.Panic.add (| + Integer.U32, + M.read (| sp |), + Value.Integer 1 + |)); + ("ltype", + Value.StructTuple + "specs::mtable::LocationType::Stack" + []); + ("atype", + Value.StructTuple + "specs::mtable::AccessType::Read" + []); + ("vtype", M.read (| inputs_type |)); + ("is_mutable", Value.Bool true); + ("value", + M.read (| + M.SubPointer.get_array_field (| + M.read (| pop_value |), + i + |) + |)) + ] + ] + |) + |) in + let _ := + M.write (| + sp, + BinOp.Panic.add (| + Integer.U32, + M.read (| sp |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply (Ty.path "core::ops::range::Range") [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u64" ], + "len", + [] + |), + [ M.read (| push_value |) ] + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + mem_op; + Value.StructRecord + "specs::mtable::MemoryTableEntry" + [ + ("eid", M.read (| eid |)); + ("offset", M.read (| sp |)); + ("ltype", + Value.StructTuple + "specs::mtable::LocationType::Stack" + []); + ("atype", + Value.StructTuple + "specs::mtable::AccessType::Write" + []); + ("vtype", M.read (| outputs_type |)); + ("is_mutable", Value.Bool true); + ("value", + M.read (| + M.SubPointer.get_array_field (| + M.read (| push_value |), + i + |) + |)) + ] + ] + |) + |) in + let _ := + M.write (| + sp, + BinOp.Panic.sub (| + Integer.U32, + M.read (| sp |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + mem_op + |))) + | _, _ => M.impossible + end. +End runtime. diff --git a/CoqOfRust/zkWasm/runtime/monitor/mod.v b/CoqOfRust/zkWasm/runtime/monitor/mod.v new file mode 100644 index 000000000..02c4b65fe --- /dev/null +++ b/CoqOfRust/zkWasm/runtime/monitor/mod.v @@ -0,0 +1,9 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module runtime. + Module monitor. + (* Trait *) + (* Empty module 'WasmiMonitor' *) + End monitor. +End runtime. diff --git a/CoqOfRust/zkWasm/runtime/monitor/observer.v b/CoqOfRust/zkWasm/runtime/monitor/observer.v new file mode 100644 index 000000000..1aeeff552 --- /dev/null +++ b/CoqOfRust/zkWasm/runtime/monitor/observer.v @@ -0,0 +1,110 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module runtime. + Module monitor. + Module observer. + (* StructRecord + { + name := "Observer"; + ty_params := []; + fields := [ ("counter", Ty.path "usize"); ("is_in_phantom", Ty.path "bool") ]; + } *) + + Module Impl_core_fmt_Debug_for_delphinus_zkwasm_runtime_monitor_observer_Observer. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::runtime::monitor::observer::Observer". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "Observer" |); + M.read (| Value.String "counter" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::observer::Observer", + "counter" + |)); + M.read (| Value.String "is_in_phantom" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::observer::Observer", + "is_in_phantom" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_delphinus_zkwasm_runtime_monitor_observer_Observer. + + Module Impl_core_default_Default_for_delphinus_zkwasm_runtime_monitor_observer_Observer. + Definition Self : Ty.t := Ty.path "delphinus_zkwasm::runtime::monitor::observer::Observer". + + (* Default *) + Definition default (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [] => + ltac:(M.monadic + (Value.StructRecord + "delphinus_zkwasm::runtime::monitor::observer::Observer" + [ + ("counter", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.path "usize", + [], + "default", + [] + |), + [] + |)); + ("is_in_phantom", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.path "bool", + [], + "default", + [] + |), + [] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::default::Default" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("default", InstanceField.Method default) ]. + End Impl_core_default_Default_for_delphinus_zkwasm_runtime_monitor_observer_Observer. + End observer. + End monitor. +End runtime. diff --git a/CoqOfRust/zkWasm/runtime/monitor/plugins/phantom.v b/CoqOfRust/zkWasm/runtime/monitor/plugins/phantom.v new file mode 100644 index 000000000..a0e1cf434 --- /dev/null +++ b/CoqOfRust/zkWasm/runtime/monitor/plugins/phantom.v @@ -0,0 +1,799 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module runtime. + Module monitor. + Module plugins. + Module phantom. + (* StructRecord + { + name := "PhantomHelper"; + ty_params := []; + fields := + [ + ("phantom_regex", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "regex::regex::string::Regex"; Ty.path "alloc::alloc::Global" ]); + ("phantom_functions", + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ Ty.path "u32"; Ty.path "std::hash::random::RandomState" ]); + ("wasm_input", Ty.path "wasmi::func::FuncRef"); + ("frame", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u32"; Ty.path "alloc::alloc::Global" ]) + ]; + } *) + + Module Impl_delphinus_zkwasm_runtime_monitor_plugins_phantom_PhantomHelper. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper". + + (* + pub fn new(phantom_regex: &Vec, wasm_input: FuncRef) -> Self { + Self { + phantom_regex: phantom_regex + .iter() + .map(|s| Regex::new(s).unwrap()) + .collect::>(), + phantom_functions: HashSet::new(), + + wasm_input, + + frame: Vec::new(), + } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ phantom_regex; wasm_input ] => + ltac:(M.monadic + (let phantom_regex := M.alloc (| phantom_regex |) in + let wasm_input := M.alloc (| wasm_input |) in + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper" + [ + ("phantom_regex", + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "alloc::string::String" ]; + Ty.function + [ + Ty.tuple + [ Ty.apply (Ty.path "&") [ Ty.path "alloc::string::String" ] ] + ] + (Ty.path "regex::regex::string::Regex") + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "regex::regex::string::Regex"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "alloc::string::String" ], + [], + "map", + [ + Ty.path "regex::regex::string::Regex"; + Ty.function + [ + Ty.tuple + [ Ty.apply (Ty.path "&") [ Ty.path "alloc::string::String" ] ] + ] + (Ty.path "regex::regex::string::Regex") + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "alloc::string::String" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "alloc::string::String"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ M.read (| phantom_regex |) ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let s := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "regex::regex::string::Regex"; + Ty.path "regex::error::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "regex::regex::string::Regex", + "new", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "alloc::string::String", + [], + "deref", + [] + |), + [ M.read (| s |) ] + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |)); + ("phantom_functions", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ Ty.path "u32"; Ty.path "std::hash::random::RandomState" ], + "new", + [] + |), + [] + |)); + ("wasm_input", M.read (| wasm_input |)); + ("frame", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u32"; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + + (* + pub(in crate::runtime::monitor) fn is_in_phantom_function(&self) -> bool { + self.frame.len() > 0 + } + *) + Definition is_in_phantom_function (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + BinOp.Pure.gt + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u32"; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "frame" + |) + ] + |)) + (Value.Integer 0))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_is_in_phantom_function : + M.IsAssociatedFunction Self "is_in_phantom_function" is_in_phantom_function. + + (* + pub(in crate::runtime::monitor) fn is_phantom_function(&self, func_index: u32) -> bool { + self.phantom_functions.contains(&func_index) + } + *) + Definition is_phantom_function (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; func_index ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let func_index := M.alloc (| func_index |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "std::collections::hash::set::HashSet") + [ Ty.path "u32"; Ty.path "std::hash::random::RandomState" ], + "contains", + [ Ty.path "u32" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "phantom_functions" + |); + func_index + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_is_phantom_function : + M.IsAssociatedFunction Self "is_phantom_function" is_phantom_function. + + (* + pub(in crate::runtime::monitor) fn wasm_input_func_idx(&self, module_ref: &ModuleRef) -> u32 { + module_ref.func_index_by_func_ref(&self.wasm_input) + } + *) + Definition wasm_input_func_idx (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; module_ref ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let module_ref := M.alloc (| module_ref |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::module::ModuleInstance", + "func_index_by_func_ref", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::module::ModuleRef", + [], + "deref", + [] + |), + [ M.read (| module_ref |) ] + |); + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "wasm_input" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_wasm_input_func_idx : + M.IsAssociatedFunction Self "wasm_input_func_idx" wasm_input_func_idx. + + (* + pub(in crate::runtime::monitor) fn push_frame(&mut self, sp: u32) { + self.frame.push(sp) + } + *) + Definition push_frame (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; sp ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let sp := M.alloc (| sp |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u32"; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "frame" + |); + M.read (| sp |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_push_frame : M.IsAssociatedFunction Self "push_frame" push_frame. + + (* + pub(in crate::runtime::monitor) fn pop_frame(&mut self) -> Option { + self.frame.pop() + } + *) + Definition pop_frame (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u32"; Ty.path "alloc::alloc::Global" ], + "pop", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "frame" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_pop_frame : M.IsAssociatedFunction Self "pop_frame" pop_frame. + End Impl_delphinus_zkwasm_runtime_monitor_plugins_phantom_PhantomHelper. + + Module Impl_wasmi_monitor_Monitor_for_delphinus_zkwasm_runtime_monitor_plugins_phantom_PhantomHelper. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper". + + (* + fn register_module( + &mut self, + _module: &Module, + module_ref: &ModuleRef, + _entry: &str, + ) -> Result<(), wasmi::Error> { + module_ref + .exports + .borrow() + .iter() + .for_each(|(name, export)| { + if export.as_func().is_some() + && self.phantom_regex.iter().any(|re| re.is_match(name)) + { + self.phantom_functions + .insert(module_ref.func_index_by_func_ref(export.as_func().unwrap())); + } + }); + + Ok(()) + } + *) + Definition register_module (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; _module; module_ref; _entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let _module := M.alloc (| _module |) in + let module_ref := M.alloc (| module_ref |) in + let _entry := M.alloc (| _entry |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::collections::btree::map::Iter") + [ Ty.path "alloc::string::String"; Ty.path "wasmi::module::ExternVal" ], + [], + "for_each", + [ + Ty.function + [ + Ty.tuple + [ + Ty.tuple + [ + Ty.apply (Ty.path "&") [ Ty.path "alloc::string::String" ]; + Ty.apply + (Ty.path "&") + [ Ty.path "wasmi::module::ExternVal" ] + ] + ] + ] + (Ty.tuple []) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "alloc::string::String"; + Ty.path "wasmi::module::ExternVal"; + Ty.path "alloc::alloc::Global" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "core::cell::Ref") + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "alloc::string::String"; + Ty.path "wasmi::module::ExternVal"; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.path "alloc::string::String"; + Ty.path "wasmi::module::ExternVal"; + Ty.path "alloc::alloc::Global" + ] + ], + "borrow", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::module::ModuleRef", + [], + "deref", + [] + |), + [ M.read (| module_ref |) ] + |), + "wasmi::module::ModuleInstance", + "exports" + |) + ] + |) + |) + ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let name := M.copy (| γ0_0 |) in + let export := M.copy (| γ0_1 |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.and (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "wasmi::func::FuncRef" + ] + ], + "is_some", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::module::ExternVal", + "as_func", + [] + |), + [ M.read (| export |) ] + |) + |) + ] + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ + Ty.path + "regex::regex::string::Regex" + ], + [], + "any", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "regex::regex::string::Regex" + ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "regex::regex::string::Regex" + ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "regex::regex::string::Regex"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "phantom_regex" + |) + ] + |) + ] + |) + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let re := + M.copy (| + γ + |) in + M.call_closure (| + M.get_associated_function (| + Ty.path + "regex::regex::string::Regex", + "is_match", + [] + |), + [ + M.read (| + re + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "alloc::string::String", + [], + "deref", + [] + |), + [ + M.read (| + name + |) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::collections::hash::set::HashSet") + [ + Ty.path "u32"; + Ty.path + "std::hash::random::RandomState" + ], + "insert", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "phantom_functions" + |); + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::module::ModuleInstance", + "func_index_by_func_ref", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "wasmi::module::ModuleRef", + [], + "deref", + [] + |), + [ M.read (| module_ref |) ] + |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "wasmi::func::FuncRef" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::module::ExternVal", + "as_func", + [] + |), + [ M.read (| export |) ] + |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "wasmi::monitor::Monitor" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("register_module", InstanceField.Method register_module) ]. + End Impl_wasmi_monitor_Monitor_for_delphinus_zkwasm_runtime_monitor_plugins_phantom_PhantomHelper. + End phantom. + End plugins. + End monitor. +End runtime. diff --git a/CoqOfRust/zkWasm/runtime/monitor/plugins/statistic.v b/CoqOfRust/zkWasm/runtime/monitor/plugins/statistic.v new file mode 100644 index 000000000..2089bb319 --- /dev/null +++ b/CoqOfRust/zkWasm/runtime/monitor/plugins/statistic.v @@ -0,0 +1,1124 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module runtime. + Module monitor. + Module plugins. + Module statistic. + (* StructRecord + { + name := "StatisticPlugin"; + ty_params := []; + fields := + [ + ("phantom_helper", + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper"); + ("observer", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ Ty.path "delphinus_zkwasm::runtime::monitor::observer::Observer" ]; + Ty.path "alloc::alloc::Global" + ]) + ]; + } *) + + Module Impl_delphinus_zkwasm_runtime_monitor_plugins_statistic_StatisticPlugin. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin". + + (* + pub fn new(phantom_regex: &Vec, wasm_input: FuncRef) -> Self { + Self { + phantom_helper: PhantomHelper::new(phantom_regex, wasm_input), + observer: Rc::new(RefCell::new(Observer::default())), + } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ phantom_regex; wasm_input ] => + ltac:(M.monadic + (let phantom_regex := M.alloc (| phantom_regex |) in + let wasm_input := M.alloc (| wasm_input |) in + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin" + [ + ("phantom_helper", + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "new", + [] + |), + [ M.read (| phantom_regex |); M.read (| wasm_input |) ] + |)); + ("observer", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ Ty.path "delphinus_zkwasm::runtime::monitor::observer::Observer" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ Ty.path "delphinus_zkwasm::runtime::monitor::observer::Observer" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.path "delphinus_zkwasm::runtime::monitor::observer::Observer", + [], + "default", + [] + |), + [] + |) + ] + |) + ] + |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + + (* + pub fn expose_observer(&self) -> Rc> { + self.observer.clone() + } + *) + Definition expose_observer (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ Ty.path "delphinus_zkwasm::runtime::monitor::observer::Observer" ]; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + "observer" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_expose_observer : + M.IsAssociatedFunction Self "expose_observer" expose_observer. + End Impl_delphinus_zkwasm_runtime_monitor_plugins_statistic_StatisticPlugin. + + Module Impl_wasmi_monitor_Monitor_for_delphinus_zkwasm_runtime_monitor_plugins_statistic_StatisticPlugin. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin". + + (* + fn register_module( + &mut self, + module: &parity_wasm::elements::Module, + module_ref: &wasmi::ModuleRef, + entry: &str, + ) -> Result<(), wasmi::Error> { + self.phantom_helper + .register_module(module, module_ref, entry)?; + + Ok(()) + } + *) + Definition register_module (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; module; module_ref; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let module := M.alloc (| module |) in + let module_ref := M.alloc (| module_ref |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "wasmi::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "wasmi::monitor::Monitor", + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + [], + "register_module", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + "phantom_helper" + |); + M.read (| module |); + M.read (| module_ref |); + M.read (| entry |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "wasmi::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "wasmi::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn invoke_instruction_post_hook( + &mut self, + fid: u32, + _iid: u32, + _sp: u32, + _allocated_memory_pages: u32, + value_stack: &wasmi::runner::ValueStack, + _function_context: &wasmi::runner::FunctionContext, + _instruction: &wasmi::isa::Instruction, + outcome: &wasmi::runner::InstructionOutcome, + ) { + self.observer.borrow_mut().counter += + !self.phantom_helper.is_in_phantom_function() as usize; + + match outcome { + InstructionOutcome::ExecuteCall(func_ref) => { + if let FuncInstanceInternal::Internal { index, .. } = func_ref.as_internal() { + if self.phantom_helper.is_phantom_function( *index as u32) { + self.observer.borrow_mut().is_in_phantom = true; + + self.phantom_helper.push_frame(value_stack.len() as u32); + } + } + } + InstructionOutcome::Return(drop_keep) => { + if self.phantom_helper.is_phantom_function(fid) { + self.phantom_helper.pop_frame(); + + if !self.phantom_helper.is_in_phantom_function() { + self.observer.borrow_mut().is_in_phantom = false; + + if let Keep::Single(t) = drop_keep.keep { + // I32Const + self.observer.borrow_mut().counter += 1; + // Call wasm_input host function + self.observer.borrow_mut().counter += 1; + // Convert if needed + self.observer.borrow_mut().counter += + (!matches!(t, ValueType::I64)) as usize; + } + // Return + self.observer.borrow_mut().counter += 1; + } + } + } + _ => {} + } + } + *) + Definition invoke_instruction_post_hook (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], + [ + self; + fid; + _iid; + _sp; + _allocated_memory_pages; + value_stack; + _function_context; + _instruction; + outcome + ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let fid := M.alloc (| fid |) in + let _iid := M.alloc (| _iid |) in + let _sp := M.alloc (| _sp |) in + let _allocated_memory_pages := M.alloc (| _allocated_memory_pages |) in + let value_stack := M.alloc (| value_stack |) in + let _function_context := M.alloc (| _function_context |) in + let _instruction := M.alloc (| _instruction |) in + let outcome := M.alloc (| outcome |) in + M.read (| + let _ := + let β := + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "core::cell::RefMut") + [ Ty.path "delphinus_zkwasm::runtime::monitor::observer::Observer" ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + "observer" + |) + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::runtime::monitor::observer::Observer", + "counter" + |) in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + M.rust_cast + (UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "is_in_phantom_function", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + "phantom_helper" + |) + ] + |))) + |) + |) in + M.match_operator (| + outcome, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::runner::InstructionOutcome::ExecuteCall", + 0 + |) in + let func_ref := M.alloc (| γ1_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::func::FuncInstance", + "as_internal", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::func::FuncRef", + [], + "deref", + [] + |), + [ M.read (| func_ref |) ] + |) + ] + |) + |) in + let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "wasmi::func::FuncInstanceInternal::Internal", + "index" + |) in + let index := M.alloc (| γ1_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "is_phantom_function", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + "phantom_helper" + |); + M.rust_cast (M.read (| M.read (| index |) |)) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "core::cell::RefMut") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + "observer" + |) + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::runtime::monitor::observer::Observer", + "is_in_phantom" + |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "push_frame", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + "phantom_helper" + |); + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "len", + [] + |), + [ M.read (| value_stack |) ] + |)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::runner::InstructionOutcome::Return", + 0 + |) in + let drop_keep := M.alloc (| γ1_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "is_phantom_function", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + "phantom_helper" + |); + M.read (| fid |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "pop_frame", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + "phantom_helper" + |) + ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "is_in_phantom_function", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + "phantom_helper" + |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "core::cell::RefMut") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + "observer" + |) + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::runtime::monitor::observer::Observer", + "is_in_phantom" + |), + Value.Bool false + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.SubPointer.get_struct_record_field (| + M.read (| drop_keep |), + "wasmi::isa::DropKeep", + "keep" + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Keep::Single", + 0 + |) in + let t := M.copy (| γ0_0 |) in + let _ := + let β := + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "core::cell::RefMut") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + "observer" + |) + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::runtime::monitor::observer::Observer", + "counter" + |) in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |) in + let _ := + let β := + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "core::cell::RefMut") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + "observer" + |) + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::runtime::monitor::observer::Observer", + "counter" + |) in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |) in + let _ := + let β := + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "core::cell::RefMut") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path + "core::cell::RefCell") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ]; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + "observer" + |) + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::runtime::monitor::observer::Observer", + "counter" + |) in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + M.rust_cast + (UnOp.Pure.not + (M.read (| + M.match_operator (| + t, + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Bool true + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Bool false + |))) + ] + |) + |))) + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + let β := + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "core::cell::RefMut") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ], + [], + "deref_mut", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ], + "borrow_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + "observer" + |) + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::runtime::monitor::observer::Observer", + "counter" + |) in + M.write (| + β, + BinOp.Panic.add (| + Integer.Usize, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "wasmi::monitor::Monitor" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ + ("register_module", InstanceField.Method register_module); + ("invoke_instruction_post_hook", InstanceField.Method invoke_instruction_post_hook) + ]. + End Impl_wasmi_monitor_Monitor_for_delphinus_zkwasm_runtime_monitor_plugins_statistic_StatisticPlugin. + End statistic. + End plugins. + End monitor. +End runtime. diff --git a/CoqOfRust/zkWasm/runtime/monitor/plugins/table/etable.v b/CoqOfRust/zkWasm/runtime/monitor/plugins/table/etable.v new file mode 100644 index 000000000..f595120b1 --- /dev/null +++ b/CoqOfRust/zkWasm/runtime/monitor/plugins/table/etable.v @@ -0,0 +1,611 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module runtime. + Module monitor. + Module plugins. + Module table. + Module etable. + (* StructRecord + { + name := "ETable"; + ty_params := []; + fields := + [ + ("eid", Ty.path "u32"); + ("slices", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "specs::etable::EventTableBackend"; Ty.path "alloc::alloc::Global" + ]); + ("entries", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "specs::etable::EventTableEntry"; Ty.path "alloc::alloc::Global" ]); + ("capacity", Ty.path "u32"); + ("backend", Ty.path "specs::TraceBackend") + ]; + } *) + + Module Impl_delphinus_zkwasm_runtime_monitor_plugins_table_etable_ETable. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable". + + (* + pub(crate) fn new(capacity: u32, backend: TraceBackend) -> Self { + Self { + eid: 0, + slices: Vec::default(), + entries: Vec::with_capacity(capacity as usize), + capacity, + backend, + } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ capacity; backend ] => + ltac:(M.monadic + (let capacity := M.alloc (| capacity |) in + let backend := M.alloc (| backend |) in + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable" + [ + ("eid", Value.Integer 0); + ("slices", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::etable::EventTableBackend"; + Ty.path "alloc::alloc::Global" + ], + [], + "default", + [] + |), + [] + |)); + ("entries", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::etable::EventTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "with_capacity", + [] + |), + [ M.rust_cast (M.read (| capacity |)) ] + |)); + ("capacity", M.read (| capacity |)); + ("backend", M.read (| backend |)) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + + (* + fn flush(&mut self) { + let empty = Vec::with_capacity(self.capacity as usize); + let entries = std::mem::replace(&mut self.entries, empty); + + let event_table = match &self.backend { + TraceBackend::File(write_file_fn) => { + let path = write_file_fn(self.slices.len(), &EventTable::new(entries)); + + EventTableBackend::Json(path) + } + TraceBackend::Memory => EventTableBackend::Memory(EventTable::new(entries)), + }; + + self.slices.push(event_table); + } + *) + Definition flush (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let empty := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::etable::EventTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "with_capacity", + [] + |), + [ + M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "capacity" + |) + |)) + ] + |) + |) in + let entries := + M.alloc (| + M.call_closure (| + M.get_function (| + "core::mem::replace", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::etable::EventTableEntry"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "entries" + |); + M.read (| empty |) + ] + |) + |) in + let event_table := + M.copy (| + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "backend" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "specs::TraceBackend::File", + 0 + |) in + let write_file_fn := M.alloc (| γ1_0 |) in + let path := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("existential predicate with variables", []); + ("existential predicate with variables", []) + ]; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.tuple + [ + Ty.path "usize"; + Ty.apply + (Ty.path "&") + [ Ty.path "specs::etable::EventTable" ] + ] + ], + "call", + [] + |), + [ + M.read (| write_file_fn |); + Value.Tuple + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::etable::EventTableBackend"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "slices" + |) + ] + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::etable::EventTable", + "new", + [] + |), + [ M.read (| entries |) ] + |) + |) + ] + ] + |) + |) in + M.alloc (| + Value.StructTuple + "specs::etable::EventTableBackend::Json" + [ M.read (| path |) ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + Value.StructTuple + "specs::etable::EventTableBackend::Memory" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::etable::EventTable", + "new", + [] + |), + [ M.read (| entries |) ] + |) + ] + |))) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::etable::EventTableBackend"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "slices" + |); + M.read (| event_table |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_flush : M.IsAssociatedFunction Self "flush" flush. + + (* + pub(crate) fn push( + &mut self, + fid: u32, + iid: u32, + sp: u32, + allocated_memory_pages: u32, + last_jump_eid: u32, + step_info: StepInfo, + ) { + if self.entries.len() == self.capacity as usize { + self.flush(); + } + + self.eid += 1; + + let sp = (DEFAULT_VALUE_STACK_LIMIT as u32) + .checked_sub(sp) + .unwrap() + .checked_sub(1) + .unwrap(); + + let eentry = EventTableEntry { + eid: self.eid, + fid, + iid, + sp, + allocated_memory_pages, + last_jump_eid, + step_info, + }; + + self.entries.push(eentry); + } + *) + Definition push (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; fid; iid; sp; allocated_memory_pages; last_jump_eid; step_info ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let fid := M.alloc (| fid |) in + let iid := M.alloc (| iid |) in + let sp := M.alloc (| sp |) in + let allocated_memory_pages := M.alloc (| allocated_memory_pages |) in + let last_jump_eid := M.alloc (| last_jump_eid |) in + let step_info := M.alloc (| step_info |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.eq + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::etable::EventTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "entries" + |) + ] + |)) + (M.rust_cast + (M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "capacity" + |) + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "flush", + [] + |), + [ M.read (| self |) ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + let β := + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "eid" + |) in + M.write (| + β, + BinOp.Panic.add (| Integer.U32, M.read (| β |), Value.Integer 1 |) + |) in + let sp := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.path "u32" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| Ty.path "u32", "checked_sub", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.path "u32" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "u32", + "checked_sub", + [] + |), + [ + M.rust_cast + (M.read (| + M.get_constant (| + "wasmi::runner::DEFAULT_VALUE_STACK_LIMIT" + |) + |)); + M.read (| sp |) + ] + |) + ] + |); + Value.Integer 1 + ] + |) + ] + |) + |) in + let eentry := + M.alloc (| + Value.StructRecord + "specs::etable::EventTableEntry" + [ + ("eid", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "eid" + |) + |)); + ("fid", M.read (| fid |)); + ("iid", M.read (| iid |)); + ("sp", M.read (| sp |)); + ("allocated_memory_pages", M.read (| allocated_memory_pages |)); + ("last_jump_eid", M.read (| last_jump_eid |)); + ("step_info", M.read (| step_info |)) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::etable::EventTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "entries" + |); + M.read (| eentry |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_push : M.IsAssociatedFunction Self "push" push. + + (* + pub(super) fn entries(&self) -> &[EventTableEntry] { + &self.entries + } + *) + Definition entries (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "specs::etable::EventTableEntry"; Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "entries" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_entries : M.IsAssociatedFunction Self "entries" entries. + + (* + pub(crate) fn entries_mut(&mut self) -> &mut Vec { + &mut self.entries + } + *) + Definition entries_mut (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "entries" + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_entries_mut : + M.IsAssociatedFunction Self "entries_mut" entries_mut. + + (* + pub fn finalized(mut self) -> Vec { + self.flush(); + + self.slices + } + *) + Definition finalized (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "flush", + [] + |), + [ self ] + |) + |) in + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "slices" + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_finalized : M.IsAssociatedFunction Self "finalized" finalized. + End Impl_delphinus_zkwasm_runtime_monitor_plugins_table_etable_ETable. + End etable. + End table. + End plugins. + End monitor. +End runtime. diff --git a/CoqOfRust/zkWasm/runtime/monitor/plugins/table/instruction.v b/CoqOfRust/zkWasm/runtime/monitor/plugins/table/instruction.v new file mode 100644 index 000000000..33f9145aa --- /dev/null +++ b/CoqOfRust/zkWasm/runtime/monitor/plugins/table/instruction.v @@ -0,0 +1,17715 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module runtime. + Module monitor. + Module plugins. + Module table. + Module instruction. + (* StructRecord + { + name := "FuncDesc"; + ty_params := []; + fields := + [ + ("ftype", Ty.path "specs::types::FunctionType"); + ("signature", Ty.path "wasmi::types::Signature") + ]; + } *) + + Module Impl_core_fmt_Debug_for_delphinus_zkwasm_runtime_monitor_plugins_table_instruction_FuncDesc. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::FuncDesc". + + (* Debug *) + Definition fmt (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; f ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let f := M.alloc (| f |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Formatter", + "debug_struct_field2_finish", + [] + |), + [ + M.read (| f |); + M.read (| Value.String "FuncDesc" |); + M.read (| Value.String "ftype" |); + (* Unsize *) + M.pointer_coercion + (M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::FuncDesc", + "ftype" + |)); + M.read (| Value.String "signature" |); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::FuncDesc", + "signature" + |) + |)) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "core::fmt::Debug" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("fmt", InstanceField.Method fmt) ]. + End Impl_core_fmt_Debug_for_delphinus_zkwasm_runtime_monitor_plugins_table_instruction_FuncDesc. + + (* StructTuple + { + name := "PhantomFunction"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_runtime_monitor_plugins_table_instruction_PhantomFunction. + Definition Self : Ty.t := + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::PhantomFunction". + + (* + pub fn build_phantom_function_instructions( + sig: &Signature, + // Wasm Image Function Id + wasm_input_function_idx: u32, + ) -> Vec> { + let mut instructions = vec![]; + + if sig.return_type().is_some() { + instructions.push(Instruction::I32Const(0)); + + instructions.push(Instruction::Call(wasm_input_function_idx)); + + if sig.return_type() != Some(wasmi::ValueType::I64) { + instructions.push(Instruction::I32WrapI64); + } + } + + instructions.push(Instruction::Return(DropKeep { + drop: sig.params().len() as u32, + keep: if let Some(t) = sig.return_type() { + Keep::Single(t.into_elements()) + } else { + Keep::None + }, + })); + + instructions + } + *) + Definition build_phantom_function_instructions (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ sig; wasm_input_function_idx ] => + ltac:(M.monadic + (let sig := M.alloc (| sig |) in + let wasm_input_function_idx := M.alloc (| wasm_input_function_idx |) in + M.read (| + let instructions := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "wasmi::isa::Instruction"; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi_core::value::ValueType" ], + "is_some", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::types::Signature", + "return_type", + [] + |), + [ M.read (| sig |) ] + |) + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "wasmi::isa::Instruction"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + instructions; + Value.StructTuple + "wasmi::isa::Instruction::I32Const" + [ Value.Integer 0 ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "wasmi::isa::Instruction"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + instructions; + Value.StructTuple + "wasmi::isa::Instruction::Call" + [ M.read (| wasm_input_function_idx |) ] + ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi_core::value::ValueType" ], + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi_core::value::ValueType" ] + ], + "ne", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::types::Signature", + "return_type", + [] + |), + [ M.read (| sig |) ] + |) + |); + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "wasmi_core::value::ValueType::I64" + [] + ] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "wasmi::isa::Instruction"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + instructions; + Value.StructTuple + "wasmi::isa::Instruction::I32WrapI64" + [] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "wasmi::isa::Instruction"; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + instructions; + Value.StructTuple + "wasmi::isa::Instruction::Return" + [ + Value.StructRecord + "wasmi::isa::DropKeep" + [ + ("drop", + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "wasmi_core::value::ValueType" ], + "len", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::types::Signature", + "params", + [] + |), + [ M.read (| sig |) ] + |) + ] + |))); + ("keep", + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::types::Signature", + "return_type", + [] + |), + [ M.read (| sig |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let t := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructTuple + "wasmi::isa::Keep::Single" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi_core::value::ValueType", + "into_elements", + [] + |), + [ M.read (| t |) ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple "wasmi::isa::Keep::None" [] + |))) + ] + |) + |)) + ] + ] + ] + |) + |) in + instructions + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_build_phantom_function_instructions : + M.IsAssociatedFunction + Self + "build_phantom_function_instructions" + build_phantom_function_instructions. + End Impl_delphinus_zkwasm_runtime_monitor_plugins_table_instruction_PhantomFunction. + + (* Trait *) + (* Empty module 'InstructionIntoOpcode' *) + + Module Impl_delphinus_zkwasm_runtime_monitor_plugins_table_instruction_InstructionIntoOpcode_for_wasmi_isa_Instruction. + Definition Self : Ty.t := Ty.path "wasmi::isa::Instruction". + + (* + fn into_opcode<'b>(self, function_mapping: &impl Fn(u32) -> &'b FuncDesc) -> Opcode { + match self { + Instruction::GetLocal(offset, typ) => Opcode::LocalGet { + offset: offset as u64, + vtype: typ.into(), + }, + Instruction::SetLocal(offset, typ) => Opcode::LocalSet { + offset: offset as u64, + vtype: typ.into(), + }, + Instruction::TeeLocal(offset, typ) => Opcode::LocalTee { + offset: offset as u64, + vtype: typ.into(), + }, + Instruction::Br(Target { dst_pc, drop_keep }) => Opcode::Br { + drop: drop_keep.drop, + keep: if let Keep::Single(t) = drop_keep.keep { + vec![t.into()] + } else { + vec![] + }, + dst_pc, + }, + Instruction::BrIfEqz(Target { dst_pc, drop_keep }) => Opcode::BrIfEqz { + drop: drop_keep.drop, + keep: if let Keep::Single(t) = drop_keep.keep { + vec![t.into()] + } else { + vec![] + }, + dst_pc, + }, + Instruction::BrIfNez(Target { dst_pc, drop_keep }) => Opcode::BrIf { + drop: drop_keep.drop, + keep: if let Keep::Single(t) = drop_keep.keep { + vec![t.into()] + } else { + vec![] + }, + dst_pc, + }, + Instruction::BrTable(targets) => Opcode::BrTable { + targets: targets + .stream + .iter() + .map(|t| { + if let InstructionInternal::BrTableTarget(target) = t { + let keep_type = match target.drop_keep.keep { + Keep::None => vec![], + Keep::Single(t) => vec![t.into()], + }; + + BrTarget { + drop: target.drop_keep.drop, + keep: keep_type, + dst_pc: target.dst_pc, + } + } else { + unreachable!() + } + }) + .collect(), + }, + Instruction::Unreachable => Opcode::Unreachable, + Instruction::Return(drop_keep) => Opcode::Return { + drop: drop_keep.drop, + keep: if let Keep::Single(t) = drop_keep.keep { + vec![t.into()] + } else { + vec![] + }, + }, + Instruction::Call(func_index) => { + let func_desc = function_mapping(func_index); + + match &func_desc.ftype { + specs::types::FunctionType::WasmFunction => Opcode::Call { index: func_index }, + specs::types::FunctionType::HostFunction { + plugin, + function_index, + function_name, + op_index_in_plugin, + } => Opcode::InternalHostCall { + plugin: *plugin, + function_index: *function_index, + function_name: function_name.clone(), + op_index_in_plugin: *op_index_in_plugin, + }, + specs::types::FunctionType::HostFunctionExternal { op, sig, .. } => { + Opcode::ExternalHostCall { op: *op, sig: *sig } + } + } + } + Instruction::CallIndirect(idx) => Opcode::CallIndirect { type_idx: idx }, + Instruction::Drop => Opcode::Drop, + Instruction::Select(_) => Opcode::Select, + Instruction::GetGlobal(idx) => Opcode::GlobalGet { idx: idx as u64 }, + Instruction::SetGlobal(idx) => Opcode::GlobalSet { idx: idx as u64 }, + Instruction::I32Load(offset) => Opcode::Load { + offset, + vtype: VarType::I32, + size: MemoryReadSize::U32, + }, + Instruction::I64Load(offset) => Opcode::Load { + offset, + vtype: VarType::I64, + size: MemoryReadSize::I64, + }, + Instruction::F32Load(_) => todo!(), + Instruction::F64Load(_) => todo!(), + Instruction::I32Load8S(offset) => Opcode::Load { + offset, + vtype: VarType::I32, + size: MemoryReadSize::S8, + }, + Instruction::I32Load8U(offset) => Opcode::Load { + offset, + vtype: VarType::I32, + size: MemoryReadSize::U8, + }, + Instruction::I32Load16S(offset) => Opcode::Load { + offset, + vtype: VarType::I32, + size: MemoryReadSize::S16, + }, + Instruction::I32Load16U(offset) => Opcode::Load { + offset, + vtype: VarType::I32, + size: MemoryReadSize::U16, + }, + Instruction::I64Load8S(offset) => Opcode::Load { + offset, + vtype: VarType::I64, + size: MemoryReadSize::S8, + }, + Instruction::I64Load8U(offset) => Opcode::Load { + offset, + vtype: VarType::I64, + size: MemoryReadSize::U8, + }, + Instruction::I64Load16S(offset) => Opcode::Load { + offset, + vtype: VarType::I64, + size: MemoryReadSize::S16, + }, + Instruction::I64Load16U(offset) => Opcode::Load { + offset, + vtype: VarType::I64, + size: MemoryReadSize::U16, + }, + Instruction::I64Load32S(offset) => Opcode::Load { + offset, + vtype: VarType::I64, + size: MemoryReadSize::S32, + }, + Instruction::I64Load32U(offset) => Opcode::Load { + offset, + vtype: VarType::I64, + size: MemoryReadSize::U32, + }, + Instruction::I32Store(offset) => Opcode::Store { + offset, + vtype: VarType::I32, + size: MemoryStoreSize::Byte32, + }, + Instruction::I64Store(offset) => Opcode::Store { + offset, + vtype: VarType::I64, + size: MemoryStoreSize::Byte64, + }, + Instruction::F32Store(_) => todo!(), + Instruction::F64Store(_) => todo!(), + Instruction::I32Store8(offset) => Opcode::Store { + offset, + vtype: VarType::I32, + size: MemoryStoreSize::Byte8, + }, + Instruction::I32Store16(offset) => Opcode::Store { + offset, + vtype: VarType::I32, + size: MemoryStoreSize::Byte16, + }, + Instruction::I64Store8(offset) => Opcode::Store { + offset, + vtype: VarType::I64, + size: MemoryStoreSize::Byte8, + }, + Instruction::I64Store16(offset) => Opcode::Store { + offset, + vtype: VarType::I64, + size: MemoryStoreSize::Byte16, + }, + Instruction::I64Store32(offset) => Opcode::Store { + offset, + vtype: VarType::I64, + size: MemoryStoreSize::Byte32, + }, + Instruction::CurrentMemory => Opcode::MemorySize, + Instruction::GrowMemory => Opcode::MemoryGrow, + Instruction::I32Const(v) => Opcode::Const { + vtype: VarType::I32, + value: v as u32 as u64, + }, + Instruction::I64Const(v) => Opcode::Const { + vtype: VarType::I64, + value: v as u64, + }, + Instruction::F32Const(_) => todo!(), + Instruction::F64Const(_) => todo!(), + Instruction::I32Eqz => Opcode::Test { + class: TestOp::Eqz, + vtype: VarType::I32, + }, + Instruction::I32Eq => Opcode::Rel { + class: RelOp::Eq, + vtype: VarType::I32, + }, + Instruction::I32Ne => Opcode::Rel { + class: RelOp::Ne, + vtype: VarType::I32, + }, + Instruction::I32LtS => Opcode::Rel { + class: RelOp::SignedLt, + vtype: VarType::I32, + }, + Instruction::I32LtU => Opcode::Rel { + class: RelOp::UnsignedLt, + vtype: VarType::I32, + }, + Instruction::I32GtS => Opcode::Rel { + class: RelOp::SignedGt, + vtype: VarType::I32, + }, + Instruction::I32GtU => Opcode::Rel { + class: RelOp::UnsignedGt, + vtype: VarType::I32, + }, + Instruction::I32LeS => Opcode::Rel { + class: RelOp::SignedLe, + vtype: VarType::I32, + }, + Instruction::I32LeU => Opcode::Rel { + class: RelOp::UnsignedLe, + vtype: VarType::I32, + }, + Instruction::I32GeS => Opcode::Rel { + class: RelOp::SignedGe, + vtype: VarType::I32, + }, + Instruction::I32GeU => Opcode::Rel { + class: RelOp::UnsignedGe, + vtype: VarType::I32, + }, + Instruction::I64Eqz => Opcode::Test { + class: TestOp::Eqz, + vtype: VarType::I64, + }, + Instruction::I64Eq => Opcode::Rel { + class: RelOp::Eq, + vtype: VarType::I64, + }, + Instruction::I64Ne => Opcode::Rel { + class: RelOp::Ne, + vtype: VarType::I64, + }, + Instruction::I64LtS => Opcode::Rel { + class: RelOp::SignedLt, + vtype: VarType::I64, + }, + Instruction::I64LtU => Opcode::Rel { + class: RelOp::UnsignedLt, + vtype: VarType::I64, + }, + Instruction::I64GtS => Opcode::Rel { + class: RelOp::SignedGt, + vtype: VarType::I64, + }, + Instruction::I64GtU => Opcode::Rel { + class: RelOp::UnsignedGt, + vtype: VarType::I64, + }, + Instruction::I64LeS => Opcode::Rel { + class: RelOp::SignedLe, + vtype: VarType::I64, + }, + Instruction::I64LeU => Opcode::Rel { + class: RelOp::UnsignedLe, + vtype: VarType::I64, + }, + Instruction::I64GeS => Opcode::Rel { + class: RelOp::SignedGe, + vtype: VarType::I64, + }, + Instruction::I64GeU => Opcode::Rel { + class: RelOp::UnsignedGe, + vtype: VarType::I64, + }, + Instruction::F32Eq => todo!(), + Instruction::F32Ne => todo!(), + Instruction::F32Lt => todo!(), + Instruction::F32Gt => todo!(), + Instruction::F32Le => todo!(), + Instruction::F32Ge => todo!(), + Instruction::F64Eq => todo!(), + Instruction::F64Ne => todo!(), + Instruction::F64Lt => todo!(), + Instruction::F64Gt => todo!(), + Instruction::F64Le => todo!(), + Instruction::F64Ge => todo!(), + Instruction::I32Clz => Opcode::Unary { + class: UnaryOp::Clz, + vtype: VarType::I32, + }, + Instruction::I32Ctz => Opcode::Unary { + class: UnaryOp::Ctz, + vtype: VarType::I32, + }, + Instruction::I32Popcnt => Opcode::Unary { + class: UnaryOp::Popcnt, + vtype: VarType::I32, + }, + Instruction::I32Add => Opcode::Bin { + class: BinOp::Add, + vtype: VarType::I32, + }, + Instruction::I32Sub => Opcode::Bin { + class: BinOp::Sub, + vtype: VarType::I32, + }, + Instruction::I32Mul => Opcode::Bin { + class: BinOp::Mul, + vtype: VarType::I32, + }, + Instruction::I32DivS => Opcode::Bin { + class: BinOp::SignedDiv, + vtype: VarType::I32, + }, + Instruction::I32DivU => Opcode::Bin { + class: BinOp::UnsignedDiv, + vtype: VarType::I32, + }, + Instruction::I32RemS => Opcode::Bin { + class: BinOp::SignedRem, + vtype: VarType::I32, + }, + Instruction::I32RemU => Opcode::Bin { + class: BinOp::UnsignedRem, + vtype: VarType::I32, + }, + Instruction::I32And => Opcode::BinBit { + class: BitOp::And, + vtype: VarType::I32, + }, + Instruction::I32Or => Opcode::BinBit { + class: BitOp::Or, + vtype: VarType::I32, + }, + Instruction::I32Xor => Opcode::BinBit { + class: BitOp::Xor, + vtype: VarType::I32, + }, + Instruction::I32Shl => Opcode::BinShift { + class: ShiftOp::Shl, + vtype: VarType::I32, + }, + Instruction::I32ShrS => Opcode::BinShift { + class: ShiftOp::SignedShr, + vtype: VarType::I32, + }, + Instruction::I32ShrU => Opcode::BinShift { + class: ShiftOp::UnsignedShr, + vtype: VarType::I32, + }, + Instruction::I32Rotl => Opcode::BinShift { + class: ShiftOp::Rotl, + vtype: VarType::I32, + }, + Instruction::I32Rotr => Opcode::BinShift { + class: ShiftOp::Rotr, + vtype: VarType::I32, + }, + Instruction::I64Clz => Opcode::Unary { + class: UnaryOp::Clz, + vtype: VarType::I64, + }, + Instruction::I64Ctz => Opcode::Unary { + class: UnaryOp::Ctz, + vtype: VarType::I64, + }, + Instruction::I64Popcnt => Opcode::Unary { + class: UnaryOp::Popcnt, + vtype: VarType::I64, + }, + Instruction::I64Add => Opcode::Bin { + class: BinOp::Add, + vtype: VarType::I64, + }, + Instruction::I64Sub => Opcode::Bin { + class: BinOp::Sub, + vtype: VarType::I64, + }, + Instruction::I64Mul => Opcode::Bin { + class: BinOp::Mul, + vtype: VarType::I64, + }, + Instruction::I64DivS => Opcode::Bin { + class: BinOp::SignedDiv, + vtype: VarType::I64, + }, + Instruction::I64DivU => Opcode::Bin { + class: BinOp::UnsignedDiv, + vtype: VarType::I64, + }, + Instruction::I64RemS => Opcode::Bin { + class: BinOp::SignedRem, + vtype: VarType::I64, + }, + Instruction::I64RemU => Opcode::Bin { + class: BinOp::UnsignedRem, + vtype: VarType::I64, + }, + Instruction::I64And => Opcode::BinBit { + class: BitOp::And, + vtype: VarType::I64, + }, + Instruction::I64Or => Opcode::BinBit { + class: BitOp::Or, + vtype: VarType::I64, + }, + Instruction::I64Xor => Opcode::BinBit { + class: BitOp::Xor, + vtype: VarType::I64, + }, + Instruction::I64Shl => Opcode::BinShift { + class: ShiftOp::Shl, + vtype: VarType::I64, + }, + Instruction::I64ShrS => Opcode::BinShift { + class: ShiftOp::SignedShr, + vtype: VarType::I64, + }, + Instruction::I64ShrU => Opcode::BinShift { + class: ShiftOp::UnsignedShr, + vtype: VarType::I64, + }, + Instruction::I64Rotl => Opcode::BinShift { + class: ShiftOp::Rotl, + vtype: VarType::I64, + }, + Instruction::I64Rotr => Opcode::BinShift { + class: ShiftOp::Rotr, + vtype: VarType::I64, + }, + Instruction::F32Abs => todo!(), + Instruction::F32Neg => todo!(), + Instruction::F32Ceil => todo!(), + Instruction::F32Floor => todo!(), + Instruction::F32Trunc => todo!(), + Instruction::F32Nearest => todo!(), + Instruction::F32Sqrt => todo!(), + Instruction::F32Add => todo!(), + Instruction::F32Sub => todo!(), + Instruction::F32Mul => todo!(), + Instruction::F32Div => todo!(), + Instruction::F32Min => todo!(), + Instruction::F32Max => todo!(), + Instruction::F32Copysign => todo!(), + Instruction::F64Abs => todo!(), + Instruction::F64Neg => todo!(), + Instruction::F64Ceil => todo!(), + Instruction::F64Floor => todo!(), + Instruction::F64Trunc => todo!(), + Instruction::F64Nearest => todo!(), + Instruction::F64Sqrt => todo!(), + Instruction::F64Add => todo!(), + Instruction::F64Sub => todo!(), + Instruction::F64Mul => todo!(), + Instruction::F64Div => todo!(), + Instruction::F64Min => todo!(), + Instruction::F64Max => todo!(), + Instruction::F64Copysign => todo!(), + Instruction::I32WrapI64 => Opcode::Conversion { + class: ConversionOp::I32WrapI64, + }, + Instruction::I32TruncSF32 => todo!(), + Instruction::I32TruncUF32 => todo!(), + Instruction::I32TruncSF64 => todo!(), + Instruction::I32TruncUF64 => todo!(), + Instruction::I64ExtendSI32 => Opcode::Conversion { + class: ConversionOp::I64ExtendI32s, + }, + Instruction::I64ExtendUI32 => Opcode::Conversion { + class: ConversionOp::I64ExtendI32u, + }, + Instruction::I64TruncSF32 => todo!(), + Instruction::I64TruncUF32 => todo!(), + Instruction::I64TruncSF64 => todo!(), + Instruction::I64TruncUF64 => todo!(), + Instruction::F32ConvertSI32 => todo!(), + Instruction::F32ConvertUI32 => todo!(), + Instruction::F32ConvertSI64 => todo!(), + Instruction::F32ConvertUI64 => todo!(), + Instruction::F32DemoteF64 => todo!(), + Instruction::F64ConvertSI32 => todo!(), + Instruction::F64ConvertUI32 => todo!(), + Instruction::F64ConvertSI64 => todo!(), + Instruction::F64ConvertUI64 => todo!(), + Instruction::F64PromoteF32 => todo!(), + Instruction::I32ReinterpretF32 => todo!(), + Instruction::I64ReinterpretF64 => todo!(), + Instruction::F32ReinterpretI32 => todo!(), + Instruction::F64ReinterpretI64 => todo!(), + Instruction::I32Extend8S => Opcode::Conversion { + class: ConversionOp::I32Extend8S, + }, + Instruction::I32Extend16S => Opcode::Conversion { + class: ConversionOp::I32Extend16S, + }, + Instruction::I64Extend8S => Opcode::Conversion { + class: ConversionOp::I64Extend8S, + }, + Instruction::I64Extend16S => Opcode::Conversion { + class: ConversionOp::I64Extend16S, + }, + Instruction::I64Extend32S => Opcode::Conversion { + class: ConversionOp::I64Extend32S, + }, + } + } + *) + Definition into_opcode (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ impl_Fn_u32__arrow__'b_FuncDesc ], [ self; function_mapping ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let function_mapping := M.alloc (| function_mapping |) in + M.read (| + M.match_operator (| + self, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::GetLocal", + 0 + |) in + let γ0_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::GetLocal", + 1 + |) in + let offset := M.copy (| γ0_0 |) in + let typ := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::LocalGet" + [ + ("offset", M.rust_cast (M.read (| offset |))); + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "parity_wasm::elements::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ M.read (| typ |) ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::SetLocal", + 0 + |) in + let γ0_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::SetLocal", + 1 + |) in + let offset := M.copy (| γ0_0 |) in + let typ := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::LocalSet" + [ + ("offset", M.rust_cast (M.read (| offset |))); + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "parity_wasm::elements::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ M.read (| typ |) ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::TeeLocal", + 0 + |) in + let γ0_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::TeeLocal", + 1 + |) in + let offset := M.copy (| γ0_0 |) in + let typ := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::LocalTee" + [ + ("offset", M.rust_cast (M.read (| offset |))); + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "parity_wasm::elements::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ M.read (| typ |) ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::Br", + 0 + |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "wasmi::isa::Target", + "dst_pc" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "wasmi::isa::Target", + "drop_keep" + |) in + let dst_pc := M.copy (| γ1_0 |) in + let drop_keep := M.copy (| γ1_1 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Br" + [ + ("drop", + M.read (| + M.SubPointer.get_struct_record_field (| + drop_keep, + "wasmi::isa::DropKeep", + "drop" + |) + |)); + ("keep", + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.SubPointer.get_struct_record_field (| + drop_keep, + "wasmi::isa::DropKeep", + "keep" + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Keep::Single", + 0 + |) in + let t := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::types::ValueType" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.path + "specs::types::ValueType" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ + Ty.path + "specs::types::ValueType" + ], + "into", + [] + |), + [ M.read (| t |) ] + |) + ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |))) + ] + |) + |)); + ("dst_pc", M.read (| dst_pc |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::BrIfEqz", + 0 + |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "wasmi::isa::Target", + "dst_pc" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "wasmi::isa::Target", + "drop_keep" + |) in + let dst_pc := M.copy (| γ1_0 |) in + let drop_keep := M.copy (| γ1_1 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::BrIfEqz" + [ + ("drop", + M.read (| + M.SubPointer.get_struct_record_field (| + drop_keep, + "wasmi::isa::DropKeep", + "drop" + |) + |)); + ("keep", + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.SubPointer.get_struct_record_field (| + drop_keep, + "wasmi::isa::DropKeep", + "keep" + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Keep::Single", + 0 + |) in + let t := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::types::ValueType" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.path + "specs::types::ValueType" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ + Ty.path + "specs::types::ValueType" + ], + "into", + [] + |), + [ M.read (| t |) ] + |) + ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |))) + ] + |) + |)); + ("dst_pc", M.read (| dst_pc |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::BrIfNez", + 0 + |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "wasmi::isa::Target", + "dst_pc" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "wasmi::isa::Target", + "drop_keep" + |) in + let dst_pc := M.copy (| γ1_0 |) in + let drop_keep := M.copy (| γ1_1 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::BrIf" + [ + ("drop", + M.read (| + M.SubPointer.get_struct_record_field (| + drop_keep, + "wasmi::isa::DropKeep", + "drop" + |) + |)); + ("keep", + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.SubPointer.get_struct_record_field (| + drop_keep, + "wasmi::isa::DropKeep", + "keep" + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Keep::Single", + 0 + |) in + let t := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::types::ValueType" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.path + "specs::types::ValueType" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ + Ty.path + "specs::types::ValueType" + ], + "into", + [] + |), + [ M.read (| t |) ] + |) + ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |))) + ] + |) + |)); + ("dst_pc", M.read (| dst_pc |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::BrTable", + 0 + |) in + let targets := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::BrTable" + [ + ("targets", + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::iter::adapters::map::Map") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "wasmi::isa::InstructionInternal" ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "wasmi::isa::InstructionInternal" ] + ] + ] + (Ty.path "specs::itable::BrTarget") + ], + [], + "collect", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::itable::BrTarget"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "wasmi::isa::InstructionInternal" ], + [], + "map", + [ + Ty.path "specs::itable::BrTarget"; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "wasmi::isa::InstructionInternal" + ] + ] + ] + (Ty.path "specs::itable::BrTarget") + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "wasmi::isa::InstructionInternal" ], + "iter", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + targets, + "wasmi::isa::BrTargets", + "stream" + |) + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let t := M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := t in + let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::InstructionInternal::BrTableTarget", + 0 + |) in + let target := + M.alloc (| γ1_0 |) in + let keep_type := + M.copy (| + M.match_operator (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| target |), + "wasmi::isa::Target", + "drop_keep" + |), + "wasmi::isa::DropKeep", + "keep" + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Keep::Single", + 0 + |) in + let t := + M.copy (| + γ0_0 + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "slice") + [ + Ty.path + "specs::types::ValueType" + ], + "into_vec", + [ + Ty.path + "alloc::alloc::Global" + ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::boxed::Box") + [ + Ty.apply + (Ty.path + "array") + [ + Ty.path + "specs::types::ValueType" + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ + Ty.path + "specs::types::ValueType" + ], + "into", + [] + |), + [ + M.read (| + t + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |))) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "specs::itable::BrTarget" + [ + ("drop", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| + target + |), + "wasmi::isa::Target", + "drop_keep" + |), + "wasmi::isa::DropKeep", + "drop" + |) + |)); + ("keep", + M.read (| + keep_type + |)); + ("dst_pc", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| + target + |), + "wasmi::isa::Target", + "dst_pc" + |) + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic", + [] + |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple "specs::itable::Opcode::Unreachable" [] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::Return", + 0 + |) in + let drop_keep := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Return" + [ + ("drop", + M.read (| + M.SubPointer.get_struct_record_field (| + drop_keep, + "wasmi::isa::DropKeep", + "drop" + |) + |)); + ("keep", + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.SubPointer.get_struct_record_field (| + drop_keep, + "wasmi::isa::DropKeep", + "keep" + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Keep::Single", + 0 + |) in + let t := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::types::ValueType" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.path + "specs::types::ValueType" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ + Ty.path + "specs::types::ValueType" + ], + "into", + [] + |), + [ M.read (| t |) ] + |) + ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |))) + ] + |) + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::Call", + 0 + |) in + let func_index := M.copy (| γ0_0 |) in + let func_desc := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::function::Fn", + impl_Fn_u32__arrow__'b_FuncDesc, + [ Ty.tuple [ Ty.path "u32" ] ], + "call", + [] + |), + [ + M.read (| function_mapping |); + Value.Tuple [ M.read (| func_index |) ] + ] + |) + |) in + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| func_desc |), + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::FuncDesc", + "ftype" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Call" + [ ("index", M.read (| func_index |)) ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::types::FunctionType::HostFunction", + "plugin" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::types::FunctionType::HostFunction", + "function_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::types::FunctionType::HostFunction", + "function_name" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::types::FunctionType::HostFunction", + "op_index_in_plugin" + |) in + let plugin := M.alloc (| γ1_0 |) in + let function_index := M.alloc (| γ1_1 |) in + let function_name := M.alloc (| γ1_2 |) in + let op_index_in_plugin := M.alloc (| γ1_3 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::InternalHostCall" + [ + ("plugin", M.read (| M.read (| plugin |) |)); + ("function_index", + M.read (| M.read (| function_index |) |)); + ("function_name", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "alloc::string::String", + [], + "clone", + [] + |), + [ M.read (| function_name |) ] + |)); + ("op_index_in_plugin", + M.read (| M.read (| op_index_in_plugin |) |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::types::FunctionType::HostFunctionExternal", + "op" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::types::FunctionType::HostFunctionExternal", + "sig" + |) in + let op := M.alloc (| γ1_0 |) in + let sig := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::ExternalHostCall" + [ + ("op", M.read (| M.read (| op |) |)); + ("sig", M.read (| M.read (| sig |) |)) + ] + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::CallIndirect", + 0 + |) in + let idx := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::CallIndirect" + [ ("type_idx", M.read (| idx |)) ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "specs::itable::Opcode::Drop" [] |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::Select", + 0 + |) in + M.alloc (| Value.StructTuple "specs::itable::Opcode::Select" [] |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::GetGlobal", + 0 + |) in + let idx := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::GlobalGet" + [ ("idx", M.rust_cast (M.read (| idx |))) ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::SetGlobal", + 0 + |) in + let idx := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::GlobalSet" + [ ("idx", M.rust_cast (M.read (| idx |))) ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Load", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Load" + [ + ("offset", M.read (| offset |)); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []); + ("size", + Value.StructTuple "specs::mtable::MemoryReadSize::U32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Load", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Load" + [ + ("offset", M.read (| offset |)); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []); + ("size", + Value.StructTuple "specs::mtable::MemoryReadSize::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::F32Load", + 0 + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::F64Load", + 0 + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Load8S", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Load" + [ + ("offset", M.read (| offset |)); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []); + ("size", Value.StructTuple "specs::mtable::MemoryReadSize::S8" []) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Load8U", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Load" + [ + ("offset", M.read (| offset |)); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []); + ("size", Value.StructTuple "specs::mtable::MemoryReadSize::U8" []) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Load16S", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Load" + [ + ("offset", M.read (| offset |)); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []); + ("size", + Value.StructTuple "specs::mtable::MemoryReadSize::S16" []) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Load16U", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Load" + [ + ("offset", M.read (| offset |)); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []); + ("size", + Value.StructTuple "specs::mtable::MemoryReadSize::U16" []) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Load8S", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Load" + [ + ("offset", M.read (| offset |)); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []); + ("size", Value.StructTuple "specs::mtable::MemoryReadSize::S8" []) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Load8U", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Load" + [ + ("offset", M.read (| offset |)); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []); + ("size", Value.StructTuple "specs::mtable::MemoryReadSize::U8" []) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Load16S", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Load" + [ + ("offset", M.read (| offset |)); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []); + ("size", + Value.StructTuple "specs::mtable::MemoryReadSize::S16" []) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Load16U", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Load" + [ + ("offset", M.read (| offset |)); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []); + ("size", + Value.StructTuple "specs::mtable::MemoryReadSize::U16" []) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Load32S", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Load" + [ + ("offset", M.read (| offset |)); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []); + ("size", + Value.StructTuple "specs::mtable::MemoryReadSize::S32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Load32U", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Load" + [ + ("offset", M.read (| offset |)); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []); + ("size", + Value.StructTuple "specs::mtable::MemoryReadSize::U32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Store", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Store" + [ + ("offset", M.read (| offset |)); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []); + ("size", + Value.StructTuple "specs::mtable::MemoryStoreSize::Byte32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Store", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Store" + [ + ("offset", M.read (| offset |)); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []); + ("size", + Value.StructTuple "specs::mtable::MemoryStoreSize::Byte64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::F32Store", + 0 + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::F64Store", + 0 + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Store8", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Store" + [ + ("offset", M.read (| offset |)); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []); + ("size", + Value.StructTuple "specs::mtable::MemoryStoreSize::Byte8" []) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Store16", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Store" + [ + ("offset", M.read (| offset |)); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []); + ("size", + Value.StructTuple "specs::mtable::MemoryStoreSize::Byte16" []) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Store8", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Store" + [ + ("offset", M.read (| offset |)); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []); + ("size", + Value.StructTuple "specs::mtable::MemoryStoreSize::Byte8" []) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Store16", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Store" + [ + ("offset", M.read (| offset |)); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []); + ("size", + Value.StructTuple "specs::mtable::MemoryStoreSize::Byte16" []) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Store32", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Store" + [ + ("offset", M.read (| offset |)); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []); + ("size", + Value.StructTuple "specs::mtable::MemoryStoreSize::Byte32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple "specs::itable::Opcode::MemorySize" [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple "specs::itable::Opcode::MemoryGrow" [] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Const", + 0 + |) in + let v := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Const" + [ + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []); + ("value", M.rust_cast (M.rust_cast (M.read (| v |)))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Const", + 0 + |) in + let v := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Const" + [ + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []); + ("value", M.rust_cast (M.read (| v |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::F32Const", + 0 + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::F64Const", + 0 + |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Test" + [ + ("class", Value.StructTuple "specs::itable::TestOp::Eqz" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Rel" + [ + ("class", Value.StructTuple "specs::itable::RelOp::Eq" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Rel" + [ + ("class", Value.StructTuple "specs::itable::RelOp::Ne" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Rel" + [ + ("class", Value.StructTuple "specs::itable::RelOp::SignedLt" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Rel" + [ + ("class", + Value.StructTuple "specs::itable::RelOp::UnsignedLt" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Rel" + [ + ("class", Value.StructTuple "specs::itable::RelOp::SignedGt" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Rel" + [ + ("class", + Value.StructTuple "specs::itable::RelOp::UnsignedGt" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Rel" + [ + ("class", Value.StructTuple "specs::itable::RelOp::SignedLe" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Rel" + [ + ("class", + Value.StructTuple "specs::itable::RelOp::UnsignedLe" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Rel" + [ + ("class", Value.StructTuple "specs::itable::RelOp::SignedGe" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Rel" + [ + ("class", + Value.StructTuple "specs::itable::RelOp::UnsignedGe" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Test" + [ + ("class", Value.StructTuple "specs::itable::TestOp::Eqz" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Rel" + [ + ("class", Value.StructTuple "specs::itable::RelOp::Eq" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Rel" + [ + ("class", Value.StructTuple "specs::itable::RelOp::Ne" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Rel" + [ + ("class", Value.StructTuple "specs::itable::RelOp::SignedLt" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Rel" + [ + ("class", + Value.StructTuple "specs::itable::RelOp::UnsignedLt" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Rel" + [ + ("class", Value.StructTuple "specs::itable::RelOp::SignedGt" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Rel" + [ + ("class", + Value.StructTuple "specs::itable::RelOp::UnsignedGt" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Rel" + [ + ("class", Value.StructTuple "specs::itable::RelOp::SignedLe" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Rel" + [ + ("class", + Value.StructTuple "specs::itable::RelOp::UnsignedLe" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Rel" + [ + ("class", Value.StructTuple "specs::itable::RelOp::SignedGe" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Rel" + [ + ("class", + Value.StructTuple "specs::itable::RelOp::UnsignedGe" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Unary" + [ + ("class", Value.StructTuple "specs::itable::UnaryOp::Clz" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Unary" + [ + ("class", Value.StructTuple "specs::itable::UnaryOp::Ctz" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Unary" + [ + ("class", Value.StructTuple "specs::itable::UnaryOp::Popcnt" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Bin" + [ + ("class", Value.StructTuple "specs::itable::BinOp::Add" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Bin" + [ + ("class", Value.StructTuple "specs::itable::BinOp::Sub" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Bin" + [ + ("class", Value.StructTuple "specs::itable::BinOp::Mul" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Bin" + [ + ("class", Value.StructTuple "specs::itable::BinOp::SignedDiv" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Bin" + [ + ("class", + Value.StructTuple "specs::itable::BinOp::UnsignedDiv" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Bin" + [ + ("class", Value.StructTuple "specs::itable::BinOp::SignedRem" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Bin" + [ + ("class", + Value.StructTuple "specs::itable::BinOp::UnsignedRem" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::BinBit" + [ + ("class", Value.StructTuple "specs::itable::BitOp::And" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::BinBit" + [ + ("class", Value.StructTuple "specs::itable::BitOp::Or" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::BinBit" + [ + ("class", Value.StructTuple "specs::itable::BitOp::Xor" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::BinShift" + [ + ("class", Value.StructTuple "specs::itable::ShiftOp::Shl" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::BinShift" + [ + ("class", + Value.StructTuple "specs::itable::ShiftOp::SignedShr" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::BinShift" + [ + ("class", + Value.StructTuple "specs::itable::ShiftOp::UnsignedShr" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::BinShift" + [ + ("class", Value.StructTuple "specs::itable::ShiftOp::Rotl" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::BinShift" + [ + ("class", Value.StructTuple "specs::itable::ShiftOp::Rotr" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I32" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Unary" + [ + ("class", Value.StructTuple "specs::itable::UnaryOp::Clz" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Unary" + [ + ("class", Value.StructTuple "specs::itable::UnaryOp::Ctz" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Unary" + [ + ("class", Value.StructTuple "specs::itable::UnaryOp::Popcnt" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Bin" + [ + ("class", Value.StructTuple "specs::itable::BinOp::Add" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Bin" + [ + ("class", Value.StructTuple "specs::itable::BinOp::Sub" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Bin" + [ + ("class", Value.StructTuple "specs::itable::BinOp::Mul" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Bin" + [ + ("class", Value.StructTuple "specs::itable::BinOp::SignedDiv" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Bin" + [ + ("class", + Value.StructTuple "specs::itable::BinOp::UnsignedDiv" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Bin" + [ + ("class", Value.StructTuple "specs::itable::BinOp::SignedRem" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Bin" + [ + ("class", + Value.StructTuple "specs::itable::BinOp::UnsignedRem" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::BinBit" + [ + ("class", Value.StructTuple "specs::itable::BitOp::And" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::BinBit" + [ + ("class", Value.StructTuple "specs::itable::BitOp::Or" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::BinBit" + [ + ("class", Value.StructTuple "specs::itable::BitOp::Xor" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::BinShift" + [ + ("class", Value.StructTuple "specs::itable::ShiftOp::Shl" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::BinShift" + [ + ("class", + Value.StructTuple "specs::itable::ShiftOp::SignedShr" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::BinShift" + [ + ("class", + Value.StructTuple "specs::itable::ShiftOp::UnsignedShr" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::BinShift" + [ + ("class", Value.StructTuple "specs::itable::ShiftOp::Rotl" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::BinShift" + [ + ("class", Value.StructTuple "specs::itable::ShiftOp::Rotr" []); + ("vtype", Value.StructTuple "specs::mtable::VarType::I64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Conversion" + [ + ("class", + Value.StructTuple "specs::itable::ConversionOp::I32WrapI64" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Conversion" + [ + ("class", + Value.StructTuple + "specs::itable::ConversionOp::I64ExtendI32s" + []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Conversion" + [ + ("class", + Value.StructTuple + "specs::itable::ConversionOp::I64ExtendI32u" + []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not yet implemented" |) ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Conversion" + [ + ("class", + Value.StructTuple "specs::itable::ConversionOp::I32Extend8S" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Conversion" + [ + ("class", + Value.StructTuple + "specs::itable::ConversionOp::I32Extend16S" + []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Conversion" + [ + ("class", + Value.StructTuple "specs::itable::ConversionOp::I64Extend8S" []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Conversion" + [ + ("class", + Value.StructTuple + "specs::itable::ConversionOp::I64Extend16S" + []) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructRecord + "specs::itable::Opcode::Conversion" + [ + ("class", + Value.StructTuple + "specs::itable::ConversionOp::I64Extend32S" + []) + ] + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::InstructionIntoOpcode" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("into_opcode", InstanceField.Method into_opcode) ]. + End Impl_delphinus_zkwasm_runtime_monitor_plugins_table_instruction_InstructionIntoOpcode_for_wasmi_isa_Instruction. + + (* + Enum RunInstructionTracePre + { + ty_params := []; + variants := + [ + { + name := "BrIfEqz"; + item := StructRecord [ ("value", Ty.path "i32") ]; + discriminant := None; + }; + { + name := "BrIfNez"; + item := StructRecord [ ("value", Ty.path "i32") ]; + discriminant := None; + }; + { + name := "BrTable"; + item := StructRecord [ ("index", Ty.path "i32") ]; + discriminant := None; + }; + { + name := "Call"; + item := StructTuple []; + discriminant := None; + }; + { + name := "CallIndirect"; + item := + StructRecord + [ + ("table_idx", Ty.path "u32"); + ("type_idx", Ty.path "u32"); + ("offset", Ty.path "u32") + ]; + discriminant := None; + }; + { + name := "SetLocal"; + item := + StructRecord + [ + ("depth", Ty.path "u32"); + ("value", Ty.path "wasmi::runner::ValueInternal"); + ("vtype", Ty.path "parity_wasm::elements::types::ValueType") + ]; + discriminant := None; + }; + { + name := "SetGlobal"; + item := StructTuple []; + discriminant := None; + }; + { + name := "Load"; + item := + StructRecord + [ + ("offset", Ty.path "u32"); + ("raw_address", Ty.path "u32"); + ("effective_address", + Ty.apply (Ty.path "core::option::Option") [ Ty.path "u32" ]); + ("vtype", Ty.path "parity_wasm::elements::types::ValueType"); + ("load_size", Ty.path "specs::mtable::MemoryReadSize") + ]; + discriminant := None; + }; + { + name := "Store"; + item := + StructRecord + [ + ("offset", Ty.path "u32"); + ("raw_address", Ty.path "u32"); + ("effective_address", + Ty.apply (Ty.path "core::option::Option") [ Ty.path "u32" ]); + ("value", Ty.path "u64"); + ("vtype", Ty.path "parity_wasm::elements::types::ValueType"); + ("store_size", Ty.path "specs::mtable::MemoryStoreSize"); + ("pre_block_value1", + Ty.apply (Ty.path "core::option::Option") [ Ty.path "u64" ]); + ("pre_block_value2", + Ty.apply (Ty.path "core::option::Option") [ Ty.path "u64" ]) + ]; + discriminant := None; + }; + { + name := "GrowMemory"; + item := StructTuple [ Ty.path "i32" ]; + discriminant := None; + }; + { + name := "I32BinOp"; + item := StructRecord [ ("left", Ty.path "i32"); ("right", Ty.path "i32") ]; + discriminant := None; + }; + { + name := "I64BinOp"; + item := StructRecord [ ("left", Ty.path "i64"); ("right", Ty.path "i64") ]; + discriminant := None; + }; + { + name := "I32Single"; + item := StructTuple [ Ty.path "i32" ]; + discriminant := None; + }; + { + name := "I32Comp"; + item := StructRecord [ ("left", Ty.path "i32"); ("right", Ty.path "i32") ]; + discriminant := None; + }; + { + name := "I64Single"; + item := StructTuple [ Ty.path "i64" ]; + discriminant := None; + }; + { + name := "I64Comp"; + item := StructRecord [ ("left", Ty.path "i64"); ("right", Ty.path "i64") ]; + discriminant := None; + }; + { + name := "I32WrapI64"; + item := StructRecord [ ("value", Ty.path "i64") ]; + discriminant := None; + }; + { + name := "I64ExtendI32"; + item := StructRecord [ ("value", Ty.path "i32"); ("sign", Ty.path "bool") ]; + discriminant := None; + }; + { + name := "I32SignExtendI8"; + item := StructRecord [ ("value", Ty.path "i32") ]; + discriminant := None; + }; + { + name := "I32SignExtendI16"; + item := StructRecord [ ("value", Ty.path "i32") ]; + discriminant := None; + }; + { + name := "I64SignExtendI8"; + item := StructRecord [ ("value", Ty.path "i64") ]; + discriminant := None; + }; + { + name := "I64SignExtendI16"; + item := StructRecord [ ("value", Ty.path "i64") ]; + discriminant := None; + }; + { + name := "I64SignExtendI32"; + item := StructRecord [ ("value", Ty.path "i64") ]; + discriminant := None; + }; + { + name := "UnaryOp"; + item := + StructRecord + [ ("operand", Ty.path "u64"); ("vtype", Ty.path "specs::mtable::VarType") ]; + discriminant := None; + }; + { + name := "Drop"; + item := StructTuple []; + discriminant := None; + }; + { + name := "Select"; + item := + StructRecord + [ ("val1", Ty.path "u64"); ("val2", Ty.path "u64"); ("cond", Ty.path "u64") ]; + discriminant := None; + } + ]; + } + *) + + (* + pub(super) fn run_instruction_pre( + value_stack: &ValueStack, + function_context: &FunctionContext, + instructions: &isa::Instruction, + ) -> Option { + match *instructions { + isa::Instruction::GetLocal(..) => None, + isa::Instruction::SetLocal(depth, vtype) => { + let value = value_stack.top(); + Some(RunInstructionTracePre::SetLocal { + depth, + value: value.clone(), + vtype, + }) + } + isa::Instruction::TeeLocal(..) => None, + isa::Instruction::GetGlobal(..) => None, + isa::Instruction::SetGlobal(..) => Some(RunInstructionTracePre::SetGlobal), + + isa::Instruction::Br(_) => None, + isa::Instruction::BrIfEqz(_) => Some(RunInstructionTracePre::BrIfEqz { + value: <_>::from_value_internal( *value_stack.top()), + }), + isa::Instruction::BrIfNez(_) => Some(RunInstructionTracePre::BrIfNez { + value: <_>::from_value_internal( *value_stack.top()), + }), + isa::Instruction::BrTable(_) => Some(RunInstructionTracePre::BrTable { + index: <_>::from_value_internal( *value_stack.top()), + }), + + isa::Instruction::Unreachable => None, + isa::Instruction::Return(..) => None, + + isa::Instruction::Call(..) => Some(RunInstructionTracePre::Call), + isa::Instruction::CallIndirect(type_idx) => { + let table_idx = DEFAULT_TABLE_INDEX; + let offset = <_>::from_value_internal( *value_stack.top()); + + Some(RunInstructionTracePre::CallIndirect { + table_idx, + type_idx, + offset, + }) + } + + isa::Instruction::Drop => Some(RunInstructionTracePre::Drop), + isa::Instruction::Select(vtype) => Some(RunInstructionTracePre::Select { + cond: from_value_internal_to_u64_with_typ(VarType::I32, *value_stack.pick(1)), + val2: from_value_internal_to_u64_with_typ(vtype.into(), *value_stack.pick(2)), + val1: from_value_internal_to_u64_with_typ(vtype.into(), *value_stack.pick(3)), + }), + + isa::Instruction::I32Load(offset) + | isa::Instruction::I32Load8S(offset) + | isa::Instruction::I32Load8U(offset) + | isa::Instruction::I32Load16S(offset) + | isa::Instruction::I32Load16U(offset) => { + let load_size = match *instructions { + isa::Instruction::I32Load(..) => MemoryReadSize::U32, + isa::Instruction::I32Load8S(..) => MemoryReadSize::S8, + isa::Instruction::I32Load8U(..) => MemoryReadSize::U8, + isa::Instruction::I32Load16S(..) => MemoryReadSize::S16, + isa::Instruction::I32Load16U(..) => MemoryReadSize::U16, + _ => unreachable!(), + }; + + let raw_address = <_>::from_value_internal( *value_stack.top()); + let address = effective_address(offset, raw_address).map_or(None, |addr| Some(addr)); + + Some(RunInstructionTracePre::Load { + offset, + raw_address, + effective_address: address, + vtype: parity_wasm::elements::ValueType::I32, + load_size, + }) + } + isa::Instruction::I64Load(offset) + | isa::Instruction::I64Load8S(offset) + | isa::Instruction::I64Load8U(offset) + | isa::Instruction::I64Load16S(offset) + | isa::Instruction::I64Load16U(offset) + | isa::Instruction::I64Load32S(offset) + | isa::Instruction::I64Load32U(offset) => { + let load_size = match *instructions { + isa::Instruction::I64Load(..) => MemoryReadSize::I64, + isa::Instruction::I64Load8S(..) => MemoryReadSize::S8, + isa::Instruction::I64Load8U(..) => MemoryReadSize::U8, + isa::Instruction::I64Load16S(..) => MemoryReadSize::S16, + isa::Instruction::I64Load16U(..) => MemoryReadSize::U16, + isa::Instruction::I64Load32S(..) => MemoryReadSize::S32, + isa::Instruction::I64Load32U(..) => MemoryReadSize::U32, + _ => unreachable!(), + }; + let raw_address = <_>::from_value_internal( *value_stack.top()); + let address = effective_address(offset, raw_address).map_or(None, |addr| Some(addr)); + + Some(RunInstructionTracePre::Load { + offset, + raw_address, + effective_address: address, + vtype: parity_wasm::elements::ValueType::I64, + load_size, + }) + } + isa::Instruction::I32Store(offset) + | isa::Instruction::I32Store8(offset) + | isa::Instruction::I32Store16(offset) => { + let store_size = match *instructions { + isa::Instruction::I32Store8(_) => MemoryStoreSize::Byte8, + isa::Instruction::I32Store16(_) => MemoryStoreSize::Byte16, + isa::Instruction::I32Store(_) => MemoryStoreSize::Byte32, + _ => unreachable!(), + }; + + let value: u32 = <_>::from_value_internal( *value_stack.pick(1)); + let raw_address = <_>::from_value_internal( *value_stack.pick(2)); + let address = effective_address(offset, raw_address).map_or(None, |addr| Some(addr)); + + let pre_block_value1 = address.map(|address| { + let mut buf = [0u8; 8]; + function_context + .memory + .clone() + .unwrap() + .get_into(address / 8 * 8, &mut buf) + .unwrap(); + u64::from_le_bytes(buf) + }); + + let pre_block_value2 = address + .map(|address| { + if store_size.byte_size() as u32 + address % 8 > 8 { + let mut buf = [0u8; 8]; + function_context + .memory + .clone() + .unwrap() + .get_into((address / 8 + 1) * 8, &mut buf) + .unwrap(); + Some(u64::from_le_bytes(buf)) + } else { + None + } + }) + .flatten(); + + Some(RunInstructionTracePre::Store { + offset, + raw_address, + effective_address: address, + value: value as u64, + vtype: parity_wasm::elements::ValueType::I32, + store_size, + pre_block_value1, + pre_block_value2, + }) + } + isa::Instruction::I64Store(offset) + | isa::Instruction::I64Store8(offset) + | isa::Instruction::I64Store16(offset) + | isa::Instruction::I64Store32(offset) => { + let store_size = match *instructions { + isa::Instruction::I64Store(..) => MemoryStoreSize::Byte64, + isa::Instruction::I64Store8(..) => MemoryStoreSize::Byte8, + isa::Instruction::I64Store16(..) => MemoryStoreSize::Byte16, + isa::Instruction::I64Store32(..) => MemoryStoreSize::Byte32, + _ => unreachable!(), + }; + + let value = <_>::from_value_internal( *value_stack.pick(1)); + let raw_address = <_>::from_value_internal( *value_stack.pick(2)); + let address = effective_address(offset, raw_address).map_or(None, |addr| Some(addr)); + + let pre_block_value1 = address.map(|address| { + let mut buf = [0u8; 8]; + function_context + .memory + .clone() + .unwrap() + .get_into(address / 8 * 8, &mut buf) + .unwrap(); + u64::from_le_bytes(buf) + }); + + let pre_block_value2 = address + .map(|address| { + if store_size.byte_size() as u32 + address % 8 > 8 { + let mut buf = [0u8; 8]; + function_context + .memory + .clone() + .unwrap() + .get_into((address / 8 + 1) * 8, &mut buf) + .unwrap(); + Some(u64::from_le_bytes(buf)) + } else { + None + } + }) + .flatten(); + + Some(RunInstructionTracePre::Store { + offset, + raw_address, + effective_address: address, + value, + vtype: parity_wasm::elements::ValueType::I64, + store_size, + pre_block_value1, + pre_block_value2, + }) + } + + isa::Instruction::CurrentMemory => None, + isa::Instruction::GrowMemory => Some(RunInstructionTracePre::GrowMemory( + <_>::from_value_internal( *value_stack.pick(1)), + )), + + isa::Instruction::I32Const(_) => None, + isa::Instruction::I64Const(_) => None, + + isa::Instruction::I32Eqz => Some(RunInstructionTracePre::I32Single( + <_>::from_value_internal( *value_stack.pick(1)), + )), + isa::Instruction::I64Eqz => Some(RunInstructionTracePre::I64Single( + <_>::from_value_internal( *value_stack.pick(1)), + )), + + isa::Instruction::I32Eq + | isa::Instruction::I32Ne + | isa::Instruction::I32GtS + | isa::Instruction::I32GtU + | isa::Instruction::I32GeS + | isa::Instruction::I32GeU + | isa::Instruction::I32LtU + | isa::Instruction::I32LeU + | isa::Instruction::I32LtS + | isa::Instruction::I32LeS => Some(RunInstructionTracePre::I32Comp { + left: <_>::from_value_internal( *value_stack.pick(2)), + right: <_>::from_value_internal( *value_stack.pick(1)), + }), + + isa::Instruction::I64Eq + | isa::Instruction::I64Ne + | isa::Instruction::I64GtS + | isa::Instruction::I64GtU + | isa::Instruction::I64GeS + | isa::Instruction::I64GeU + | isa::Instruction::I64LtU + | isa::Instruction::I64LeU + | isa::Instruction::I64LtS + | isa::Instruction::I64LeS => Some(RunInstructionTracePre::I64Comp { + left: <_>::from_value_internal( *value_stack.pick(2)), + right: <_>::from_value_internal( *value_stack.pick(1)), + }), + + isa::Instruction::I32Add + | isa::Instruction::I32Sub + | isa::Instruction::I32Mul + | isa::Instruction::I32DivS + | isa::Instruction::I32DivU + | isa::Instruction::I32RemS + | isa::Instruction::I32RemU + | isa::Instruction::I32Shl + | isa::Instruction::I32ShrU + | isa::Instruction::I32ShrS + | isa::Instruction::I32And + | isa::Instruction::I32Or + | isa::Instruction::I32Xor + | isa::Instruction::I32Rotl + | isa::Instruction::I32Rotr => Some(RunInstructionTracePre::I32BinOp { + left: <_>::from_value_internal( *value_stack.pick(2)), + right: <_>::from_value_internal( *value_stack.pick(1)), + }), + + isa::Instruction::I64Add + | isa::Instruction::I64Sub + | isa::Instruction::I64Mul + | isa::Instruction::I64DivS + | isa::Instruction::I64DivU + | isa::Instruction::I64RemS + | isa::Instruction::I64RemU + | isa::Instruction::I64Shl + | isa::Instruction::I64ShrU + | isa::Instruction::I64ShrS + | isa::Instruction::I64And + | isa::Instruction::I64Or + | isa::Instruction::I64Xor + | isa::Instruction::I64Rotl + | isa::Instruction::I64Rotr => Some(RunInstructionTracePre::I64BinOp { + left: <_>::from_value_internal( *value_stack.pick(2)), + right: <_>::from_value_internal( *value_stack.pick(1)), + }), + + isa::Instruction::I32Ctz | isa::Instruction::I32Clz | isa::Instruction::I32Popcnt => { + Some(RunInstructionTracePre::UnaryOp { + operand: from_value_internal_to_u64_with_typ(VarType::I32, *value_stack.pick(1)), + vtype: VarType::I32, + }) + } + isa::Instruction::I64Ctz | isa::Instruction::I64Clz | isa::Instruction::I64Popcnt => { + Some(RunInstructionTracePre::UnaryOp { + operand: from_value_internal_to_u64_with_typ(VarType::I64, *value_stack.pick(1)), + vtype: VarType::I64, + }) + } + + isa::Instruction::I32WrapI64 => Some(RunInstructionTracePre::I32WrapI64 { + value: <_>::from_value_internal( *value_stack.pick(1)), + }), + isa::Instruction::I64ExtendUI32 => Some(RunInstructionTracePre::I64ExtendI32 { + value: <_>::from_value_internal( *value_stack.pick(1)), + sign: false, + }), + isa::Instruction::I64ExtendSI32 => Some(RunInstructionTracePre::I64ExtendI32 { + value: <_>::from_value_internal( *value_stack.pick(1)), + sign: true, + }), + isa::Instruction::I32Extend8S => Some(RunInstructionTracePre::I32SignExtendI8 { + value: <_>::from_value_internal( *value_stack.pick(1)), + }), + isa::Instruction::I32Extend16S => Some(RunInstructionTracePre::I32SignExtendI16 { + value: <_>::from_value_internal( *value_stack.pick(1)), + }), + isa::Instruction::I64Extend8S => Some(RunInstructionTracePre::I64SignExtendI8 { + value: <_>::from_value_internal( *value_stack.pick(1)), + }), + isa::Instruction::I64Extend16S => Some(RunInstructionTracePre::I64SignExtendI16 { + value: <_>::from_value_internal( *value_stack.pick(1)), + }), + isa::Instruction::I64Extend32S => Some(RunInstructionTracePre::I64SignExtendI32 { + value: <_>::from_value_internal( *value_stack.pick(1)), + }), + + _ => { + println!("{:?}", *instructions); + unimplemented!() + } + } + } + *) + Definition run_instruction_pre (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ value_stack; function_context; instructions ] => + ltac:(M.monadic + (let value_stack := M.alloc (| value_stack |) in + let function_context := M.alloc (| function_context |) in + let instructions := M.alloc (| instructions |) in + M.read (| + M.match_operator (| + M.read (| instructions |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "core::option::Option::None" [] |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::SetLocal", + 0 + |) in + let γ0_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::SetLocal", + 1 + |) in + let depth := M.copy (| γ0_0 |) in + let vtype := M.copy (| γ0_1 |) in + let value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::SetLocal" + [ + ("depth", M.read (| depth |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "wasmi::runner::ValueInternal", + [], + "clone", + [] + |), + [ M.read (| value |) ] + |)); + ("vtype", M.read (| vtype |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "core::option::Option::None" [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "core::option::Option::None" [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::SetGlobal" + [] + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::Br", + 0 + |) in + M.alloc (| Value.StructTuple "core::option::Option::None" [] |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::BrIfEqz", + 0 + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::BrIfEqz" + [ + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::BrIfNez", + 0 + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::BrIfNez" + [ + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::BrTable", + 0 + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::BrTable" + [ + ("index", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "core::option::Option::None" [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "core::option::Option::None" [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Call" + [] + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::CallIndirect", + 0 + |) in + let type_idx := M.copy (| γ0_0 |) in + let table_idx := + M.copy (| + M.get_constant (| + "delphinus_zkwasm::runtime::monitor::plugins::table::DEFAULT_TABLE_INDEX" + |) + |) in + let offset := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "u32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::CallIndirect" + [ + ("table_idx", M.read (| table_idx |)); + ("type_idx", M.read (| type_idx |)); + ("offset", M.read (| offset |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Drop" + [] + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::Select", + 0 + |) in + let vtype := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Select" + [ + ("cond", + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + Value.StructTuple "specs::mtable::VarType::I32" []; + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 1 ] + |) + |) + ] + |)); + ("val2", + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "parity_wasm::elements::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ M.read (| vtype |) ] + |); + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 2 ] + |) + |) + ] + |)); + ("val1", + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "parity_wasm::elements::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ M.read (| vtype |) ] + |); + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 3 ] + |) + |) + ] + |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Load", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + Value.Tuple [ offset ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Load8S", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + Value.Tuple [ offset ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Load8U", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + Value.Tuple [ offset ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Load16S", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + Value.Tuple [ offset ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Load16U", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + Value.Tuple [ offset ])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ offset ] => + let load_size := + M.copy (| + M.match_operator (| + M.read (| instructions |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "specs::mtable::MemoryReadSize::U32" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "specs::mtable::MemoryReadSize::S8" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "specs::mtable::MemoryReadSize::U8" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "specs::mtable::MemoryReadSize::S16" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "specs::mtable::MemoryReadSize::U16" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic", + [] + |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |) in + let raw_address := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "u32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |) + |) in + let address := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "wasmi_core::trap::TrapCode" + ], + "map_or", + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u32" ]; + Ty.function + [ Ty.tuple [ Ty.path "u32" ] ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u32" ]) + ] + |), + [ + M.call_closure (| + M.get_function (| + "wasmi::runner::effective_address", + [] + |), + [ M.read (| offset |); M.read (| raw_address |) ] + |); + Value.StructTuple "core::option::Option::None" []; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let addr := M.copy (| γ |) in + Value.StructTuple + "core::option::Option::Some" + [ M.read (| addr |) ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Load" + [ + ("offset", M.read (| offset |)); + ("raw_address", M.read (| raw_address |)); + ("effective_address", M.read (| address |)); + ("vtype", + Value.StructTuple + "parity_wasm::elements::types::ValueType::I32" + []); + ("load_size", M.read (| load_size |)) + ] + ] + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Load", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + Value.Tuple [ offset ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Load8S", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + Value.Tuple [ offset ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Load8U", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + Value.Tuple [ offset ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Load16S", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + Value.Tuple [ offset ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Load16U", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + Value.Tuple [ offset ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Load32S", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + Value.Tuple [ offset ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Load32U", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + Value.Tuple [ offset ])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ offset ] => + let load_size := + M.copy (| + M.match_operator (| + M.read (| instructions |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "specs::mtable::MemoryReadSize::I64" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "specs::mtable::MemoryReadSize::S8" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "specs::mtable::MemoryReadSize::U8" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "specs::mtable::MemoryReadSize::S16" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "specs::mtable::MemoryReadSize::U16" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "specs::mtable::MemoryReadSize::S32" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "specs::mtable::MemoryReadSize::U32" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic", + [] + |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |) in + let raw_address := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "u32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |) + |) in + let address := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "wasmi_core::trap::TrapCode" + ], + "map_or", + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u32" ]; + Ty.function + [ Ty.tuple [ Ty.path "u32" ] ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u32" ]) + ] + |), + [ + M.call_closure (| + M.get_function (| + "wasmi::runner::effective_address", + [] + |), + [ M.read (| offset |); M.read (| raw_address |) ] + |); + Value.StructTuple "core::option::Option::None" []; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let addr := M.copy (| γ |) in + Value.StructTuple + "core::option::Option::Some" + [ M.read (| addr |) ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Load" + [ + ("offset", M.read (| offset |)); + ("raw_address", M.read (| raw_address |)); + ("effective_address", M.read (| address |)); + ("vtype", + Value.StructTuple + "parity_wasm::elements::types::ValueType::I64" + []); + ("load_size", M.read (| load_size |)) + ] + ] + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Store", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + Value.Tuple [ offset ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Store8", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + Value.Tuple [ offset ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Store16", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + Value.Tuple [ offset ])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ offset ] => + let store_size := + M.copy (| + M.match_operator (| + M.read (| instructions |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Store8", + 0 + |) in + M.alloc (| + Value.StructTuple + "specs::mtable::MemoryStoreSize::Byte8" + [] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Store16", + 0 + |) in + M.alloc (| + Value.StructTuple + "specs::mtable::MemoryStoreSize::Byte16" + [] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Store", + 0 + |) in + M.alloc (| + Value.StructTuple + "specs::mtable::MemoryStoreSize::Byte32" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic", + [] + |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |) in + let value := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "u32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 1 ] + |) + |) + ] + |) + |) in + let raw_address := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "u32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 2 ] + |) + |) + ] + |) + |) in + let address := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "wasmi_core::trap::TrapCode" + ], + "map_or", + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u32" ]; + Ty.function + [ Ty.tuple [ Ty.path "u32" ] ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u32" ]) + ] + |), + [ + M.call_closure (| + M.get_function (| + "wasmi::runner::effective_address", + [] + |), + [ M.read (| offset |); M.read (| raw_address |) ] + |); + Value.StructTuple "core::option::Option::None" []; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let addr := M.copy (| γ |) in + Value.StructTuple + "core::option::Option::Some" + [ M.read (| addr |) ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let pre_block_value1 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u32" ], + "map", + [ + Ty.path "u64"; + Ty.function + [ Ty.tuple [ Ty.path "u32" ] ] + (Ty.path "u64") + ] + |), + [ + M.read (| address |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let address := M.copy (| γ |) in + M.read (| + let buf := + M.alloc (| + repeat (Value.Integer 0) 8 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path "wasmi::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::memory::MemoryInstance", + "get_into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "wasmi::memory::MemoryRef", + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "wasmi::memory::MemoryRef" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "wasmi::memory::MemoryRef" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + function_context + |), + "wasmi::runner::FunctionContext", + "memory" + |) + ] + |) + ] + |) + |) + ] + |); + BinOp.Panic.mul (| + Integer.U32, + BinOp.Panic.div (| + Integer.U32, + M.read (| address |), + Value.Integer 8 + |), + Value.Integer 8 + |); + (* Unsize *) + M.pointer_coercion buf + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u64", + "from_le_bytes", + [] + |), + [ M.read (| buf |) ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let pre_block_value2 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ] + ], + "flatten", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u32" ], + "map", + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ]; + Ty.function + [ Ty.tuple [ Ty.path "u32" ] ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ]) + ] + |), + [ + M.read (| address |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let address := M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (BinOp.Panic.add (| + Integer.U32, + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::mtable::MemoryStoreSize", + "byte_size", + [] + |), + [ store_size + ] + |)), + BinOp.Panic.rem (| + Integer.U32, + M.read (| + address + |), + Value.Integer + 8 + |) + |)) + (Value.Integer 8) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let buf := + M.alloc (| + repeat + (Value.Integer 0) + 8 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "wasmi::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::memory::MemoryInstance", + "get_into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "wasmi::memory::MemoryRef", + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "wasmi::memory::MemoryRef" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "wasmi::memory::MemoryRef" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + function_context + |), + "wasmi::runner::FunctionContext", + "memory" + |) + ] + |) + ] + |) + |) + ] + |); + BinOp.Panic.mul (| + Integer.U32, + BinOp.Panic.add (| + Integer.U32, + BinOp.Panic.div (| + Integer.U32, + M.read (| + address + |), + Value.Integer + 8 + |), + Value.Integer + 1 + |), + Value.Integer + 8 + |); + (* Unsize *) + M.pointer_coercion + buf + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "u64", + "from_le_bytes", + [] + |), + [ M.read (| buf |) + ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Store" + [ + ("offset", M.read (| offset |)); + ("raw_address", M.read (| raw_address |)); + ("effective_address", M.read (| address |)); + ("value", M.rust_cast (M.read (| value |))); + ("vtype", + Value.StructTuple + "parity_wasm::elements::types::ValueType::I32" + []); + ("store_size", M.read (| store_size |)); + ("pre_block_value1", M.read (| pre_block_value1 |)); + ("pre_block_value2", M.read (| pre_block_value2 |)) + ] + ] + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Store", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + Value.Tuple [ offset ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Store8", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + Value.Tuple [ offset ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Store16", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + Value.Tuple [ offset ])); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Store32", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + Value.Tuple [ offset ])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ offset ] => + let store_size := + M.copy (| + M.match_operator (| + M.read (| instructions |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "specs::mtable::MemoryStoreSize::Byte64" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "specs::mtable::MemoryStoreSize::Byte8" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "specs::mtable::MemoryStoreSize::Byte16" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "specs::mtable::MemoryStoreSize::Byte32" + [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic", + [] + |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |) in + let value := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "u64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 1 ] + |) + |) + ] + |) + |) in + let raw_address := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "u32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 2 ] + |) + |) + ] + |) + |) in + let address := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "u32"; Ty.path "wasmi_core::trap::TrapCode" + ], + "map_or", + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u32" ]; + Ty.function + [ Ty.tuple [ Ty.path "u32" ] ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u32" ]) + ] + |), + [ + M.call_closure (| + M.get_function (| + "wasmi::runner::effective_address", + [] + |), + [ M.read (| offset |); M.read (| raw_address |) ] + |); + Value.StructTuple "core::option::Option::None" []; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let addr := M.copy (| γ |) in + Value.StructTuple + "core::option::Option::Some" + [ M.read (| addr |) ])) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let pre_block_value1 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u32" ], + "map", + [ + Ty.path "u64"; + Ty.function + [ Ty.tuple [ Ty.path "u32" ] ] + (Ty.path "u64") + ] + |), + [ + M.read (| address |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let address := M.copy (| γ |) in + M.read (| + let buf := + M.alloc (| + repeat (Value.Integer 0) 8 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path "wasmi::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::memory::MemoryInstance", + "get_into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "wasmi::memory::MemoryRef", + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "wasmi::memory::MemoryRef" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "wasmi::memory::MemoryRef" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + function_context + |), + "wasmi::runner::FunctionContext", + "memory" + |) + ] + |) + ] + |) + |) + ] + |); + BinOp.Panic.mul (| + Integer.U32, + BinOp.Panic.div (| + Integer.U32, + M.read (| address |), + Value.Integer 8 + |), + Value.Integer 8 + |); + (* Unsize *) + M.pointer_coercion buf + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u64", + "from_le_bytes", + [] + |), + [ M.read (| buf |) ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let pre_block_value2 := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ] + ], + "flatten", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u32" ], + "map", + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ]; + Ty.function + [ Ty.tuple [ Ty.path "u32" ] ] + (Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ]) + ] + |), + [ + M.read (| address |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let address := M.copy (| γ |) in + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (BinOp.Panic.add (| + Integer.U32, + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::mtable::MemoryStoreSize", + "byte_size", + [] + |), + [ store_size + ] + |)), + BinOp.Panic.rem (| + Integer.U32, + M.read (| + address + |), + Value.Integer + 8 + |) + |)) + (Value.Integer 8) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let buf := + M.alloc (| + repeat + (Value.Integer 0) + 8 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "wasmi::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::memory::MemoryInstance", + "get_into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "wasmi::memory::MemoryRef", + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "wasmi::memory::MemoryRef" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "wasmi::memory::MemoryRef" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + function_context + |), + "wasmi::runner::FunctionContext", + "memory" + |) + ] + |) + ] + |) + |) + ] + |); + BinOp.Panic.mul (| + Integer.U32, + BinOp.Panic.add (| + Integer.U32, + BinOp.Panic.div (| + Integer.U32, + M.read (| + address + |), + Value.Integer + 8 + |), + Value.Integer + 1 + |), + Value.Integer + 8 + |); + (* Unsize *) + M.pointer_coercion + buf + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "u64", + "from_le_bytes", + [] + |), + [ M.read (| buf |) + ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))) + ] + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Store" + [ + ("offset", M.read (| offset |)); + ("raw_address", M.read (| raw_address |)); + ("effective_address", M.read (| address |)); + ("value", M.read (| value |)); + ("vtype", + Value.StructTuple + "parity_wasm::elements::types::ValueType::I64" + []); + ("store_size", M.read (| store_size |)); + ("pre_block_value1", M.read (| pre_block_value1 |)); + ("pre_block_value2", M.read (| pre_block_value2 |)) + ] + ] + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.StructTuple "core::option::Option::None" [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::GrowMemory" + [ + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 1 ] + |) + |) + ] + |) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Const", + 0 + |) in + M.alloc (| Value.StructTuple "core::option::Option::None" [] |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Const", + 0 + |) in + M.alloc (| Value.StructTuple "core::option::Option::None" [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Single" + [ + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 1 ] + |) + |) + ] + |) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Single" + [ + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 1 ] + |) + |) + ] + |) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [] => + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp" + [ + ("left", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 2 + ] + |) + |) + ] + |)); + ("right", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 1 + ] + |) + |) + ] + |)) + ] + ] + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [] => + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp" + [ + ("left", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 2 + ] + |) + |) + ] + |)); + ("right", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 1 + ] + |) + |) + ] + |)) + ] + ] + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [] => + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp" + [ + ("left", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 2 + ] + |) + |) + ] + |)); + ("right", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 1 + ] + |) + |) + ] + |)) + ] + ] + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [] => + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp" + [ + ("left", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 2 + ] + |) + |) + ] + |)); + ("right", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 1 + ] + |) + |) + ] + |)) + ] + ] + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [] => + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::UnaryOp" + [ + ("operand", + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + Value.StructTuple + "specs::mtable::VarType::I32" + []; + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 1 + ] + |) + |) + ] + |)); + ("vtype", + Value.StructTuple "specs::mtable::VarType::I32" []) + ] + ] + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [] => + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::UnaryOp" + [ + ("operand", + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + Value.StructTuple + "specs::mtable::VarType::I64" + []; + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 1 + ] + |) + |) + ] + |)); + ("vtype", + Value.StructTuple "specs::mtable::VarType::I64" []) + ] + ] + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32WrapI64" + [ + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 1 ] + |) + |) + ] + |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64ExtendI32" + [ + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 1 ] + |) + |) + ] + |)); + ("sign", Value.Bool false) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64ExtendI32" + [ + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 1 ] + |) + |) + ] + |)); + ("sign", Value.Bool true) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32SignExtendI8" + [ + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 1 ] + |) + |) + ] + |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32SignExtendI16" + [ + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 1 ] + |) + |) + ] + |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64SignExtendI8" + [ + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 1 ] + |) + |) + ] + |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64SignExtendI16" + [ + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 1 ] + |) + |) + ] + |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64SignExtendI32" + [ + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "pick", + [] + |), + [ M.read (| value_stack |); Value.Integer 1 ] + |) + |) + ] + |)) + ] + ] + |))); + fun γ => + ltac:(M.monadic + (let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| "std::io::stdio::_print", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "" |); + M.read (| Value.String " +" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ Ty.path "wasmi::isa::Instruction" ] + |), + [ M.read (| instructions |) ] + |) + ] + |)) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not implemented" |) ] + |) + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Module Impl_delphinus_zkwasm_runtime_monitor_plugins_table_TablePlugin. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin". + + (* + pub(super) fn run_instruction_post( + &self, + module_ref: &ModuleRef, + current_event: Option, + value_stack: &ValueStack, + context: &FunctionContext, + instructions: &isa::Instruction, + ) -> StepInfo { + match *instructions { + isa::Instruction::GetLocal(depth, vtype) => StepInfo::GetLocal { + depth, + value: from_value_internal_to_u64_with_typ(vtype.into(), *value_stack.top()), + vtype: vtype.into(), + }, + isa::Instruction::SetLocal(..) => { + if let RunInstructionTracePre::SetLocal { + depth, + value, + vtype, + } = current_event.unwrap() + { + StepInfo::SetLocal { + depth, + value: from_value_internal_to_u64_with_typ(vtype.into(), value), + vtype: vtype.into(), + } + } else { + unreachable!() + } + } + isa::Instruction::TeeLocal(depth, vtype) => StepInfo::TeeLocal { + depth, + value: from_value_internal_to_u64_with_typ(vtype.into(), *value_stack.top()), + vtype: vtype.into(), + }, + isa::Instruction::GetGlobal(idx) => { + let global_ref = context.module().global_by_index(idx).unwrap(); + let is_mutable = global_ref.is_mutable(); + let vtype: VarType = global_ref.value_type().into_elements().into(); + let value = from_value_internal_to_u64_with_typ( + vtype.into(), + ValueInternal::from(global_ref.get()), + ); + + StepInfo::GetGlobal { + idx, + vtype, + is_mutable, + value, + } + } + isa::Instruction::SetGlobal(idx) => { + let global_ref = context.module().global_by_index(idx).unwrap(); + let is_mutable = global_ref.is_mutable(); + let vtype: VarType = global_ref.value_type().into_elements().into(); + let value = from_value_internal_to_u64_with_typ( + vtype.into(), + ValueInternal::from(global_ref.get()), + ); + + StepInfo::SetGlobal { + idx, + vtype, + is_mutable, + value, + } + } + + isa::Instruction::Br(target) => StepInfo::Br { + dst_pc: target.dst_pc, + drop: target.drop_keep.drop, + keep: if let Keep::Single(t) = target.drop_keep.keep { + vec![t.into()] + } else { + vec![] + }, + keep_values: match target.drop_keep.keep { + Keep::Single(t) => vec![from_value_internal_to_u64_with_typ( + t.into(), + *value_stack.top(), + )], + Keep::None => vec![], + }, + }, + isa::Instruction::BrIfEqz(target) => { + if let RunInstructionTracePre::BrIfEqz { value } = current_event.unwrap() { + StepInfo::BrIfEqz { + condition: value, + dst_pc: target.dst_pc, + drop: target.drop_keep.drop, + keep: if let Keep::Single(t) = target.drop_keep.keep { + vec![t.into()] + } else { + vec![] + }, + keep_values: match target.drop_keep.keep { + Keep::Single(t) => vec![from_value_internal_to_u64_with_typ( + t.into(), + *value_stack.top(), + )], + Keep::None => vec![], + }, + } + } else { + unreachable!() + } + } + isa::Instruction::BrIfNez(target) => { + if let RunInstructionTracePre::BrIfNez { value } = current_event.unwrap() { + StepInfo::BrIfNez { + condition: value, + dst_pc: target.dst_pc, + drop: target.drop_keep.drop, + keep: if let Keep::Single(t) = target.drop_keep.keep { + vec![t.into()] + } else { + vec![] + }, + keep_values: match target.drop_keep.keep { + Keep::Single(t) => vec![from_value_internal_to_u64_with_typ( + t.into(), + *value_stack.top(), + )], + Keep::None => vec![], + }, + } + } else { + unreachable!() + } + } + isa::Instruction::BrTable(targets) => { + if let RunInstructionTracePre::BrTable { index } = current_event.unwrap() { + StepInfo::BrTable { + index, + dst_pc: targets.get(index as u32).dst_pc, + drop: targets.get(index as u32).drop_keep.drop, + keep: if let Keep::Single(t) = targets.get(index as u32).drop_keep.keep { + vec![t.into()] + } else { + vec![] + }, + keep_values: match targets.get(index as u32).drop_keep.keep { + Keep::Single(t) => vec![from_value_internal_to_u64_with_typ( + t.into(), + *value_stack.top(), + )], + Keep::None => vec![], + }, + } + } else { + unreachable!() + } + } + + isa::Instruction::Return(DropKeep { drop, keep }) => { + let mut drop_values = vec![]; + + for i in 1..=drop { + drop_values.push( *value_stack.pick(i as usize)); + } + + StepInfo::Return { + drop, + keep: if let Keep::Single(t) = keep { + vec![t.into()] + } else { + vec![] + }, + keep_values: match keep { + Keep::Single(t) => vec![from_value_internal_to_u64_with_typ( + t.into(), + *value_stack.top(), + )], + Keep::None => vec![], + }, + } + } + + isa::Instruction::Drop => { + if let RunInstructionTracePre::Drop = current_event.unwrap() { + StepInfo::Drop + } else { + unreachable!() + } + } + isa::Instruction::Select(vtype) => { + if let RunInstructionTracePre::Select { val1, val2, cond } = current_event.unwrap() + { + StepInfo::Select { + val1, + val2, + cond, + result: from_value_internal_to_u64_with_typ( + vtype.into(), + *value_stack.top(), + ), + vtype: vtype.into(), + } + } else { + unreachable!() + } + } + + isa::Instruction::Call(index) => { + if let RunInstructionTracePre::Call = current_event.unwrap() { + let desc = &self.function_table[index as usize]; + + match &desc.ftype { + specs::types::FunctionType::WasmFunction => StepInfo::Call { index }, + specs::types::FunctionType::HostFunction { + plugin, + function_index: host_function_idx, + function_name, + op_index_in_plugin, + } => { + let params_len = desc.signature.params().len(); + let mut args: Vec = vec![]; + let signature: specs::host_function::Signature = + desc.signature.clone().into(); + let params = signature.params.clone(); + + for i in 0..params_len { + args.push(from_value_internal_to_u64_with_typ( + (params[i]).into(), + *value_stack.pick(params_len - i), + )); + } + StepInfo::CallHost { + plugin: *plugin, + host_function_idx: *host_function_idx, + function_name: function_name.clone(), + args, + ret_val: None, + signature, + op_index_in_plugin: *op_index_in_plugin, + } + } + specs::types::FunctionType::HostFunctionExternal { op, sig, .. } => { + StepInfo::ExternalHostCall { + op: *op, + value: match sig { + ExternalHostCallSignature::Argument => { + Some(from_value_internal_to_u64_with_typ( + VarType::I64, + *value_stack.top(), + )) + } + ExternalHostCallSignature::Return => None, + }, + sig: *sig, + } + } + } + } else { + unreachable!() + } + } + isa::Instruction::CallIndirect(_) => { + if let RunInstructionTracePre::CallIndirect { + table_idx, + type_idx, + offset, + } = current_event.unwrap() + { + let table = context + .module() + .table_by_index(DEFAULT_TABLE_INDEX) + .unwrap(); + let func_ref = table.get(offset).unwrap().unwrap(); + let func_index = module_ref.func_index_by_func_ref(&func_ref); + + StepInfo::CallIndirect { + table_index: table_idx, + type_index: type_idx, + offset, + func_index, + } + } else { + unreachable!() + } + } + + isa::Instruction::I32Load(..) + | isa::Instruction::I32Load8U(..) + | isa::Instruction::I32Load8S(..) + | isa::Instruction::I32Load16U(..) + | isa::Instruction::I32Load16S(..) + | isa::Instruction::I64Load(..) + | isa::Instruction::I64Load8U(..) + | isa::Instruction::I64Load8S(..) + | isa::Instruction::I64Load16U(..) + | isa::Instruction::I64Load16S(..) + | isa::Instruction::I64Load32U(..) + | isa::Instruction::I64Load32S(..) => { + if let RunInstructionTracePre::Load { + offset, + raw_address, + effective_address, + vtype, + load_size, + } = current_event.unwrap() + { + let block_value1 = { + let mut buf = [0u8; 8]; + context + .memory + .clone() + .unwrap() + .get_into(effective_address.unwrap() / 8 * 8, &mut buf) + .unwrap(); + u64::from_le_bytes(buf) + }; + + let block_value2 = + if effective_address.unwrap() % 8 + load_size.byte_size() as u32 > 8 { + let mut buf = [0u8; 8]; + context + .memory + .clone() + .unwrap() + .get_into((effective_address.unwrap() / 8 + 1) * 8, &mut buf) + .unwrap(); + u64::from_le_bytes(buf) + } else { + 0 + }; + + StepInfo::Load { + vtype: vtype.into(), + load_size, + offset, + raw_address, + effective_address: effective_address.unwrap(), + value: from_value_internal_to_u64_with_typ( + vtype.into(), + *value_stack.top(), + ), + block_value1, + block_value2, + } + } else { + unreachable!() + } + } + isa::Instruction::I32Store(..) + | isa::Instruction::I32Store8(..) + | isa::Instruction::I32Store16(..) + | isa::Instruction::I64Store(..) + | isa::Instruction::I64Store8(..) + | isa::Instruction::I64Store16(..) + | isa::Instruction::I64Store32(..) => { + if let RunInstructionTracePre::Store { + offset, + raw_address, + effective_address, + value, + vtype, + store_size, + pre_block_value1, + pre_block_value2, + } = current_event.unwrap() + { + let updated_block_value1 = { + let mut buf = [0u8; 8]; + context + .memory + .clone() + .unwrap() + .get_into(effective_address.unwrap() / 8 * 8, &mut buf) + .unwrap(); + u64::from_le_bytes(buf) + }; + + let updated_block_value2 = + if effective_address.unwrap() % 8 + store_size.byte_size() as u32 > 8 { + let mut buf = [0u8; 8]; + context + .memory + .clone() + .unwrap() + .get_into((effective_address.unwrap() / 8 + 1) * 8, &mut buf) + .unwrap(); + u64::from_le_bytes(buf) + } else { + 0 + }; + + StepInfo::Store { + vtype: vtype.into(), + store_size, + offset, + raw_address, + effective_address: effective_address.unwrap(), + value: value as u64, + pre_block_value1: pre_block_value1.unwrap(), + pre_block_value2: pre_block_value2.unwrap_or(0u64), + updated_block_value1, + updated_block_value2, + } + } else { + unreachable!() + } + } + + isa::Instruction::CurrentMemory => StepInfo::MemorySize, + isa::Instruction::GrowMemory => { + if let RunInstructionTracePre::GrowMemory(grow_size) = current_event.unwrap() { + StepInfo::MemoryGrow { + grow_size, + result: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + + isa::Instruction::I32Const(value) => StepInfo::I32Const { value }, + isa::Instruction::I64Const(value) => StepInfo::I64Const { value }, + + isa::Instruction::I32Eqz => { + if let RunInstructionTracePre::I32Single(value) = current_event.unwrap() { + StepInfo::Test { + vtype: VarType::I32, + value: value as u32 as u64, + result: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32Eq => { + if let RunInstructionTracePre::I32Comp { left, right } = current_event.unwrap() { + StepInfo::I32Comp { + class: RelOp::Eq, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32Ne => { + if let RunInstructionTracePre::I32Comp { left, right } = current_event.unwrap() { + StepInfo::I32Comp { + class: RelOp::Ne, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32GtS => { + if let RunInstructionTracePre::I32Comp { left, right } = current_event.unwrap() { + StepInfo::I32Comp { + class: RelOp::SignedGt, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32GtU => { + if let RunInstructionTracePre::I32Comp { left, right } = current_event.unwrap() { + StepInfo::I32Comp { + class: RelOp::UnsignedGt, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32GeS => { + if let RunInstructionTracePre::I32Comp { left, right } = current_event.unwrap() { + StepInfo::I32Comp { + class: RelOp::SignedGe, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32GeU => { + if let RunInstructionTracePre::I32Comp { left, right } = current_event.unwrap() { + StepInfo::I32Comp { + class: RelOp::UnsignedGe, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32LtS => { + if let RunInstructionTracePre::I32Comp { left, right } = current_event.unwrap() { + StepInfo::I32Comp { + class: RelOp::SignedLt, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32LtU => { + if let RunInstructionTracePre::I32Comp { left, right } = current_event.unwrap() { + StepInfo::I32Comp { + class: RelOp::UnsignedLt, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32LeS => { + if let RunInstructionTracePre::I32Comp { left, right } = current_event.unwrap() { + StepInfo::I32Comp { + class: RelOp::SignedLe, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32LeU => { + if let RunInstructionTracePre::I32Comp { left, right } = current_event.unwrap() { + StepInfo::I32Comp { + class: RelOp::UnsignedLe, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + + isa::Instruction::I64Eqz => { + if let RunInstructionTracePre::I64Single(value) = current_event.unwrap() { + StepInfo::Test { + vtype: VarType::I64, + value: value as u64, + result: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64Eq => { + if let RunInstructionTracePre::I64Comp { left, right } = current_event.unwrap() { + StepInfo::I64Comp { + class: RelOp::Eq, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64Ne => { + if let RunInstructionTracePre::I64Comp { left, right } = current_event.unwrap() { + StepInfo::I64Comp { + class: RelOp::Ne, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64GtS => { + if let RunInstructionTracePre::I64Comp { left, right } = current_event.unwrap() { + StepInfo::I64Comp { + class: RelOp::SignedGt, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64GtU => { + if let RunInstructionTracePre::I64Comp { left, right } = current_event.unwrap() { + StepInfo::I64Comp { + class: RelOp::UnsignedGt, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64LtU => { + if let RunInstructionTracePre::I64Comp { left, right } = current_event.unwrap() { + StepInfo::I64Comp { + class: RelOp::UnsignedLt, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64LtS => { + if let RunInstructionTracePre::I64Comp { left, right } = current_event.unwrap() { + StepInfo::I64Comp { + class: RelOp::SignedLt, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64LeU => { + if let RunInstructionTracePre::I64Comp { left, right } = current_event.unwrap() { + StepInfo::I64Comp { + class: RelOp::UnsignedLe, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64LeS => { + if let RunInstructionTracePre::I64Comp { left, right } = current_event.unwrap() { + StepInfo::I64Comp { + class: RelOp::SignedLe, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64GeU => { + if let RunInstructionTracePre::I64Comp { left, right } = current_event.unwrap() { + StepInfo::I64Comp { + class: RelOp::UnsignedGe, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64GeS => { + if let RunInstructionTracePre::I64Comp { left, right } = current_event.unwrap() { + StepInfo::I64Comp { + class: RelOp::SignedGe, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + + isa::Instruction::I32Add => { + if let RunInstructionTracePre::I32BinOp { left, right } = current_event.unwrap() { + StepInfo::I32BinOp { + class: BinOp::Add, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32Sub => { + if let RunInstructionTracePre::I32BinOp { left, right } = current_event.unwrap() { + StepInfo::I32BinOp { + class: BinOp::Sub, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32Mul => { + if let RunInstructionTracePre::I32BinOp { left, right } = current_event.unwrap() { + StepInfo::I32BinOp { + class: BinOp::Mul, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32DivU => { + if let RunInstructionTracePre::I32BinOp { left, right } = current_event.unwrap() { + StepInfo::I32BinOp { + class: BinOp::UnsignedDiv, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32RemU => { + if let RunInstructionTracePre::I32BinOp { left, right } = current_event.unwrap() { + StepInfo::I32BinOp { + class: BinOp::UnsignedRem, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32DivS => { + if let RunInstructionTracePre::I32BinOp { left, right } = current_event.unwrap() { + StepInfo::I32BinOp { + class: BinOp::SignedDiv, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32RemS => { + if let RunInstructionTracePre::I32BinOp { left, right } = current_event.unwrap() { + StepInfo::I32BinOp { + class: BinOp::SignedRem, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32And => { + if let RunInstructionTracePre::I32BinOp { left, right } = current_event.unwrap() { + StepInfo::I32BinBitOp { + class: BitOp::And, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32Or => { + if let RunInstructionTracePre::I32BinOp { left, right } = current_event.unwrap() { + StepInfo::I32BinBitOp { + class: BitOp::Or, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32Xor => { + if let RunInstructionTracePre::I32BinOp { left, right } = current_event.unwrap() { + StepInfo::I32BinBitOp { + class: BitOp::Xor, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32Shl => { + if let RunInstructionTracePre::I32BinOp { left, right } = current_event.unwrap() { + StepInfo::I32BinShiftOp { + class: ShiftOp::Shl, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32ShrU => { + if let RunInstructionTracePre::I32BinOp { left, right } = current_event.unwrap() { + StepInfo::I32BinShiftOp { + class: ShiftOp::UnsignedShr, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32ShrS => { + if let RunInstructionTracePre::I32BinOp { left, right } = current_event.unwrap() { + StepInfo::I32BinShiftOp { + class: ShiftOp::SignedShr, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32Rotl => { + if let RunInstructionTracePre::I32BinOp { left, right } = current_event.unwrap() { + StepInfo::I32BinShiftOp { + class: ShiftOp::Rotl, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32Rotr => { + if let RunInstructionTracePre::I32BinOp { left, right } = current_event.unwrap() { + StepInfo::I32BinShiftOp { + class: ShiftOp::Rotr, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64Add => { + if let RunInstructionTracePre::I64BinOp { left, right } = current_event.unwrap() { + StepInfo::I64BinOp { + class: BinOp::Add, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64Sub => { + if let RunInstructionTracePre::I64BinOp { left, right } = current_event.unwrap() { + StepInfo::I64BinOp { + class: BinOp::Sub, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64Mul => { + if let RunInstructionTracePre::I64BinOp { left, right } = current_event.unwrap() { + StepInfo::I64BinOp { + class: BinOp::Mul, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64DivU => { + if let RunInstructionTracePre::I64BinOp { left, right } = current_event.unwrap() { + StepInfo::I64BinOp { + class: BinOp::UnsignedDiv, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64RemU => { + if let RunInstructionTracePre::I64BinOp { left, right } = current_event.unwrap() { + StepInfo::I64BinOp { + class: BinOp::UnsignedRem, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64DivS => { + if let RunInstructionTracePre::I64BinOp { left, right } = current_event.unwrap() { + StepInfo::I64BinOp { + class: BinOp::SignedDiv, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64RemS => { + if let RunInstructionTracePre::I64BinOp { left, right } = current_event.unwrap() { + StepInfo::I64BinOp { + class: BinOp::SignedRem, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64And => { + if let RunInstructionTracePre::I64BinOp { left, right } = current_event.unwrap() { + StepInfo::I64BinBitOp { + class: BitOp::And, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64Or => { + if let RunInstructionTracePre::I64BinOp { left, right } = current_event.unwrap() { + StepInfo::I64BinBitOp { + class: BitOp::Or, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64Xor => { + if let RunInstructionTracePre::I64BinOp { left, right } = current_event.unwrap() { + StepInfo::I64BinBitOp { + class: BitOp::Xor, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64Shl => { + if let RunInstructionTracePre::I64BinOp { left, right } = current_event.unwrap() { + StepInfo::I64BinShiftOp { + class: ShiftOp::Shl, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64ShrU => { + if let RunInstructionTracePre::I64BinOp { left, right } = current_event.unwrap() { + StepInfo::I64BinShiftOp { + class: ShiftOp::UnsignedShr, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64ShrS => { + if let RunInstructionTracePre::I64BinOp { left, right } = current_event.unwrap() { + StepInfo::I64BinShiftOp { + class: ShiftOp::SignedShr, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64Rotl => { + if let RunInstructionTracePre::I64BinOp { left, right } = current_event.unwrap() { + StepInfo::I64BinShiftOp { + class: ShiftOp::Rotl, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64Rotr => { + if let RunInstructionTracePre::I64BinOp { left, right } = current_event.unwrap() { + StepInfo::I64BinShiftOp { + class: ShiftOp::Rotr, + left, + right, + value: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + + isa::Instruction::I32Ctz + | isa::Instruction::I32Clz + | isa::Instruction::I32Popcnt + | isa::Instruction::I64Ctz + | isa::Instruction::I64Clz + | isa::Instruction::I64Popcnt => { + if let RunInstructionTracePre::UnaryOp { operand, vtype } = current_event.unwrap() { + StepInfo::UnaryOp { + class: UnaryOp::from(instructions.clone()), + vtype, + operand, + result: from_value_internal_to_u64_with_typ(vtype, *value_stack.top()), + } + } else { + unreachable!() + } + } + + isa::Instruction::I32WrapI64 => { + if let RunInstructionTracePre::I32WrapI64 { value } = current_event.unwrap() { + StepInfo::I32WrapI64 { + value, + result: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64ExtendSI32 | isa::Instruction::I64ExtendUI32 => { + if let RunInstructionTracePre::I64ExtendI32 { value, sign } = current_event.unwrap() + { + StepInfo::I64ExtendI32 { + value, + result: <_>::from_value_internal( *value_stack.top()), + sign, + } + } else { + unreachable!() + } + } + isa::Instruction::I32Extend8S => { + if let RunInstructionTracePre::I32SignExtendI8 { value } = current_event.unwrap() { + StepInfo::I32SignExtendI8 { + value, + result: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I32Extend16S => { + if let RunInstructionTracePre::I32SignExtendI16 { value } = current_event.unwrap() { + StepInfo::I32SignExtendI16 { + value, + result: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64Extend8S => { + if let RunInstructionTracePre::I64SignExtendI8 { value } = current_event.unwrap() { + StepInfo::I64SignExtendI8 { + value, + result: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64Extend16S => { + if let RunInstructionTracePre::I64SignExtendI16 { value } = current_event.unwrap() { + StepInfo::I64SignExtendI16 { + value, + result: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + isa::Instruction::I64Extend32S => { + if let RunInstructionTracePre::I64SignExtendI32 { value } = current_event.unwrap() { + StepInfo::I64SignExtendI32 { + value, + result: <_>::from_value_internal( *value_stack.top()), + } + } else { + unreachable!() + } + } + + _ => { + println!("{:?}", instructions); + unimplemented!() + } + } + } + *) + Definition run_instruction_post (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; module_ref; current_event; value_stack; context; instructions ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let module_ref := M.alloc (| module_ref |) in + let current_event := M.alloc (| current_event |) in + let value_stack := M.alloc (| value_stack |) in + let context := M.alloc (| context |) in + let instructions := M.alloc (| instructions |) in + M.read (| + M.match_operator (| + M.read (| instructions |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::GetLocal", + 0 + |) in + let γ0_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::GetLocal", + 1 + |) in + let depth := M.copy (| γ0_0 |) in + let vtype := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::GetLocal" + [ + ("depth", M.read (| depth |)); + ("value", + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "parity_wasm::elements::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ M.read (| vtype |) ] + |); + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)); + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "parity_wasm::elements::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ M.read (| vtype |) ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::SetLocal", + "depth" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::SetLocal", + "value" + |) in + let γ0_2 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::SetLocal", + "vtype" + |) in + let depth := M.copy (| γ0_0 |) in + let value := M.copy (| γ0_1 |) in + let vtype := M.copy (| γ0_2 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::SetLocal" + [ + ("depth", M.read (| depth |)); + ("value", + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ M.read (| vtype |) ] + |); + M.read (| value |) + ] + |)); + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "parity_wasm::elements::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ M.read (| vtype |) ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::TeeLocal", + 0 + |) in + let γ0_1 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::TeeLocal", + 1 + |) in + let depth := M.copy (| γ0_0 |) in + let vtype := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::TeeLocal" + [ + ("depth", M.read (| depth |)); + ("value", + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "parity_wasm::elements::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ M.read (| vtype |) ] + |); + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)); + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "parity_wasm::elements::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ M.read (| vtype |) ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::GetGlobal", + 0 + |) in + let idx := M.copy (| γ0_0 |) in + let global_ref := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi::global::GlobalRef" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::module::ModuleInstance", + "global_by_index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::module::ModuleRef", + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::FunctionContext", + "module", + [] + |), + [ M.read (| context |) ] + |) + |) + ] + |); + M.read (| idx |) + ] + |) + ] + |) + |) in + let is_mutable := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::global::GlobalInstance", + "is_mutable", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::global::GlobalRef", + [], + "deref", + [] + |), + [ global_ref ] + |) + ] + |) + |) in + let vtype := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "parity_wasm::elements::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi_core::value::ValueType", + "into_elements", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::global::GlobalInstance", + "value_type", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::global::GlobalRef", + [], + "deref", + [] + |), + [ global_ref ] + |) + ] + |) + ] + |) + ] + |) + |) in + let value := + M.alloc (| + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ M.read (| vtype |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "wasmi::runner::ValueInternal", + [ Ty.path "wasmi_core::value::Value" ], + "from", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::global::GlobalInstance", + "get", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::global::GlobalRef", + [], + "deref", + [] + |), + [ global_ref ] + |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::GetGlobal" + [ + ("idx", M.read (| idx |)); + ("vtype", M.read (| vtype |)); + ("is_mutable", M.read (| is_mutable |)); + ("value", M.read (| value |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::SetGlobal", + 0 + |) in + let idx := M.copy (| γ0_0 |) in + let global_ref := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi::global::GlobalRef" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::module::ModuleInstance", + "global_by_index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::module::ModuleRef", + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::FunctionContext", + "module", + [] + |), + [ M.read (| context |) ] + |) + |) + ] + |); + M.read (| idx |) + ] + |) + ] + |) + |) in + let is_mutable := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::global::GlobalInstance", + "is_mutable", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::global::GlobalRef", + [], + "deref", + [] + |), + [ global_ref ] + |) + ] + |) + |) in + let vtype := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "parity_wasm::elements::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi_core::value::ValueType", + "into_elements", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::global::GlobalInstance", + "value_type", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::global::GlobalRef", + [], + "deref", + [] + |), + [ global_ref ] + |) + ] + |) + ] + |) + ] + |) + |) in + let value := + M.alloc (| + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::mtable::VarType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ M.read (| vtype |) ] + |); + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "wasmi::runner::ValueInternal", + [ Ty.path "wasmi_core::value::Value" ], + "from", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::global::GlobalInstance", + "get", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::global::GlobalRef", + [], + "deref", + [] + |), + [ global_ref ] + |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::SetGlobal" + [ + ("idx", M.read (| idx |)); + ("vtype", M.read (| vtype |)); + ("is_mutable", M.read (| is_mutable |)); + ("value", M.read (| value |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::Br", + 0 + |) in + let target := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::Br" + [ + ("dst_pc", + M.read (| + M.SubPointer.get_struct_record_field (| + target, + "wasmi::isa::Target", + "dst_pc" + |) + |)); + ("drop", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + target, + "wasmi::isa::Target", + "drop_keep" + |), + "wasmi::isa::DropKeep", + "drop" + |) + |)); + ("keep", + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + target, + "wasmi::isa::Target", + "drop_keep" + |), + "wasmi::isa::DropKeep", + "keep" + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Keep::Single", + 0 + |) in + let t := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::types::ValueType" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.path + "specs::types::ValueType" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ + Ty.path + "specs::types::ValueType" + ], + "into", + [] + |), + [ M.read (| t |) ] + |) + ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |))) + ] + |) + |)); + ("keep_values", + M.read (| + M.match_operator (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + target, + "wasmi::isa::Target", + "drop_keep" + |), + "wasmi::isa::DropKeep", + "keep" + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Keep::Single", + 0 + |) in + let t := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u64" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "u64" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ + Ty.path + "specs::mtable::VarType" + ], + "into", + [] + |), + [ M.read (| t |) ] + |); + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) + ] + |) + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |))) + ] + |) + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::BrIfEqz", + 0 + |) in + let target := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::BrIfEqz", + "value" + |) in + let value := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::BrIfEqz" + [ + ("condition", M.read (| value |)); + ("dst_pc", + M.read (| + M.SubPointer.get_struct_record_field (| + target, + "wasmi::isa::Target", + "dst_pc" + |) + |)); + ("drop", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + target, + "wasmi::isa::Target", + "drop_keep" + |), + "wasmi::isa::DropKeep", + "drop" + |) + |)); + ("keep", + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + target, + "wasmi::isa::Target", + "drop_keep" + |), + "wasmi::isa::DropKeep", + "keep" + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Keep::Single", + 0 + |) in + let t := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::types::ValueType" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.path + "specs::types::ValueType" + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ + Ty.path + "specs::types::ValueType" + ], + "into", + [] + |), + [ M.read (| t |) ] + |) + ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |))) + ] + |) + |)); + ("keep_values", + M.read (| + M.match_operator (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + target, + "wasmi::isa::Target", + "drop_keep" + |), + "wasmi::isa::DropKeep", + "keep" + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Keep::Single", + 0 + |) in + let t := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "u64" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "u64" ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ + Ty.path + "specs::mtable::VarType" + ], + "into", + [] + |), + [ M.read (| t |) ] + |); + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::runner::ValueStack", + "top", + [] + |), + [ + M.read (| + value_stack + |) + ] + |) + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |))) + ] + |) + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::BrIfNez", + 0 + |) in + let target := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::BrIfNez", + "value" + |) in + let value := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::BrIfNez" + [ + ("condition", M.read (| value |)); + ("dst_pc", + M.read (| + M.SubPointer.get_struct_record_field (| + target, + "wasmi::isa::Target", + "dst_pc" + |) + |)); + ("drop", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + target, + "wasmi::isa::Target", + "drop_keep" + |), + "wasmi::isa::DropKeep", + "drop" + |) + |)); + ("keep", + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + target, + "wasmi::isa::Target", + "drop_keep" + |), + "wasmi::isa::DropKeep", + "keep" + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Keep::Single", + 0 + |) in + let t := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::types::ValueType" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.path + "specs::types::ValueType" + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ + Ty.path + "specs::types::ValueType" + ], + "into", + [] + |), + [ M.read (| t |) ] + |) + ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |))) + ] + |) + |)); + ("keep_values", + M.read (| + M.match_operator (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + target, + "wasmi::isa::Target", + "drop_keep" + |), + "wasmi::isa::DropKeep", + "keep" + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Keep::Single", + 0 + |) in + let t := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "u64" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "u64" ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ + Ty.path + "specs::mtable::VarType" + ], + "into", + [] + |), + [ M.read (| t |) ] + |); + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::runner::ValueStack", + "top", + [] + |), + [ + M.read (| + value_stack + |) + ] + |) + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |))) + ] + |) + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::BrTable", + 0 + |) in + let targets := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::BrTable", + "index" + |) in + let index := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::BrTable" + [ + ("index", M.read (| index |)); + ("dst_pc", + M.read (| + M.SubPointer.get_struct_record_field (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::isa::BrTargets", + "get", + [] + |), + [ targets; M.rust_cast (M.read (| index |)) ] + |) + |), + "wasmi::isa::Target", + "dst_pc" + |) + |)); + ("drop", + M.read (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::isa::BrTargets", + "get", + [] + |), + [ targets; M.rust_cast (M.read (| index |)) ] + |) + |), + "wasmi::isa::Target", + "drop_keep" + |), + "wasmi::isa::DropKeep", + "drop" + |) + |)); + ("keep", + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::isa::BrTargets", + "get", + [] + |), + [ + targets; + M.rust_cast (M.read (| index |)) + ] + |) + |), + "wasmi::isa::Target", + "drop_keep" + |), + "wasmi::isa::DropKeep", + "keep" + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Keep::Single", + 0 + |) in + let t := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::types::ValueType" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.path + "specs::types::ValueType" + ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ + Ty.path + "specs::types::ValueType" + ], + "into", + [] + |), + [ M.read (| t |) ] + |) + ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |))) + ] + |) + |)); + ("keep_values", + M.read (| + M.match_operator (| + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::isa::BrTargets", + "get", + [] + |), + [ targets; M.rust_cast (M.read (| index |)) + ] + |) + |), + "wasmi::isa::Target", + "drop_keep" + |), + "wasmi::isa::DropKeep", + "keep" + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Keep::Single", + 0 + |) in + let t := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "u64" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "u64" ]; + Ty.path + "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ + Ty.path + "specs::mtable::VarType" + ], + "into", + [] + |), + [ M.read (| t |) ] + |); + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::runner::ValueStack", + "top", + [] + |), + [ + M.read (| + value_stack + |) + ] + |) + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |))) + ] + |) + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::Return", + 0 + |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "wasmi::isa::DropKeep", + "drop" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ0_0, + "wasmi::isa::DropKeep", + "keep" + |) in + let drop := M.copy (| γ1_0 |) in + let keep := M.copy (| γ1_1 |) in + let drop_values := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "wasmi::runner::ValueInternal"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::ops::range::RangeInclusive") + [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::ops::range::RangeInclusive") + [ Ty.path "u32" ], + "new", + [] + |), + [ Value.Integer 1; M.read (| drop |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::RangeInclusive") + [ Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "wasmi::runner::ValueInternal"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + drop_values; + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::runner::ValueStack", + "pick", + [] + |), + [ + M.read (| value_stack |); + M.rust_cast (M.read (| i |)) + ] + |) + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::Return" + [ + ("drop", M.read (| drop |)); + ("keep", + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := keep in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Keep::Single", + 0 + |) in + let t := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::types::ValueType" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.path + "specs::types::ValueType" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ + Ty.path + "specs::types::ValueType" + ], + "into", + [] + |), + [ M.read (| t |) ] + |) + ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |))) + ] + |) + |)); + ("keep_values", + M.read (| + M.match_operator (| + keep, + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Keep::Single", + 0 + |) in + let t := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u64" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "u64" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ + Ty.path + "specs::mtable::VarType" + ], + "into", + [] + |), + [ M.read (| t |) ] + |); + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) + ] + |) + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |))) + ] + |) + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + M.alloc (| + Value.StructTuple "specs::step::StepInfo::Drop" [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::Select", + 0 + |) in + let vtype := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Select", + "val1" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Select", + "val2" + |) in + let γ0_2 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Select", + "cond" + |) in + let val1 := M.copy (| γ0_0 |) in + let val2 := M.copy (| γ0_1 |) in + let cond := M.copy (| γ0_2 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::Select" + [ + ("val1", M.read (| val1 |)); + ("val2", M.read (| val2 |)); + ("cond", M.read (| cond |)); + ("result", + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ M.read (| vtype |) ] + |); + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)); + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "parity_wasm::elements::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ M.read (| vtype |) ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::Call", + 0 + |) in + let index := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let desc := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::FuncDesc"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "function_table" + |); + M.rust_cast (M.read (| index |)) + ] + |) + |) in + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| desc |), + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::FuncDesc", + "ftype" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::Call" + [ ("index", M.read (| index |)) ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::types::FunctionType::HostFunction", + "plugin" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::types::FunctionType::HostFunction", + "function_index" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::types::FunctionType::HostFunction", + "function_name" + |) in + let γ1_3 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::types::FunctionType::HostFunction", + "op_index_in_plugin" + |) in + let plugin := M.alloc (| γ1_0 |) in + let host_function_idx := M.alloc (| γ1_1 |) in + let function_name := M.alloc (| γ1_2 |) in + let op_index_in_plugin := M.alloc (| γ1_3 |) in + let params_len := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "wasmi_core::value::ValueType" ], + "len", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::types::Signature", + "params", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| desc |), + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::FuncDesc", + "signature" + |) + ] + |) + ] + |) + |) in + let args := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |) in + let signature := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "wasmi::types::Signature", + [ Ty.path "specs::host_function::Signature" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "wasmi::types::Signature", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| desc |), + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::FuncDesc", + "signature" + |) + ] + |) + ] + |) + |) in + let params := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + signature, + "specs::host_function::Signature", + "params" + |) + ] + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", M.read (| params_len |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::ops::range::Range") + [ Ty.path "usize" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let i := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path "u64"; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + args; + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "specs::types::ValueType", + [ + Ty.path + "specs::mtable::VarType" + ], + "into", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::types::ValueType"; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + params; + M.read (| + i + |) + ] + |) + |) + ] + |); + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::runner::ValueStack", + "pick", + [] + |), + [ + M.read (| + value_stack + |); + BinOp.Panic.sub (| + Integer.Usize, + M.read (| + params_len + |), + M.read (| + i + |) + |) + ] + |) + |) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::CallHost" + [ + ("plugin", M.read (| M.read (| plugin |) |)); + ("host_function_idx", + M.read (| M.read (| host_function_idx |) |)); + ("function_name", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "alloc::string::String", + [], + "clone", + [] + |), + [ M.read (| function_name |) ] + |)); + ("args", M.read (| args |)); + ("ret_val", + Value.StructTuple + "core::option::Option::None" + []); + ("signature", M.read (| signature |)); + ("op_index_in_plugin", + M.read (| M.read (| op_index_in_plugin |) |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::types::FunctionType::HostFunctionExternal", + "op" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::types::FunctionType::HostFunctionExternal", + "sig" + |) in + let op := M.alloc (| γ1_0 |) in + let sig := M.alloc (| γ1_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::ExternalHostCall" + [ + ("op", M.read (| M.read (| op |) |)); + ("value", + M.read (| + M.match_operator (| + sig, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + Value.StructTuple + "specs::mtable::VarType::I64" + []; + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::runner::ValueStack", + "top", + [] + |), + [ + M.read (| + value_stack + |) + ] + |) + |) + ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))) + ] + |) + |)); + ("sig", M.read (| M.read (| sig |) |)) + ] + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::CallIndirect", + 0 + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::CallIndirect", + "table_idx" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::CallIndirect", + "type_idx" + |) in + let γ0_2 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::CallIndirect", + "offset" + |) in + let table_idx := M.copy (| γ0_0 |) in + let type_idx := M.copy (| γ0_1 |) in + let offset := M.copy (| γ0_2 |) in + let table := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi::table::TableRef" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::module::ModuleInstance", + "table_by_index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::module::ModuleRef", + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::FunctionContext", + "module", + [] + |), + [ M.read (| context |) ] + |) + |) + ] + |); + M.read (| + M.get_constant (| + "delphinus_zkwasm::runtime::monitor::plugins::table::DEFAULT_TABLE_INDEX" + |) + |) + ] + |) + ] + |) + |) in + let func_ref := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi::func::FuncRef" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi::func::FuncRef" ]; + Ty.path "wasmi::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::table::TableInstance", + "get", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::table::TableRef", + [], + "deref", + [] + |), + [ table ] + |); + M.read (| offset |) + ] + |) + ] + |) + ] + |) + |) in + let func_index := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::module::ModuleInstance", + "func_index_by_func_ref", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::module::ModuleRef", + [], + "deref", + [] + |), + [ M.read (| module_ref |) ] + |); + func_ref + ] + |) + |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::CallIndirect" + [ + ("table_index", M.read (| table_idx |)); + ("type_index", M.read (| type_idx |)); + ("offset", M.read (| offset |)); + ("func_index", M.read (| func_index |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [] => + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Load", + "offset" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Load", + "raw_address" + |) in + let γ0_2 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Load", + "effective_address" + |) in + let γ0_3 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Load", + "vtype" + |) in + let γ0_4 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Load", + "load_size" + |) in + let offset := M.copy (| γ0_0 |) in + let raw_address := M.copy (| γ0_1 |) in + let effective_address := M.copy (| γ0_2 |) in + let vtype := M.copy (| γ0_3 |) in + let load_size := M.copy (| γ0_4 |) in + let block_value1 := + M.copy (| + let buf := + M.alloc (| repeat (Value.Integer 0) 8 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "wasmi::Error" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::memory::MemoryInstance", + "get_into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "wasmi::memory::MemoryRef", + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "wasmi::memory::MemoryRef" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "wasmi::memory::MemoryRef" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| context |), + "wasmi::runner::FunctionContext", + "memory" + |) + ] + |) + ] + |) + |) + ] + |); + BinOp.Panic.mul (| + Integer.U32, + BinOp.Panic.div (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ Ty.path "u32" ], + "unwrap", + [] + |), + [ M.read (| effective_address |) + ] + |), + Value.Integer 8 + |), + Value.Integer 8 + |); + (* Unsize *) M.pointer_coercion buf + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u64", + "from_le_bytes", + [] + |), + [ M.read (| buf |) ] + |) + |) + |) in + let block_value2 := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (BinOp.Panic.add (| + Integer.U32, + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ Ty.path "u32" ], + "unwrap", + [] + |), + [ + M.read (| + effective_address + |) + ] + |), + Value.Integer 8 + |), + M.read (| + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::mtable::MemoryReadSize", + "byte_size", + [] + |), + [ load_size ] + |) + |)) + |) + |)) + (Value.Integer 8) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let buf := + M.alloc (| + repeat (Value.Integer 0) 8 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "wasmi::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::memory::MemoryInstance", + "get_into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "wasmi::memory::MemoryRef", + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "wasmi::memory::MemoryRef" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "wasmi::memory::MemoryRef" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + context + |), + "wasmi::runner::FunctionContext", + "memory" + |) + ] + |) + ] + |) + |) + ] + |); + BinOp.Panic.mul (| + Integer.U32, + BinOp.Panic.add (| + Integer.U32, + BinOp.Panic.div (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ Ty.path "u32" ], + "unwrap", + [] + |), + [ + M.read (| + effective_address + |) + ] + |), + Value.Integer 8 + |), + Value.Integer 1 + |), + Value.Integer 8 + |); + (* Unsize *) + M.pointer_coercion buf + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u64", + "from_le_bytes", + [] + |), + [ M.read (| buf |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Integer 0 |))) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::Load" + [ + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ M.read (| vtype |) ] + |)); + ("load_size", M.read (| load_size |)); + ("offset", M.read (| offset |)); + ("raw_address", M.read (| raw_address |)); + ("effective_address", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u32" ], + "unwrap", + [] + |), + [ M.read (| effective_address |) ] + |)); + ("value", + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ M.read (| vtype |) ] + |); + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)); + ("block_value1", M.read (| block_value1 |)); + ("block_value2", M.read (| block_value2 |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic", + [] + |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [] => + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Store", + "offset" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Store", + "raw_address" + |) in + let γ0_2 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Store", + "effective_address" + |) in + let γ0_3 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Store", + "value" + |) in + let γ0_4 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Store", + "vtype" + |) in + let γ0_5 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Store", + "store_size" + |) in + let γ0_6 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Store", + "pre_block_value1" + |) in + let γ0_7 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::Store", + "pre_block_value2" + |) in + let offset := M.copy (| γ0_0 |) in + let raw_address := M.copy (| γ0_1 |) in + let effective_address := M.copy (| γ0_2 |) in + let value := M.copy (| γ0_3 |) in + let vtype := M.copy (| γ0_4 |) in + let store_size := M.copy (| γ0_5 |) in + let pre_block_value1 := M.copy (| γ0_6 |) in + let pre_block_value2 := M.copy (| γ0_7 |) in + let updated_block_value1 := + M.copy (| + let buf := + M.alloc (| repeat (Value.Integer 0) 8 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "wasmi::Error" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::memory::MemoryInstance", + "get_into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "wasmi::memory::MemoryRef", + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "wasmi::memory::MemoryRef" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "wasmi::memory::MemoryRef" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| context |), + "wasmi::runner::FunctionContext", + "memory" + |) + ] + |) + ] + |) + |) + ] + |); + BinOp.Panic.mul (| + Integer.U32, + BinOp.Panic.div (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ Ty.path "u32" ], + "unwrap", + [] + |), + [ M.read (| effective_address |) + ] + |), + Value.Integer 8 + |), + Value.Integer 8 + |); + (* Unsize *) M.pointer_coercion buf + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u64", + "from_le_bytes", + [] + |), + [ M.read (| buf |) ] + |) + |) + |) in + let updated_block_value2 := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (BinOp.Panic.add (| + Integer.U32, + BinOp.Panic.rem (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ Ty.path "u32" ], + "unwrap", + [] + |), + [ + M.read (| + effective_address + |) + ] + |), + Value.Integer 8 + |), + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::mtable::MemoryStoreSize", + "byte_size", + [] + |), + [ store_size ] + |)) + |)) + (Value.Integer 8) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let buf := + M.alloc (| + repeat (Value.Integer 0) 8 + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "wasmi::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::memory::MemoryInstance", + "get_into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "wasmi::memory::MemoryRef", + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "wasmi::memory::MemoryRef" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.path + "wasmi::memory::MemoryRef" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| + context + |), + "wasmi::runner::FunctionContext", + "memory" + |) + ] + |) + ] + |) + |) + ] + |); + BinOp.Panic.mul (| + Integer.U32, + BinOp.Panic.add (| + Integer.U32, + BinOp.Panic.div (| + Integer.U32, + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ Ty.path "u32" ], + "unwrap", + [] + |), + [ + M.read (| + effective_address + |) + ] + |), + Value.Integer 8 + |), + Value.Integer 1 + |), + Value.Integer 8 + |); + (* Unsize *) + M.pointer_coercion buf + ] + |) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u64", + "from_le_bytes", + [] + |), + [ M.read (| buf |) ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Integer 0 |))) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::Store" + [ + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ Ty.path "specs::mtable::VarType" ], + "into", + [] + |), + [ M.read (| vtype |) ] + |)); + ("store_size", M.read (| store_size |)); + ("offset", M.read (| offset |)); + ("raw_address", M.read (| raw_address |)); + ("effective_address", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u32" ], + "unwrap", + [] + |), + [ M.read (| effective_address |) ] + |)); + ("value", M.read (| M.use value |)); + ("pre_block_value1", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ], + "unwrap", + [] + |), + [ M.read (| pre_block_value1 |) ] + |)); + ("pre_block_value2", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ], + "unwrap_or", + [] + |), + [ + M.read (| pre_block_value2 |); + Value.Integer 0 + ] + |)); + ("updated_block_value1", + M.read (| updated_block_value1 |)); + ("updated_block_value2", + M.read (| updated_block_value2 |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic", + [] + |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple "specs::step::StepInfo::MemorySize" [] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::GrowMemory", + 0 + |) in + let grow_size := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::MemoryGrow" + [ + ("grow_size", M.read (| grow_size |)); + ("result", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I32Const", + 0 + |) in + let value := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32Const" + [ ("value", M.read (| value |)) ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Instruction::I64Const", + 0 + |) in + let value := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64Const" + [ ("value", M.read (| value |)) ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Single", + 0 + |) in + let value := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::Test" + [ + ("vtype", + Value.StructTuple "specs::mtable::VarType::I32" []); + ("value", M.rust_cast (M.rust_cast (M.read (| value |)))); + ("result", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32Comp" + [ + ("class", + Value.StructTuple "specs::itable::RelOp::Eq" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "bool", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32Comp" + [ + ("class", + Value.StructTuple "specs::itable::RelOp::Ne" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "bool", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32Comp" + [ + ("class", + Value.StructTuple "specs::itable::RelOp::SignedGt" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "bool", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32Comp" + [ + ("class", + Value.StructTuple + "specs::itable::RelOp::UnsignedGt" + []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "bool", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32Comp" + [ + ("class", + Value.StructTuple "specs::itable::RelOp::SignedGe" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "bool", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32Comp" + [ + ("class", + Value.StructTuple + "specs::itable::RelOp::UnsignedGe" + []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "bool", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32Comp" + [ + ("class", + Value.StructTuple "specs::itable::RelOp::SignedLt" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "bool", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32Comp" + [ + ("class", + Value.StructTuple + "specs::itable::RelOp::UnsignedLt" + []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "bool", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32Comp" + [ + ("class", + Value.StructTuple "specs::itable::RelOp::SignedLe" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "bool", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32Comp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32Comp" + [ + ("class", + Value.StructTuple + "specs::itable::RelOp::UnsignedLe" + []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "bool", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Single", + 0 + |) in + let value := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::Test" + [ + ("vtype", + Value.StructTuple "specs::mtable::VarType::I64" []); + ("value", M.rust_cast (M.read (| value |))); + ("result", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64Comp" + [ + ("class", + Value.StructTuple "specs::itable::RelOp::Eq" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "bool", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64Comp" + [ + ("class", + Value.StructTuple "specs::itable::RelOp::Ne" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "bool", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64Comp" + [ + ("class", + Value.StructTuple "specs::itable::RelOp::SignedGt" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "bool", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64Comp" + [ + ("class", + Value.StructTuple + "specs::itable::RelOp::UnsignedGt" + []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "bool", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64Comp" + [ + ("class", + Value.StructTuple + "specs::itable::RelOp::UnsignedLt" + []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "bool", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64Comp" + [ + ("class", + Value.StructTuple "specs::itable::RelOp::SignedLt" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "bool", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64Comp" + [ + ("class", + Value.StructTuple + "specs::itable::RelOp::UnsignedLe" + []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "bool", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64Comp" + [ + ("class", + Value.StructTuple "specs::itable::RelOp::SignedLe" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "bool", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64Comp" + [ + ("class", + Value.StructTuple + "specs::itable::RelOp::UnsignedGe" + []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "bool", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64Comp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64Comp" + [ + ("class", + Value.StructTuple "specs::itable::RelOp::SignedGe" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "bool", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32BinOp" + [ + ("class", + Value.StructTuple "specs::itable::BinOp::Add" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32BinOp" + [ + ("class", + Value.StructTuple "specs::itable::BinOp::Sub" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32BinOp" + [ + ("class", + Value.StructTuple "specs::itable::BinOp::Mul" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32BinOp" + [ + ("class", + Value.StructTuple + "specs::itable::BinOp::UnsignedDiv" + []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32BinOp" + [ + ("class", + Value.StructTuple + "specs::itable::BinOp::UnsignedRem" + []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32BinOp" + [ + ("class", + Value.StructTuple "specs::itable::BinOp::SignedDiv" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32BinOp" + [ + ("class", + Value.StructTuple "specs::itable::BinOp::SignedRem" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32BinBitOp" + [ + ("class", + Value.StructTuple "specs::itable::BitOp::And" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32BinBitOp" + [ + ("class", + Value.StructTuple "specs::itable::BitOp::Or" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32BinBitOp" + [ + ("class", + Value.StructTuple "specs::itable::BitOp::Xor" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32BinShiftOp" + [ + ("class", + Value.StructTuple "specs::itable::ShiftOp::Shl" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32BinShiftOp" + [ + ("class", + Value.StructTuple + "specs::itable::ShiftOp::UnsignedShr" + []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32BinShiftOp" + [ + ("class", + Value.StructTuple + "specs::itable::ShiftOp::SignedShr" + []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32BinShiftOp" + [ + ("class", + Value.StructTuple "specs::itable::ShiftOp::Rotl" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32BinShiftOp" + [ + ("class", + Value.StructTuple "specs::itable::ShiftOp::Rotr" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64BinOp" + [ + ("class", + Value.StructTuple "specs::itable::BinOp::Add" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64BinOp" + [ + ("class", + Value.StructTuple "specs::itable::BinOp::Sub" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64BinOp" + [ + ("class", + Value.StructTuple "specs::itable::BinOp::Mul" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64BinOp" + [ + ("class", + Value.StructTuple + "specs::itable::BinOp::UnsignedDiv" + []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64BinOp" + [ + ("class", + Value.StructTuple + "specs::itable::BinOp::UnsignedRem" + []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64BinOp" + [ + ("class", + Value.StructTuple "specs::itable::BinOp::SignedDiv" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64BinOp" + [ + ("class", + Value.StructTuple "specs::itable::BinOp::SignedRem" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64BinBitOp" + [ + ("class", + Value.StructTuple "specs::itable::BitOp::And" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64BinBitOp" + [ + ("class", + Value.StructTuple "specs::itable::BitOp::Or" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64BinBitOp" + [ + ("class", + Value.StructTuple "specs::itable::BitOp::Xor" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64BinShiftOp" + [ + ("class", + Value.StructTuple "specs::itable::ShiftOp::Shl" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64BinShiftOp" + [ + ("class", + Value.StructTuple + "specs::itable::ShiftOp::UnsignedShr" + []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64BinShiftOp" + [ + ("class", + Value.StructTuple + "specs::itable::ShiftOp::SignedShr" + []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64BinShiftOp" + [ + ("class", + Value.StructTuple "specs::itable::ShiftOp::Rotl" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "left" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64BinOp", + "right" + |) in + let left := M.copy (| γ0_0 |) in + let right := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64BinShiftOp" + [ + ("class", + Value.StructTuple "specs::itable::ShiftOp::Rotr" []); + ("left", M.read (| left |)); + ("right", M.read (| right |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [] => + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::UnaryOp", + "operand" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::UnaryOp", + "vtype" + |) in + let operand := M.copy (| γ0_0 |) in + let vtype := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::UnaryOp" + [ + ("class", + M.call_closure (| + M.get_trait_method (| + "core::convert::From", + Ty.path "specs::itable::UnaryOp", + [ Ty.path "wasmi::isa::Instruction" ], + "from", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "wasmi::isa::Instruction", + [], + "clone", + [] + |), + [ M.read (| instructions |) ] + |) + ] + |)); + ("vtype", M.read (| vtype |)); + ("operand", M.read (| operand |)); + ("result", + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + M.read (| vtype |); + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic", + [] + |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32WrapI64", + "value" + |) in + let value := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32WrapI64" + [ + ("value", M.read (| value |)); + ("result", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => ltac:(M.monadic (Value.Tuple [])); + fun γ => ltac:(M.monadic (Value.Tuple [])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [] => + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64ExtendI32", + "value" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64ExtendI32", + "sign" + |) in + let value := M.copy (| γ0_0 |) in + let sign := M.copy (| γ0_1 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64ExtendI32" + [ + ("value", M.read (| value |)); + ("result", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)); + ("sign", M.read (| sign |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic", + [] + |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32SignExtendI8", + "value" + |) in + let value := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32SignExtendI8" + [ + ("value", M.read (| value |)); + ("result", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I32SignExtendI16", + "value" + |) in + let value := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I32SignExtendI16" + [ + ("value", M.read (| value |)); + ("result", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i32", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64SignExtendI8", + "value" + |) in + let value := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64SignExtendI8" + [ + ("value", M.read (| value |)); + ("result", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64SignExtendI16", + "value" + |) in + let value := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64SignExtendI16" + [ + ("value", M.read (| value |)); + ("result", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "unwrap", + [] + |), + [ M.read (| current_event |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre::I64SignExtendI32", + "value" + |) in + let value := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructRecord + "specs::step::StepInfo::I64SignExtendI32" + [ + ("value", M.read (| value |)); + ("result", + M.call_closure (| + M.get_trait_method (| + "wasmi::runner::FromValueInternal", + Ty.path "i64", + [], + "from_value_internal", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) ] + |) + |) + ] + |)) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let _ := + let _ := + M.alloc (| + M.call_closure (| + M.get_function (| "std::io::stdio::_print", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| Value.String "" |); + M.read (| Value.String " +" |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_debug", + [ + Ty.apply + (Ty.path "&") + [ Ty.path "wasmi::isa::Instruction" ] + ] + |), + [ instructions ] + |) + ] + |)) + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ M.read (| Value.String "not implemented" |) ] + |) + |) + |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_run_instruction_post : + M.IsAssociatedFunction Self "run_instruction_post" run_instruction_post. + End Impl_delphinus_zkwasm_runtime_monitor_plugins_table_TablePlugin. + End instruction. + End table. + End plugins. + End monitor. +End runtime. diff --git a/CoqOfRust/zkWasm/runtime/monitor/plugins/table/mod.v b/CoqOfRust/zkWasm/runtime/monitor/plugins/table/mod.v new file mode 100644 index 000000000..336227bee --- /dev/null +++ b/CoqOfRust/zkWasm/runtime/monitor/plugins/table/mod.v @@ -0,0 +1,6967 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module runtime. + Module monitor. + Module plugins. + Module table. + Definition value_DEFAULT_MEMORY_INDEX : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 0 |))). + + Definition value_DEFAULT_TABLE_INDEX : Value.t := + M.run ltac:(M.monadic (M.alloc (| Value.Integer 0 |))). + + (* StructRecord + { + name := "TablePlugin"; + ty_params := []; + fields := + [ + ("phantom_helper", + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper"); + ("host_function_desc", + Ty.apply + (Ty.path "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "specs::host_function::HostFunctionDesc"; + Ty.path "std::hash::random::RandomState" + ]); + ("function_table", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::FuncDesc"; + Ty.path "alloc::alloc::Global" + ]); + ("itable", Ty.path "specs::itable::InstructionTableInternal"); + ("elements", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "specs::brtable::ElemEntry"; Ty.path "alloc::alloc::Global" ]); + ("configure_table", Ty.path "specs::configure_table::ConfigureTable"); + ("init_memory_table", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "specs::imtable::InitMemoryTableEntry"; Ty.path "alloc::alloc::Global" + ]); + ("static_frame_table", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "specs::jtable::StaticFrameEntry"; Ty.path "alloc::alloc::Global" ]); + ("start_fid", Ty.apply (Ty.path "core::option::Option") [ Ty.path "u32" ]); + ("etable", + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable"); + ("frame_table", Ty.path "specs::jtable::JumpTable"); + ("last_jump_eid", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u32"; Ty.path "alloc::alloc::Global" ]); + ("module_ref", + Ty.apply (Ty.path "core::option::Option") [ Ty.path "wasmi::module::ModuleRef" ]); + ("unresolved_event", + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ]) + ]; + } *) + + Module Impl_delphinus_zkwasm_runtime_monitor_plugins_table_TablePlugin. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin". + + (* + pub fn new( + k: u32, + host_function_desc: HashMap, + phantom_regex: &Vec, + wasm_input: FuncRef, + backend: TraceBackend, + ) -> Self { + Self { + host_function_desc, + + phantom_helper: PhantomHelper::new(phantom_regex, wasm_input), + + itable: InstructionTableInternal::default(), + elements: vec![], + configure_table: ConfigureTable::default(), + init_memory_table: vec![], + function_table: vec![], + static_frame_table: vec![], + start_fid: None, + + last_jump_eid: vec![], + etable: ETable::new(compute_slice_capability(k), backend), + frame_table: JumpTable::default(), + + module_ref: None, + unresolved_event: None, + } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ k; host_function_desc; phantom_regex; wasm_input; backend ] => + ltac:(M.monadic + (let k := M.alloc (| k |) in + let host_function_desc := M.alloc (| host_function_desc |) in + let phantom_regex := M.alloc (| phantom_regex |) in + let wasm_input := M.alloc (| wasm_input |) in + let backend := M.alloc (| backend |) in + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin" + [ + ("host_function_desc", M.read (| host_function_desc |)); + ("phantom_helper", + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "new", + [] + |), + [ M.read (| phantom_regex |); M.read (| wasm_input |) ] + |)); + ("itable", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.path "specs::itable::InstructionTableInternal", + [], + "default", + [] + |), + [] + |)); + ("elements", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "specs::brtable::ElemEntry"; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |)); + ("configure_table", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.path "specs::configure_table::ConfigureTable", + [], + "default", + [] + |), + [] + |)); + ("init_memory_table", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::imtable::InitMemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("function_table", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::FuncDesc"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("static_frame_table", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::jtable::StaticFrameEntry"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |)); + ("start_fid", Value.StructTuple "core::option::Option::None" []); + ("last_jump_eid", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u32"; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |)); + ("etable", + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "new", + [] + |), + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::circuits::compute_slice_capability", + [] + |), + [ M.read (| k |) ] + |); + M.read (| backend |) + ] + |)); + ("frame_table", + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.path "specs::jtable::JumpTable", + [], + "default", + [] + |), + [] + |)); + ("module_ref", Value.StructTuple "core::option::Option::None" []); + ("unresolved_event", Value.StructTuple "core::option::Option::None" []) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + + (* + pub fn into_compilation_table(&self) -> CompilationTable { + let itable: InstructionTable = self.itable.clone().into(); + let imtable = InitMemoryTable::new(self.init_memory_table.clone()); + let br_table = Arc::new(itable.create_brtable()); + let elem_table = Arc::new(ElemTable::new(self.elements.clone())); + let configure_table = Arc::new(self.configure_table.clone()); + let static_jtable = Arc::new(self.static_frame_table.clone().try_into().expect(&format!( + "The number of static frame entries should be {}", + STATIC_FRAME_ENTRY_NUMBER + ))); + let initialization_state = Arc::new(InitializationState { + eid: 1, + fid: self.start_fid.unwrap(), + iid: 0, + frame_id: 0, + sp: DEFAULT_VALUE_STACK_LIMIT as u32 - 1, + + host_public_inputs: 1, + context_in_index: 1, + context_out_index: 1, + external_host_call_call_index: 1, + + initial_memory_pages: configure_table.init_memory_pages, + maximal_memory_pages: configure_table.maximal_memory_pages, + + #[cfg(feature = "continuation")] + jops: num_bigint::BigUint::from(0u64), + + #[cfg(not(feature = "continuation"))] + _phantom: core::marker::PhantomData, + }); + + CompilationTable { + itable: Arc::new(itable), + imtable: Arc::new(imtable), + br_table, + elem_table, + configure_table, + static_jtable, + initialization_state, + } + } + *) + Definition into_compilation_table (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let itable := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "specs::itable::InstructionTableInternal", + [ Ty.path "specs::itable::InstructionTable" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "specs::itable::InstructionTableInternal", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "itable" + |) + ] + |) + ] + |) + |) in + let imtable := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::imtable::InitMemoryTable", + "new", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::imtable::InitMemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "init_memory_table" + |) + ] + |) + ] + |) + |) in + let br_table := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ Ty.path "specs::brtable::BrTable"; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::itable::InstructionTable", + "create_brtable", + [] + |), + [ itable ] + |) + ] + |) + |) in + let elem_table := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ Ty.path "specs::brtable::ElemTable"; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::brtable::ElemTable", + "new", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::brtable::ElemEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "elements" + |) + ] + |) + ] + |) + ] + |) + |) in + let configure_table := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::configure_table::ConfigureTable"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "specs::configure_table::ConfigureTable", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "configure_table" + |) + ] + |) + ] + |) + |) in + let static_jtable := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::jtable::StaticFrameEntry" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::jtable::StaticFrameEntry" ]; + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::jtable::StaticFrameEntry"; + Ty.path "alloc::alloc::Global" + ] + ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::TryInto", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::jtable::StaticFrameEntry"; + Ty.path "alloc::alloc::Global" + ], + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::jtable::StaticFrameEntry" ] + ], + "try_into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::jtable::StaticFrameEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "static_frame_table" + |) + ] + |) + ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "alloc::string::String", + [], + "deref", + [] + |), + [ + let res := + M.alloc (| + M.call_closure (| + M.get_function (| "alloc::fmt::format", [] |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::Arguments", + "new_v1", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "The number of static frame entries should be " + |) + ] + |)); + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "core::fmt::rt::Argument", + "new_display", + [ Ty.path "usize" ] + |), + [ + M.get_constant (| + "specs::jtable::STATIC_FRAME_ENTRY_NUMBER" + |) + ] + |) + ] + |)) + ] + |) + ] + |) + |) in + res + ] + |) + ] + |) + ] + |) + |) in + let initialization_state := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.apply + (Ty.path "specs::state::InitializationState") + [ Ty.path "u32"; Ty.path "num_bigint::biguint::BigUint" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + Value.StructRecord + "specs::state::InitializationState" + [ + ("eid", Value.Integer 1); + ("fid", + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.path "u32" ], + "unwrap", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "start_fid" + |) + |) + ] + |)); + ("iid", Value.Integer 0); + ("frame_id", Value.Integer 0); + ("sp", + BinOp.Panic.sub (| + Integer.U32, + M.rust_cast + (M.read (| + M.get_constant (| + "wasmi::runner::DEFAULT_VALUE_STACK_LIMIT" + |) + |)), + Value.Integer 1 + |)); + ("host_public_inputs", Value.Integer 1); + ("context_in_index", Value.Integer 1); + ("context_out_index", Value.Integer 1); + ("external_host_call_call_index", Value.Integer 1); + ("initial_memory_pages", + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::configure_table::ConfigureTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ configure_table ] + |), + "specs::configure_table::ConfigureTable", + "init_memory_pages" + |) + |)); + ("maximal_memory_pages", + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::configure_table::ConfigureTable"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ configure_table ] + |), + "specs::configure_table::ConfigureTable", + "maximal_memory_pages" + |) + |)); + ("_phantom", Value.StructTuple "core::marker::PhantomData" []) + ] + ] + |) + |) in + M.alloc (| + Value.StructRecord + "specs::CompilationTable" + [ + ("itable", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::itable::InstructionTable"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| itable |) ] + |)); + ("imtable", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::sync::Arc") + [ + Ty.path "specs::imtable::InitMemoryTable"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.read (| imtable |) ] + |)); + ("br_table", M.read (| br_table |)); + ("elem_table", M.read (| elem_table |)); + ("configure_table", M.read (| configure_table |)); + ("static_jtable", M.read (| static_jtable |)); + ("initialization_state", M.read (| initialization_state |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_into_compilation_table : + M.IsAssociatedFunction Self "into_compilation_table" into_compilation_table. + + (* + pub fn into_tables(self) -> Tables { + Tables { + compilation_tables: self.into_compilation_table(), + execution_tables: ExecutionTable { + etable: self.etable.finalized(), + jtable: self.frame_table, + }, + } + } + *) + Definition into_tables (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + Value.StructRecord + "specs::Tables" + [ + ("compilation_tables", + M.call_closure (| + M.get_associated_function (| + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "into_compilation_table", + [] + |), + [ self ] + |)); + ("execution_tables", + Value.StructRecord + "specs::ExecutionTable" + [ + ("etable", + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "finalized", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "etable" + |) + |) + ] + |)); + ("jtable", + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "frame_table" + |) + |)) + ]) + ])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_into_tables : + M.IsAssociatedFunction Self "into_tables" into_tables. + (* + fn push_frame(&mut self, eid: u32, last_jump_eid: u32, callee_fid: u32, fid: u32, iid: u32) { + self.frame_table.push(JumpTableEntry { + eid, + last_jump_eid, + callee_fid, + fid, + iid, + }); + + self.last_jump_eid.push(eid); + } + *) + Definition push_frame (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; eid; last_jump_eid; callee_fid; fid; iid ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let eid := M.alloc (| eid |) in + let last_jump_eid := M.alloc (| last_jump_eid |) in + let callee_fid := M.alloc (| callee_fid |) in + let fid := M.alloc (| fid |) in + let iid := M.alloc (| iid |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::jtable::JumpTable", + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "frame_table" + |); + Value.StructRecord + "specs::jtable::JumpTableEntry" + [ + ("eid", M.read (| eid |)); + ("last_jump_eid", M.read (| last_jump_eid |)); + ("callee_fid", M.read (| callee_fid |)); + ("fid", M.read (| fid |)); + ("iid", M.read (| iid |)) + ] + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u32"; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "last_jump_eid" + |); + M.read (| eid |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_push_frame : M.IsAssociatedFunction Self "push_frame" push_frame. + + (* + fn pop_frame(&mut self) { + self.last_jump_eid.pop(); + } + *) + Definition pop_frame (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u32"; Ty.path "alloc::alloc::Global" ], + "pop", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "last_jump_eid" + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_pop_frame : M.IsAssociatedFunction Self "pop_frame" pop_frame. + + (* + pub fn fill_trace( + &mut self, + current_sp: u32, + allocated_memory_pages: u32, + fid: u32, + callee_sig: &Signature, + keep_value: Option, + wasm_input_func_ref: FuncRef, + ) { + let has_return_value = callee_sig.return_type().is_some(); + + let last_jump_eid = *self.last_jump_eid.last().unwrap(); + + let mut iid = 0; + + let wasm_input_host_func_index = match wasm_input_func_ref.as_internal() { + FuncInstanceInternal::Internal { .. } => unreachable!(), + FuncInstanceInternal::Host { + host_func_index, .. + } => host_func_index, + }; + + if has_return_value { + self.etable.push( + fid, + iid, + current_sp, + allocated_memory_pages, + last_jump_eid, + StepInfo::I32Const { value: 0 }, + ); + + iid += 1; + + self.etable.push( + fid, + iid, + current_sp + 1, + allocated_memory_pages, + last_jump_eid, + StepInfo::CallHost { + plugin: HostPlugin::HostInput, + host_function_idx: *wasm_input_host_func_index, + function_name: "wasm_input".to_owned(), + signature: specs::host_function::Signature { + params: vec![ValueType::I32], + return_type: Some(ValueType::I64), + }, + args: vec![0], + ret_val: Some(keep_value.unwrap()), + op_index_in_plugin: 0, + }, + ); + + iid += 1; + + if callee_sig.return_type() != Some(wasmi::ValueType::I64) { + self.etable.push( + fid, + iid, + current_sp + 1, + allocated_memory_pages, + last_jump_eid, + StepInfo::I32WrapI64 { + value: keep_value.unwrap() as i64, + result: keep_value.unwrap() as i32, + }, + ); + + iid += 1; + } + } + + self.etable.push( + fid, + iid, + current_sp + has_return_value as u32, + allocated_memory_pages, + last_jump_eid, + StepInfo::Return { + drop: callee_sig.params().len() as u32, + keep: if let Some(t) = callee_sig.return_type() { + vec![t.into_elements().into()] + } else { + vec![] + }, + keep_values: keep_value.map_or(vec![], |v| vec![v]), + }, + ); + } + *) + Definition fill_trace (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], + [ + self; + current_sp; + allocated_memory_pages; + fid; + callee_sig; + keep_value; + wasm_input_func_ref + ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let current_sp := M.alloc (| current_sp |) in + let allocated_memory_pages := M.alloc (| allocated_memory_pages |) in + let fid := M.alloc (| fid |) in + let callee_sig := M.alloc (| callee_sig |) in + let keep_value := M.alloc (| keep_value |) in + let wasm_input_func_ref := M.alloc (| wasm_input_func_ref |) in + M.read (| + let has_return_value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi_core::value::ValueType" ], + "is_some", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::types::Signature", + "return_type", + [] + |), + [ M.read (| callee_sig |) ] + |) + |) + ] + |) + |) in + let last_jump_eid := + M.copy (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u32" ], + "last", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u32"; Ty.path "alloc::alloc::Global" ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "last_jump_eid" + |) + ] + |) + ] + |) + ] + |) + |) in + let iid := M.alloc (| Value.Integer 0 |) in + let wasm_input_host_func_index := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::func::FuncInstance", + "as_internal", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::func::FuncRef", + [], + "deref", + [] + |), + [ wasm_input_func_ref ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String "internal error: entered unreachable code" + |) + ] + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "wasmi::func::FuncInstanceInternal::Host", + "host_func_index" + |) in + let host_func_index := M.alloc (| γ1_0 |) in + host_func_index)) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.use has_return_value in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "etable" + |); + M.read (| fid |); + M.read (| iid |); + M.read (| current_sp |); + M.read (| allocated_memory_pages |); + M.read (| last_jump_eid |); + Value.StructRecord + "specs::step::StepInfo::I32Const" + [ ("value", Value.Integer 0) ] + ] + |) + |) in + let _ := + let β := iid in + M.write (| + β, + BinOp.Panic.add (| Integer.U32, M.read (| β |), Value.Integer 1 |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "etable" + |); + M.read (| fid |); + M.read (| iid |); + BinOp.Panic.add (| + Integer.U32, + M.read (| current_sp |), + Value.Integer 1 + |); + M.read (| allocated_memory_pages |); + M.read (| last_jump_eid |); + Value.StructRecord + "specs::step::StepInfo::CallHost" + [ + ("plugin", + Value.StructTuple + "specs::host_function::HostPlugin::HostInput" + []); + ("host_function_idx", + M.read (| M.read (| wasm_input_host_func_index |) |)); + ("function_name", + M.call_closure (| + M.get_trait_method (| + "alloc::borrow::ToOwned", + Ty.path "str", + [], + "to_owned", + [] + |), + [ M.read (| Value.String "wasm_input" |) ] + |)); + ("signature", + Value.StructRecord + "specs::host_function::Signature" + [ + ("params", + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::types::ValueType" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ + Ty.path + "specs::types::ValueType" + ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.StructTuple + "specs::types::ValueType::I32" + [] + ] + |) + ] + |) + |)) + ] + |)); + ("return_type", + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "specs::types::ValueType::I64" + [] + ]) + ]); + ("args", + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u64" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "u64" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ M.alloc (| Value.Array [ Value.Integer 0 ] |) + ] + |) + |)) + ] + |)); + ("ret_val", + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ], + "unwrap", + [] + |), + [ M.read (| keep_value |) ] + |) + ]); + ("op_index_in_plugin", Value.Integer 0) + ] + ] + |) + |) in + let _ := + let β := iid in + M.write (| + β, + BinOp.Panic.add (| Integer.U32, M.read (| β |), Value.Integer 1 |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi_core::value::ValueType" ], + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi_core::value::ValueType" ] + ], + "ne", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::types::Signature", + "return_type", + [] + |), + [ M.read (| callee_sig |) ] + |) + |); + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + Value.StructTuple + "wasmi_core::value::ValueType::I64" + [] + ] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "etable" + |); + M.read (| fid |); + M.read (| iid |); + BinOp.Panic.add (| + Integer.U32, + M.read (| current_sp |), + Value.Integer 1 + |); + M.read (| allocated_memory_pages |); + M.read (| last_jump_eid |); + Value.StructRecord + "specs::step::StepInfo::I32WrapI64" + [ + ("value", + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ], + "unwrap", + [] + |), + [ M.read (| keep_value |) ] + |))); + ("result", + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u64" ], + "unwrap", + [] + |), + [ M.read (| keep_value |) ] + |))) + ] + ] + |) + |) in + let _ := + let β := iid in + M.write (| + β, + BinOp.Panic.add (| + Integer.U32, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "etable" + |); + M.read (| fid |); + M.read (| iid |); + BinOp.Panic.add (| + Integer.U32, + M.read (| current_sp |), + M.rust_cast (M.read (| has_return_value |)) + |); + M.read (| allocated_memory_pages |); + M.read (| last_jump_eid |); + Value.StructRecord + "specs::step::StepInfo::Return" + [ + ("drop", + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "wasmi_core::value::ValueType" ], + "len", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::types::Signature", + "params", + [] + |), + [ M.read (| callee_sig |) ] + |) + ] + |))); + ("keep", + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::types::Signature", + "return_type", + [] + |), + [ M.read (| callee_sig |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let t := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::types::ValueType" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "specs::types::ValueType" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ + Ty.path + "specs::types::ValueType" + ], + "into", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi_core::value::ValueType", + "into_elements", + [] + |), + [ M.read (| t |) ] + |) + ] + |) + ] + |) + ] + |) + |)) + ] + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::types::ValueType"; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [] + |) + |))) + ] + |) + |)); + ("keep_values", + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "core::option::Option") [ Ty.path "u64" ], + "map_or", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ]; + Ty.function + [ Ty.tuple [ Ty.path "u64" ] ] + (Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ]) + ] + |), + [ + M.read (| keep_value |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u64"; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let v := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "u64" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "u64" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array [ M.read (| v |) ] + |) + ] + |) + |)) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |)) + ] + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_fill_trace : M.IsAssociatedFunction Self "fill_trace" fill_trace. + End Impl_delphinus_zkwasm_runtime_monitor_plugins_table_TablePlugin. + + + Module Impl_wasmi_monitor_Monitor_for_delphinus_zkwasm_runtime_monitor_plugins_table_TablePlugin. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin". + + (* + fn register_module( + &mut self, + module: &parity_wasm::elements::Module, + module_ref: &wasmi::ModuleRef, + entry: &str, + ) -> Result<(), wasmi::Error> { + self.module_ref = Some(module_ref.clone()); + + self.phantom_helper + .register_module(module, module_ref, entry)?; + + let mut type_idx_of_func = vec![]; + + // register static frame entries + { + let zkmain = module_ref.func_by_name(entry)?; + let zkmain_idx = match zkmain.as_internal() { + FuncInstanceInternal::Internal { index, .. } => index, + _ => unreachable!(), + }; + + self.static_frame_table.push(StaticFrameEntry { + enable: true, + frame_id: 0, + next_frame_id: 0, + callee_fid: *zkmain_idx as u32, + fid: 0, + iid: 0, + }); + + if let Some(start_idx) = module.start_section() { + self.static_frame_table.push(StaticFrameEntry { + enable: true, + frame_id: 0, + next_frame_id: 0, + callee_fid: start_idx, + fid: *zkmain_idx as u32, + iid: 0, + }); + + self.start_fid = Some(start_idx); + } else { + self.static_frame_table.push(StaticFrameEntry { + enable: false, + frame_id: 0, + next_frame_id: 0, + callee_fid: 0, + fid: 0, + iid: 0, + }); + + self.start_fid = Some( *zkmain_idx as u32); + } + } + + { + for import_entry in module.import_section().map(|s| s.entries()).unwrap_or(&[]) { + match *import_entry.external() { + External::Function(fn_ty_idx) => { + type_idx_of_func.push(fn_ty_idx); + } + _ => {} + } + } + + let funcs = module + .function_section() + .map(|fs| fs.entries()) + .unwrap_or(&[]); + + for func in funcs { + type_idx_of_func.push(func.type_ref()) + } + } + + // register functions + { + let mut fid = 0; + + while let Some(ref func) = module_ref.func_by_index(fid) { + let ftype = match *func.as_internal() { + FuncInstanceInternal::Internal { .. } => FunctionType::WasmFunction, + FuncInstanceInternal::Host { + host_func_index, .. + } => match self + .host_function_desc + .get(&host_func_index) + .cloned() + .unwrap() + { + HostFunctionDesc::Internal { + name, + op_index_in_plugin, + plugin, + } => FunctionType::HostFunction { + plugin, + function_index: host_func_index, + function_name: name, + op_index_in_plugin, + }, + HostFunctionDesc::External { name, op, sig } => { + FunctionType::HostFunctionExternal { + function_name: name, + op, + sig, + } + } + }, + }; + + self.function_table.push(FuncDesc { + ftype, + signature: func.signature().clone(), + }); + + fid += 1; + } + + let mut fid = 0; + while let Some(ref func) = module_ref.func_by_index(fid) { + let function_mapping = |index| self.function_table.get(index as usize).unwrap(); + + if self.phantom_helper.is_phantom_function(fid) { + let wasm_input_func_idx = self.phantom_helper.wasm_input_func_idx(module_ref); + + let instructions = PhantomFunction::build_phantom_function_instructions( + &func.signature(), + wasm_input_func_idx, + ); + + for (iid, instruction) in instructions.into_iter().enumerate() { + self.itable.push( + fid, + iid as u32, + instruction.into_opcode(&function_mapping), + ); + } + } else { + if let Some(body) = func.body() { + let code = &body.code; + + let mut iter = code.iterate_from(0); + let mut iid = iter.position(); + while let Some(instr) = iter.next() { + self.itable + .push(fid, iid, instr.into_opcode(&function_mapping)); + + iid = iter.position(); + } + } + } + + fid += 1; + } + } + + // register globals + for (global_idx, global_ref) in module_ref.globals().iter().enumerate() { + self.init_memory_table.push(InitMemoryTableEntry { + is_mutable: global_ref.is_mutable(), + ltype: LocationType::Global, + offset: global_idx as u32, + vtype: global_ref.value_type().into_elements().into(), + value: global_ref.get().into(), + eid: 0, + }); + } + + // register memory + if let Some(memory_ref) = module_ref.memory_by_index(DEFAULT_MEMORY_INDEX) { + // one page contains 64KB*1024/8=8192 u64 entries + const ENTRIES: u32 = 8192; + + let init_memory_pages = memory_ref.initial().0 as u32; + let maximal_memory_pages = memory_ref.maximum().map_or(65536, |max| max.0 as u32); + + self.configure_table = ConfigureTable { + init_memory_pages, + maximal_memory_pages, + }; + + for offset in 0..(init_memory_pages * ENTRIES) { + let mut buf = [0u8; 8]; + memory_ref.get_into(offset * 8, &mut buf)?; + + let value = u64::from_le_bytes(buf); + if value != 0 { + self.init_memory_table.push(InitMemoryTableEntry { + is_mutable: true, + ltype: LocationType::Heap, + offset, + vtype: VarType::I64, + value, + eid: 0, + }); + } + } + } + + // for data_segment in module.data_section().map(|ds| ds.entries()).unwrap_or(&[]) { + // let offset = data_segment + // .offset() + // .as_ref() + // .expect("passive segments are rejected due to validation"); + // let offset_val = match eval_init_expr(offset, &module_ref) { + // RuntimeValue::I32(v) => v as u32, + // _ => panic!("Due to validation data segment offset should evaluate to i32"), + // }; + + // let memory_inst = module_ref + // .memory_by_index(DEFAULT_MEMORY_INDEX) + // .expect("Due to validation default memory should exists"); + // memory_inst.set(offset_val, data_segment.value())?; + + // todo!() + // } + + for element_segment in module + .elements_section() + .map(|es| es.entries()) + .unwrap_or(&[]) + { + let offset = element_segment + .offset() + .as_ref() + .expect("passive segments are rejected due to validation"); + let offset_val = match eval_init_expr(offset, &module_ref) { + RuntimeValue::I32(v) => v as u32, + _ => panic!("Due to validation elem segment offset should evaluate to i32"), + }; + + let table_inst = module_ref + .table_by_index(DEFAULT_TABLE_INDEX) + .expect("Due to validation default table should exists"); + + // This check is not only for bailing out early, but also to check the case when + // segment consist of 0 members. + if offset_val as u64 + element_segment.members().len() as u64 + > table_inst.current_size() as u64 + { + return Err(Error::Instantiation( + "elements segment does not fit".to_string(), + )); + } + + for (j, func_idx) in element_segment.members().iter().enumerate() { + self.elements.push(ElemEntry { + table_idx: DEFAULT_TABLE_INDEX, + type_idx: type_idx_of_func[*func_idx as usize], + offset: offset_val + j as u32, + func_idx: *func_idx, + }); + } + } + + assert_eq!(self.function_table.len(), type_idx_of_func.len()); + + Ok(()) + } + *) + Definition register_module (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; module; module_ref; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let module := M.alloc (| module |) in + let module_ref := M.alloc (| module_ref |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "module_ref" + |), + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "wasmi::module::ModuleRef", + [], + "clone", + [] + |), + [ M.read (| module_ref |) ] + |) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "wasmi::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "wasmi::monitor::Monitor", + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + [], + "register_module", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "phantom_helper" + |); + M.read (| module |); + M.read (| module_ref |); + M.read (| entry |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "wasmi::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "wasmi::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let type_idx_of_func := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u32"; Ty.path "alloc::alloc::Global" ], + "new", + [] + |), + [] + |) + |) in + let _ := + let zkmain := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "wasmi::func::FuncRef"; Ty.path "wasmi::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::module::ModuleInstance", + "func_by_name", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::module::ModuleRef", + [], + "deref", + [] + |), + [ M.read (| module_ref |) ] + |); + M.read (| entry |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "wasmi::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "wasmi::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let zkmain_idx := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::func::FuncInstance", + "as_internal", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::func::FuncRef", + [], + "deref", + [] + |), + [ zkmain ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "wasmi::func::FuncInstanceInternal::Internal", + "index" + |) in + let index := M.alloc (| γ1_0 |) in + index)); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::jtable::StaticFrameEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "static_frame_table" + |); + Value.StructRecord + "specs::jtable::StaticFrameEntry" + [ + ("enable", Value.Bool true); + ("frame_id", Value.Integer 0); + ("next_frame_id", Value.Integer 0); + ("callee_fid", + M.rust_cast (M.read (| M.read (| zkmain_idx |) |))); + ("fid", Value.Integer 0); + ("iid", Value.Integer 0) + ] + ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "parity_wasm::elements::module::Module", + "start_section", + [] + |), + [ M.read (| module |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let start_idx := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::jtable::StaticFrameEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "static_frame_table" + |); + Value.StructRecord + "specs::jtable::StaticFrameEntry" + [ + ("enable", Value.Bool true); + ("frame_id", Value.Integer 0); + ("next_frame_id", Value.Integer 0); + ("callee_fid", M.read (| start_idx |)); + ("fid", + M.rust_cast (M.read (| M.read (| zkmain_idx |) |))); + ("iid", Value.Integer 0) + ] + ] + |) + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "start_fid" + |), + Value.StructTuple + "core::option::Option::Some" + [ M.read (| start_idx |) ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::jtable::StaticFrameEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "static_frame_table" + |); + Value.StructRecord + "specs::jtable::StaticFrameEntry" + [ + ("enable", Value.Bool false); + ("frame_id", Value.Integer 0); + ("next_frame_id", Value.Integer 0); + ("callee_fid", Value.Integer 0); + ("fid", Value.Integer 0); + ("iid", Value.Integer 0) + ] + ] + |) + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "start_fid" + |), + Value.StructTuple + "core::option::Option::Some" + [ M.rust_cast (M.read (| M.read (| zkmain_idx |) |)) ] + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.path + "parity_wasm::elements::import_entry::ImportEntry" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.path + "parity_wasm::elements::import_entry::ImportEntry" + ] + ] + ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "parity_wasm::elements::section::ImportSection" + ] + ], + "map", + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.path + "parity_wasm::elements::import_entry::ImportEntry" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "parity_wasm::elements::section::ImportSection" + ] + ] + ] + (Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.path + "parity_wasm::elements::import_entry::ImportEntry" + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "parity_wasm::elements::module::Module", + "import_section", + [] + |), + [ M.read (| module |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let s := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.path + "parity_wasm::elements::section::ImportSection", + "entries", + [] + |), + [ M.read (| s |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + (* Unsize *) + M.pointer_coercion (M.alloc (| Value.Array [] |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "parity_wasm::elements::import_entry::ImportEntry" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let import_entry := M.copy (| γ0_0 |) in + M.match_operator (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "parity_wasm::elements::import_entry::ImportEntry", + "external", + [] + |), + [ M.read (| import_entry |) ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "parity_wasm::elements::import_entry::External::Function", + 0 + |) in + let fn_ty_idx := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + type_idx_of_func; + M.read (| fn_ty_idx |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let funcs := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.path "parity_wasm::elements::func::Func" ] + ] + ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "parity_wasm::elements::section::FunctionSection" + ] + ], + "map", + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.path "parity_wasm::elements::func::Func" ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "parity_wasm::elements::section::FunctionSection" + ] + ] + ] + (Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.path "parity_wasm::elements::func::Func" ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "parity_wasm::elements::module::Module", + "function_section", + [] + |), + [ M.read (| module |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let fs := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.path + "parity_wasm::elements::section::FunctionSection", + "entries", + [] + |), + [ M.read (| fs |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + (* Unsize *) M.pointer_coercion (M.alloc (| Value.Array [] |)) + ] + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.path "parity_wasm::elements::func::Func" ] + ], + [], + "into_iter", + [] + |), + [ M.read (| funcs |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "parity_wasm::elements::func::Func" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let func := M.copy (| γ0_0 |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + type_idx_of_func; + M.call_closure (| + M.get_associated_function (| + Ty.path + "parity_wasm::elements::func::Func", + "type_ref", + [] + |), + [ M.read (| func |) ] + |) + ] + |) + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + let fid := M.alloc (| Value.Integer 0 |) in + let _ := + M.loop (| + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::module::ModuleInstance", + "func_by_index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::module::ModuleRef", + [], + "deref", + [] + |), + [ M.read (| module_ref |) ] + |); + M.read (| fid |) + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let func := M.alloc (| γ0_0 |) in + let ftype := + M.copy (| + M.match_operator (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::func::FuncInstance", + "as_internal", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::func::FuncRef", + [], + "deref", + [] + |), + [ M.read (| func |) ] + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "specs::types::FunctionType::WasmFunction" + [] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "wasmi::func::FuncInstanceInternal::Host", + "host_func_index" + |) in + let host_func_index := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "specs::host_function::HostFunctionDesc" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "specs::host_function::HostFunctionDesc" + ] + ], + "cloned", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path + "specs::host_function::HostFunctionDesc"; + Ty.path + "std::hash::random::RandomState" + ], + "get", + [ Ty.path "usize" ] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "host_function_desc" + |); + host_func_index + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::host_function::HostFunctionDesc::Internal", + "name" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::host_function::HostFunctionDesc::Internal", + "op_index_in_plugin" + |) in + let γ0_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::host_function::HostFunctionDesc::Internal", + "plugin" + |) in + let name := M.copy (| γ0_0 |) in + let op_index_in_plugin := + M.copy (| γ0_1 |) in + let plugin := M.copy (| γ0_2 |) in + M.alloc (| + Value.StructRecord + "specs::types::FunctionType::HostFunction" + [ + ("plugin", M.read (| plugin |)); + ("function_index", + M.read (| host_func_index |)); + ("function_name", + M.read (| name |)); + ("op_index_in_plugin", + M.read (| op_index_in_plugin |)) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::host_function::HostFunctionDesc::External", + "name" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::host_function::HostFunctionDesc::External", + "op" + |) in + let γ0_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::host_function::HostFunctionDesc::External", + "sig" + |) in + let name := M.copy (| γ0_0 |) in + let op := M.copy (| γ0_1 |) in + let sig := M.copy (| γ0_2 |) in + M.alloc (| + Value.StructRecord + "specs::types::FunctionType::HostFunctionExternal" + [ + ("function_name", + M.read (| name |)); + ("op", M.read (| op |)); + ("sig", M.read (| sig |)) + ] + |))) + ] + |))) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::FuncDesc"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "function_table" + |); + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::FuncDesc" + [ + ("ftype", M.read (| ftype |)); + ("signature", + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "wasmi::types::Signature", + [], + "clone", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::func::FuncInstance", + "signature", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::func::FuncRef", + [], + "deref", + [] + |), + [ M.read (| func |) ] + |) + ] + |) + ] + |)) + ] + ] + |) + |) in + let _ := + let β := fid in + M.write (| + β, + BinOp.Panic.add (| + Integer.U32, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + let _ := + M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |) in + M.alloc (| Value.Tuple [] |) + |) + |) + |))) + ] + |))) + |) in + let fid := M.alloc (| Value.Integer 0 |) in + M.loop (| + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::module::ModuleInstance", + "func_by_index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::module::ModuleRef", + [], + "deref", + [] + |), + [ M.read (| module_ref |) ] + |); + M.read (| fid |) + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let func := M.alloc (| γ0_0 |) in + let function_mapping := + M.alloc (| + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let index := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::FuncDesc" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::FuncDesc" + ], + "get", + [ Ty.path "usize" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::FuncDesc"; + Ty.path + "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "function_table" + |) + ] + |); + M.rust_cast (M.read (| index |)) + ] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "is_phantom_function", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "phantom_helper" + |); + M.read (| fid |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let wasm_input_func_idx := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "wasm_input_func_idx", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "phantom_helper" + |); + M.read (| module_ref |) + ] + |) + |) in + let instructions := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::PhantomFunction", + "build_phantom_function_instructions", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::func::FuncInstance", + "signature", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::func::FuncRef", + [], + "deref", + [] + |), + [ M.read (| func |) ] + |) + ] + |); + M.read (| wasm_input_func_idx |) + ] + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.path "wasmi::isa::Instruction"; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.path "wasmi::isa::Instruction"; + Ty.path "alloc::alloc::Global" + ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "wasmi::isa::Instruction"; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ M.read (| instructions |) ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.path + "wasmi::isa::Instruction"; + Ty.path + "alloc::alloc::Global" + ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let iid := + M.copy (| γ1_0 |) in + let instruction := + M.copy (| γ1_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::itable::InstructionTableInternal", + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "itable" + |); + M.read (| fid |); + M.rust_cast + (M.read (| iid |)); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::InstructionIntoOpcode", + Ty.path + "wasmi::isa::Instruction", + [], + "into_opcode", + [ + Ty.function + [ + Ty.tuple + [ + Ty.path + "u32" + ] + ] + (Ty.apply + (Ty.path + "&") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::FuncDesc" + ]) + ] + |), + [ + M.read (| + instruction + |); + function_mapping + ] + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::func::FuncInstance", + "body", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::func::FuncRef", + [], + "deref", + [] + |), + [ M.read (| func |) ] + |) + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let body := M.copy (| γ0_0 |) in + let code := + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.path "wasmi::func::FuncBody"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ body ] + |), + "wasmi::func::FuncBody", + "code" + |) + |) in + let iter := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::isa::Instructions", + "iterate_from", + [] + |), + [ M.read (| code |); Value.Integer 0 ] + |) + |) in + let iid := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::isa::InstructionIter", + "position", + [] + |), + [ iter ] + |) + |) in + M.loop (| + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.path + "wasmi::isa::InstructionIter", + [], + "next", + [] + |), + [ iter ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let instr := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::itable::InstructionTableInternal", + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "itable" + |); + M.read (| fid |); + M.read (| iid |); + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::InstructionIntoOpcode", + Ty.path + "wasmi::isa::Instruction", + [], + "into_opcode", + [ + Ty.function + [ + Ty.tuple + [ + Ty.path + "u32" + ] + ] + (Ty.apply + (Ty.path "&") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::FuncDesc" + ]) + ] + |), + [ + M.read (| instr |); + function_mapping + ] + |) + ] + |) + |) in + let _ := + M.write (| + iid, + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::isa::InstructionIter", + "position", + [] + |), + [ iter ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + let _ := + M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |) in + M.alloc (| Value.Tuple [] |) + |) + |) + |))) + ] + |))) + |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + let _ := + let β := fid in + M.write (| + β, + BinOp.Panic.add (| + Integer.U32, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + let _ := + M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |) in + M.alloc (| Value.Tuple [] |) + |) + |) + |))) + ] + |))) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "wasmi::global::GlobalRef" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "wasmi::global::GlobalRef" ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "wasmi::global::GlobalRef" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "wasmi::global::GlobalRef"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "core::cell::Ref") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "wasmi::global::GlobalRef"; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::module::ModuleInstance", + "globals", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::module::ModuleRef", + [], + "deref", + [] + |), + [ M.read (| module_ref |) ] + |) + ] + |) + |) + ] + |) + ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "wasmi::global::GlobalRef" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| γ0_0, 0 |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| γ0_0, 1 |) in + let global_idx := M.copy (| γ1_0 |) in + let global_ref := M.copy (| γ1_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "specs::imtable::InitMemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "init_memory_table" + |); + Value.StructRecord + "specs::imtable::InitMemoryTableEntry" + [ + ("is_mutable", + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::global::GlobalInstance", + "is_mutable", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "wasmi::global::GlobalRef", + [], + "deref", + [] + |), + [ M.read (| global_ref |) ] + |) + ] + |)); + ("ltype", + Value.StructTuple + "specs::mtable::LocationType::Global" + []); + ("offset", + M.rust_cast + (M.read (| global_idx |))); + ("vtype", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ Ty.path "specs::mtable::VarType" + ], + "into", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi_core::value::ValueType", + "into_elements", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::global::GlobalInstance", + "value_type", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "wasmi::global::GlobalRef", + [], + "deref", + [] + |), + [ + M.read (| + global_ref + |) + ] + |) + ] + |) + ] + |) + ] + |)); + ("value", + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "wasmi_core::value::Value", + [ Ty.path "u64" ], + "into", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::global::GlobalInstance", + "get", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "wasmi::global::GlobalRef", + [], + "deref", + [] + |), + [ M.read (| global_ref |) ] + |) + ] + |) + ] + |)); + ("eid", Value.Integer 0) + ] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::module::ModuleInstance", + "memory_by_index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::module::ModuleRef", + [], + "deref", + [] + |), + [ M.read (| module_ref |) ] + |); + M.read (| + M.get_constant (| + "delphinus_zkwasm::runtime::monitor::plugins::table::DEFAULT_MEMORY_INDEX" + |) + |) + ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let memory_ref := M.copy (| γ0_0 |) in + let init_memory_pages := + M.alloc (| + M.rust_cast + (M.read (| + M.SubPointer.get_struct_tuple_field (| + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::memory::MemoryInstance", + "initial", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::memory::MemoryRef", + [], + "deref", + [] + |), + [ memory_ref ] + |) + ] + |) + |), + "memory_units::wasm32::Pages", + 0 + |) + |)) + |) in + let maximal_memory_pages := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "memory_units::wasm32::Pages" ], + "map_or", + [ + Ty.path "u32"; + Ty.function + [ Ty.tuple [ Ty.path "memory_units::wasm32::Pages" ] ] + (Ty.path "u32") + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::memory::MemoryInstance", + "maximum", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::memory::MemoryRef", + [], + "deref", + [] + |), + [ memory_ref ] + |) + ] + |); + Value.Integer 65536; + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let max := M.copy (| γ |) in + M.rust_cast + (M.read (| + M.SubPointer.get_struct_tuple_field (| + max, + "memory_units::wasm32::Pages", + 0 + |) + |)))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "configure_table" + |), + Value.StructRecord + "specs::configure_table::ConfigureTable" + [ + ("init_memory_pages", M.read (| init_memory_pages |)); + ("maximal_memory_pages", M.read (| maximal_memory_pages |)) + ] + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "into_iter", + [] + |), + [ + Value.StructRecord + "core::ops::range::Range" + [ + ("start", Value.Integer 0); + ("end_", + BinOp.Panic.mul (| + Integer.U32, + M.read (| init_memory_pages |), + M.read (| + M.get_constant (| + "delphinus_zkwasm::runtime::monitor::plugins::table::register_module::ENTRIES" + |) + |) + |)) + ] + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::ops::range::Range") + [ Ty.path "u32" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| M.break (||) |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let offset := M.copy (| γ0_0 |) in + let buf := + M.alloc (| + repeat (Value.Integer 0) 8 + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "wasmi::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::memory::MemoryInstance", + "get_into", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "wasmi::memory::MemoryRef", + [], + "deref", + [] + |), + [ memory_ref ] + |); + BinOp.Panic.mul (| + Integer.U32, + M.read (| offset |), + Value.Integer 8 + |); + (* Unsize *) + M.pointer_coercion buf + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := + M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.tuple []; + Ty.path + "wasmi::Error" + ], + [ + Ty.apply + (Ty.path + "core::result::Result") + [ + Ty.path + "core::convert::Infallible"; + Ty.path + "wasmi::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) + ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let value := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "u64", + "from_le_bytes", + [] + |), + [ M.read (| buf |) ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.ne + (M.read (| value |)) + (Value.Integer 0) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::imtable::InitMemoryTableEntry"; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "init_memory_table" + |); + Value.StructRecord + "specs::imtable::InitMemoryTableEntry" + [ + ("is_mutable", + Value.Bool true); + ("ltype", + Value.StructTuple + "specs::mtable::LocationType::Heap" + []); + ("offset", + M.read (| offset |)); + ("vtype", + Value.StructTuple + "specs::mtable::VarType::I64" + []); + ("value", + M.read (| value |)); + ("eid", Value.Integer 0) + ] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ Ty.path "parity_wasm::elements::segment::ElementSegment" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.path + "parity_wasm::elements::segment::ElementSegment" + ] + ] + ], + "unwrap_or", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "parity_wasm::elements::section::ElementSection" + ] + ], + "map", + [ + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.path + "parity_wasm::elements::segment::ElementSegment" + ] + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "parity_wasm::elements::section::ElementSection" + ] + ] + ] + (Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "slice") + [ + Ty.path + "parity_wasm::elements::segment::ElementSegment" + ] + ]) + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "parity_wasm::elements::module::Module", + "elements_section", + [] + |), + [ M.read (| module |) ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let es := M.copy (| γ |) in + M.call_closure (| + M.get_associated_function (| + Ty.path + "parity_wasm::elements::section::ElementSection", + "entries", + [] + |), + [ M.read (| es |) ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |); + (* Unsize *) M.pointer_coercion (M.alloc (| Value.Array [] |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ + Ty.path + "parity_wasm::elements::segment::ElementSegment" + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let element_segment := M.copy (| γ0_0 |) in + let offset := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "parity_wasm::elements::ops::InitExpr" + ] + ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "parity_wasm::elements::ops::InitExpr" + ], + "as_ref", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "parity_wasm::elements::segment::ElementSegment", + "offset", + [] + |), + [ M.read (| element_segment |) ] + |) + ] + |); + M.read (| + Value.String + "passive segments are rejected due to validation" + |) + ] + |) + |) in + let offset_val := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_function (| + "wasmi::module::eval_init_expr", + [] + |), + [ + M.read (| offset |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::module::ModuleRef", + [], + "deref", + [] + |), + [ M.read (| module_ref |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi_core::value::Value::I32", + 0 + |) in + let v := M.copy (| γ0_0 |) in + M.alloc (| + M.rust_cast (M.read (| v |)) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| + "core::panicking::panic_fmt", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "core::fmt::Arguments", + "new_const", + [] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.alloc (| + Value.Array + [ + M.read (| + Value.String + "Due to validation elem segment offset should evaluate to i32" + |) + ] + |)) + ] + |) + ] + |) + |) + |))) + ] + |) + |) in + let table_inst := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi::table::TableRef" ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::module::ModuleInstance", + "table_by_index", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::module::ModuleRef", + [], + "deref", + [] + |), + [ M.read (| module_ref |) ] + |); + M.read (| + M.get_constant (| + "delphinus_zkwasm::runtime::monitor::plugins::table::DEFAULT_TABLE_INDEX" + |) + |) + ] + |); + M.read (| + Value.String + "Due to validation default table should exists" + |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + BinOp.Pure.gt + (BinOp.Panic.add (| + Integer.U64, + M.rust_cast + (M.read (| offset_val |)), + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "u32" ], + "len", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "parity_wasm::elements::segment::ElementSegment", + "members", + [] + |), + [ + M.read (| + element_segment + |) + ] + |) + ] + |)) + |)) + (M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::table::TableInstance", + "current_size", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "wasmi::table::TableRef", + [], + "deref", + [] + |), + [ table_inst ] + |) + ] + |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + Value.StructTuple + "core::result::Result::Err" + [ + Value.StructTuple + "wasmi::Error::Instantiation" + [ + M.call_closure (| + M.get_trait_method (| + "alloc::string::ToString", + Ty.path "str", + [], + "to_string", + [] + |), + [ + M.read (| + Value.String + "elements segment does not fit" + |) + ] + |) + ] + ] + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "u32" ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "u32" ], + [], + "enumerate", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "u32" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "parity_wasm::elements::segment::ElementSegment", + "members", + [] + |), + [ M.read (| element_segment |) ] + |) + ] + |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::enumerate::Enumerate") + [ + Ty.apply + (Ty.path + "core::slice::iter::Iter") + [ Ty.path "u32" ] + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + M.break (||) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let γ1_0 := + M.SubPointer.get_tuple_field (| + γ0_0, + 0 + |) in + let γ1_1 := + M.SubPointer.get_tuple_field (| + γ0_0, + 1 + |) in + let j := + M.copy (| γ1_0 |) in + let func_idx := + M.copy (| γ1_1 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "specs::brtable::ElemEntry"; + Ty.path + "alloc::alloc::Global" + ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "elements" + |); + Value.StructRecord + "specs::brtable::ElemEntry" + [ + ("table_idx", + M.read (| + M.get_constant (| + "delphinus_zkwasm::runtime::monitor::plugins::table::DEFAULT_TABLE_INDEX" + |) + |)); + ("type_idx", + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "u32"; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + type_idx_of_func; + M.rust_cast + (M.read (| + M.read (| + func_idx + |) + |)) + ] + |) + |)); + ("offset", + BinOp.Panic.add (| + Integer.U32, + M.read (| + offset_val + |), + M.rust_cast + (M.read (| + j + |)) + |)); + ("func_idx", + M.read (| + M.read (| + func_idx + |) + |)) + ] + ] + |) + |) in + M.alloc (| + Value.Tuple [] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let _ := + M.match_operator (| + M.alloc (| + Value.Tuple + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::FuncDesc"; + Ty.path "alloc::alloc::Global" + ], + "len", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "function_table" + |) + ] + |) + |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u32"; Ty.path "alloc::alloc::Global" ], + "len", + [] + |), + [ type_idx_of_func ] + |) + |) + ] + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in + let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in + let left_val := M.copy (| γ0_0 |) in + let right_val := M.copy (| γ0_1 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (BinOp.Pure.eq + (M.read (| M.read (| left_val |) |)) + (M.read (| M.read (| right_val |) |))) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| + M.read (| + let kind := + M.alloc (| + Value.StructTuple + "core::panicking::AssertKind::Eq" + [] + |) in + M.alloc (| + M.call_closure (| + M.get_function (| + "core::panicking::assert_failed", + [ Ty.path "usize"; Ty.path "usize" ] + |), + [ + M.read (| kind |); + M.read (| left_val |); + M.read (| right_val |); + Value.StructTuple + "core::option::Option::None" + [] + ] + |) + |) + |) + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn invoke_exported_function_pre_hook(&mut self) { + self.last_jump_eid.push(0); + } + *) + Definition invoke_exported_function_pre_hook (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u32"; Ty.path "alloc::alloc::Global" ], + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "last_jump_eid" + |); + Value.Integer 0 + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + (* + fn invoke_instruction_pre_hook( + &mut self, + value_stack: &ValueStack, + function_context: &FunctionContext, + instruction: &Instruction, + ) { + // phantom should do nothing + if self.phantom_helper.is_in_phantom_function() { + return; + } + self.unresolved_event = run_instruction_pre(value_stack, function_context, instruction); + } + *) + Definition invoke_instruction_pre_hook (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; value_stack; function_context; instruction ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let value_stack := M.alloc (| value_stack |) in + let function_context := M.alloc (| function_context |) in + let instruction := M.alloc (| instruction |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "is_in_phantom_function", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "phantom_helper" + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| M.read (| M.return_ (| Value.Tuple [] |) |) |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.write (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "unresolved_event" + |), + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::run_instruction_pre", + [] + |), + [ + M.read (| value_stack |); + M.read (| function_context |); + M.read (| instruction |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn invoke_instruction_post_hook( + &mut self, + fid: u32, + iid: u32, + sp: u32, + allocated_memory_pages: u32, + value_stack: &ValueStack, + function_context: &FunctionContext, + instruction: &Instruction, + outcome: &InstructionOutcome, + ) { + if !self.phantom_helper.is_in_phantom_function() { + let current_event = self.unresolved_event.take(); + + let event = self.run_instruction_post( + self.module_ref.as_ref().unwrap(), + current_event, + value_stack, + function_context, + instruction, + ); + + self.etable.push( + fid, + iid, + sp, + allocated_memory_pages, + *self.last_jump_eid.last().unwrap(), + event, + ); + } + + match outcome { + InstructionOutcome::ExecuteCall(func_ref) => { + if let FuncInstanceInternal::Internal { index, .. } = func_ref.as_internal() { + if !self.phantom_helper.is_in_phantom_function() { + let eid = self.etable.entries().last().unwrap().eid; + + self.push_frame( + eid, + *self.last_jump_eid.last().unwrap(), + *index as u32, + fid, + iid + 1, + ); + } + + if self.phantom_helper.is_phantom_function( *index as u32) { + if let Some(memory_ref) = function_context.memory() { + let mut buf = memory_ref.buffer_cache.borrow_mut(); + + if buf.is_none() { + *buf = Some(( + Pages(allocated_memory_pages as usize), + HashMap::default(), + )); + } + } + self.phantom_helper.push_frame(value_stack.len() as u32); + } + } + } + InstructionOutcome::Return(dropkeep) => { + if self.phantom_helper.is_phantom_function(fid) { + let sp_before = self.phantom_helper.pop_frame().unwrap(); + + let wasm_input = self.phantom_helper.wasm_input.clone(); + let signature = self.function_table[fid as usize].signature.clone(); + if !self.phantom_helper.is_in_phantom_function() { + let allocated_memory_pages = + if let Some(memory_ref) = function_context.memory() { + let mut buf = memory_ref.buffer_cache.borrow_mut(); + + let pages = buf.as_ref().unwrap().0; + *buf = None; + memory_ref.shrink(pages).unwrap(); + + pages.0 + } else { + 0 + }; + + self.fill_trace( + sp_before, + allocated_memory_pages as u32, + fid, + &signature, + if let Keep::Single(t) = dropkeep.keep { + Some(from_value_internal_to_u64_with_typ( + t.into(), + *value_stack.top(), + )) + } else { + None + }, + wasm_input, + ) + } + } + + if !self.phantom_helper.is_in_phantom_function() { + self.pop_frame(); + } + } + _ => {} + } + } + *) + Definition invoke_instruction_post_hook (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], + [ + self; + fid; + iid; + sp; + allocated_memory_pages; + value_stack; + function_context; + instruction; + outcome + ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let fid := M.alloc (| fid |) in + let iid := M.alloc (| iid |) in + let sp := M.alloc (| sp |) in + let allocated_memory_pages := M.alloc (| allocated_memory_pages |) in + let value_stack := M.alloc (| value_stack |) in + let function_context := M.alloc (| function_context |) in + let instruction := M.alloc (| instruction |) in + let outcome := M.alloc (| outcome |) in + M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "is_in_phantom_function", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "phantom_helper" + |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let current_event := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::RunInstructionTracePre" + ], + "take", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "unresolved_event" + |) + ] + |) + |) in + let event := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "run_instruction_post", + [] + |), + [ + M.read (| self |); + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ Ty.path "wasmi::module::ModuleRef" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi::module::ModuleRef" ], + "as_ref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "module_ref" + |) + ] + |) + ] + |); + M.read (| current_event |); + M.read (| value_stack |); + M.read (| function_context |); + M.read (| instruction |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "push", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "etable" + |); + M.read (| fid |); + M.read (| iid |); + M.read (| sp |); + M.read (| allocated_memory_pages |); + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.apply (Ty.path "&") [ Ty.path "u32" ] ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "u32" ], + "last", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ Ty.path "u32"; Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "last_jump_eid" + |) + ] + |) + ] + |) + ] + |) + |); + M.read (| event |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.match_operator (| + outcome, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::runner::InstructionOutcome::ExecuteCall", + 0 + |) in + let func_ref := M.alloc (| γ1_0 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::func::FuncInstance", + "as_internal", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::func::FuncRef", + [], + "deref", + [] + |), + [ M.read (| func_ref |) ] + |) + ] + |) + |) in + let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "wasmi::func::FuncInstanceInternal::Internal", + "index" + |) in + let index := M.alloc (| γ1_0 |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "is_in_phantom_function", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "phantom_helper" + |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let eid := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "specs::etable::EventTableEntry" + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ + Ty.path + "specs::etable::EventTableEntry" + ], + "last", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "entries", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "etable" + |) + ] + |) + ] + |) + ] + |), + "specs::etable::EventTableEntry", + "eid" + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "push_frame", + [] + |), + [ + M.read (| self |); + M.read (| eid |); + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ Ty.path "u32" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "u32" ], + "last", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "u32"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "last_jump_eid" + |) + ] + |) + ] + |) + ] + |) + |); + M.rust_cast (M.read (| M.read (| index |) |)); + M.read (| fid |); + BinOp.Panic.add (| + Integer.U32, + M.read (| iid |), + Value.Integer 1 + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "is_phantom_function", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "phantom_helper" + |); + M.rust_cast (M.read (| M.read (| index |) |)) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::runner::FunctionContext", + "memory", + [] + |), + [ M.read (| function_context |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let memory_ref := M.copy (| γ0_0 |) in + let buf := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.tuple + [ + Ty.path + "memory_units::wasm32::Pages"; + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "u8"; + Ty.path + "std::hash::random::RandomState" + ] + ] + ] + ], + "borrow_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "wasmi::memory::MemoryRef", + [], + "deref", + [] + |), + [ M.read (| memory_ref |) ] + |), + "wasmi::memory::MemoryInstance", + "buffer_cache" + |) + ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.tuple + [ + Ty.path + "memory_units::wasm32::Pages"; + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "u8"; + Ty.path + "std::hash::random::RandomState" + ] + ] + ], + "is_none", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.tuple + [ + Ty.path + "memory_units::wasm32::Pages"; + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path + "usize"; + Ty.path + "u8"; + Ty.path + "std::hash::random::RandomState" + ] + ] + ] + ], + [], + "deref", + [] + |), + [ buf ] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.tuple + [ + Ty.path + "memory_units::wasm32::Pages"; + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "u8"; + Ty.path + "std::hash::random::RandomState" + ] + ] + ] + ], + [], + "deref_mut", + [] + |), + [ buf ] + |), + Value.StructTuple + "core::option::Option::Some" + [ + Value.Tuple + [ + Value.StructTuple + "memory_units::wasm32::Pages" + [ + M.rust_cast + (M.read (| + allocated_memory_pages + |)) + ]; + M.call_closure (| + M.get_trait_method (| + "core::default::Default", + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "u8"; + Ty.path + "std::hash::random::RandomState" + ], + [], + "default", + [] + |), + [] + |) + ] + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => + ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "push_frame", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "phantom_helper" + |); + M.rust_cast + (M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::runner::ValueStack", + "len", + [] + |), + [ M.read (| value_stack |) ] + |)) + ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::runner::InstructionOutcome::Return", + 0 + |) in + let dropkeep := M.alloc (| γ1_0 |) in + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "is_phantom_function", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "phantom_helper" + |); + M.read (| fid |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let sp_before := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "u32" ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "pop_frame", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "phantom_helper" + |) + ] + |) + ] + |) + |) in + let wasm_input := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "wasmi::func::FuncRef", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "phantom_helper" + |), + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "wasm_input" + |) + ] + |) + |) in + let signature := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "wasmi::types::Signature", + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::FuncDesc"; + Ty.path "alloc::alloc::Global" + ], + [ Ty.path "usize" ], + "index", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "function_table" + |); + M.rust_cast (M.read (| fid |)) + ] + |), + "delphinus_zkwasm::runtime::monitor::plugins::table::instruction::FuncDesc", + "signature" + |) + ] + |) + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "is_in_phantom_function", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "phantom_helper" + |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let allocated_memory_pages := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::runner::FunctionContext", + "memory", + [] + |), + [ M.read (| function_context |) ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let memory_ref := M.copy (| γ0_0 |) in + let buf := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.tuple + [ + Ty.path + "memory_units::wasm32::Pages"; + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "u8"; + Ty.path + "std::hash::random::RandomState" + ] + ] + ] + ], + "borrow_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "wasmi::memory::MemoryRef", + [], + "deref", + [] + |), + [ M.read (| memory_ref |) ] + |), + "wasmi::memory::MemoryInstance", + "buffer_cache" + |) + ] + |) + |) in + let pages := + M.copy (| + M.SubPointer.get_tuple_field (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ + Ty.tuple + [ + Ty.path + "memory_units::wasm32::Pages"; + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "u8"; + Ty.path + "std::hash::random::RandomState" + ] + ] + ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.tuple + [ + Ty.path + "memory_units::wasm32::Pages"; + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "u8"; + Ty.path + "std::hash::random::RandomState" + ] + ] + ], + "as_ref", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path + "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.tuple + [ + Ty.path + "memory_units::wasm32::Pages"; + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path + "usize"; + Ty.path + "u8"; + Ty.path + "std::hash::random::RandomState" + ] + ] + ] + ], + [], + "deref", + [] + |), + [ buf ] + |) + ] + |) + ] + |), + 0 + |) + |) in + let _ := + M.write (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "core::cell::RefMut") + [ + Ty.apply + (Ty.path + "core::option::Option") + [ + Ty.tuple + [ + Ty.path + "memory_units::wasm32::Pages"; + Ty.apply + (Ty.path + "std::collections::hash::map::HashMap") + [ + Ty.path "usize"; + Ty.path "u8"; + Ty.path + "std::hash::random::RandomState" + ] + ] + ] + ], + [], + "deref_mut", + [] + |), + [ buf ] + |), + Value.StructTuple + "core::option::Option::None" + [] + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.tuple []; + Ty.path "wasmi::Error" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::memory::MemoryInstance", + "shrink", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path + "wasmi::memory::MemoryRef", + [], + "deref", + [] + |), + [ M.read (| memory_ref |) ] + |); + M.read (| pages |) + ] + |) + ] + |) + |) in + M.SubPointer.get_struct_tuple_field (| + pages, + "memory_units::wasm32::Pages", + 0 + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Integer 0 |))) + ] + |) + |) in + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "fill_trace", + [] + |), + [ + M.read (| self |); + M.read (| sp_before |); + M.rust_cast (M.read (| allocated_memory_pages |)); + M.read (| fid |); + signature; + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.SubPointer.get_struct_record_field (| + M.read (| dropkeep |), + "wasmi::isa::DropKeep", + "keep" + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "wasmi::isa::Keep::Single", + 0 + |) in + let t := M.copy (| γ0_0 |) in + M.alloc (| + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_function (| + "wasmi::runner::from_value_internal_to_u64_with_typ", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path + "parity_wasm::elements::types::ValueType", + [ + Ty.path + "specs::mtable::VarType" + ], + "into", + [] + |), + [ M.read (| t |) ] + |); + M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "wasmi::runner::ValueStack", + "top", + [] + |), + [ M.read (| value_stack |) + ] + |) + |) + ] + |) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.StructTuple + "core::option::Option::None" + [] + |))) + ] + |) + |); + M.read (| wasm_input |) + ] + |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + UnOp.Pure.not + (M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "is_in_phantom_function", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "phantom_helper" + |) + ] + |)) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "pop_frame", + [] + |), + [ M.read (| self |) ] + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) + |))) + | _, _ => M.impossible + end. + + (* + fn invoke_call_host_post_hook(&mut self, return_value: Option) { + if self.phantom_helper.is_in_phantom_function() { + return; + } + + if let Some(return_value) = return_value { + match self.etable.entries_mut().last_mut().unwrap().step_info { + StepInfo::CallHost { + ref mut ret_val, .. + } => { + *ret_val = Some(return_value.into()); + } + StepInfo::ExternalHostCall { + ref mut value, sig, .. + } if sig.is_ret() => { + *value = Some(return_value.into()); + } + _ => unreachable!(), + } + } + } + *) + Definition invoke_call_host_post_hook (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; return_value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let return_value := M.alloc (| return_value |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::phantom::PhantomHelper", + "is_in_phantom_function", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "phantom_helper" + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.alloc (| + M.never_to_any (| M.read (| M.return_ (| Value.Tuple [] |) |) |) + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := return_value in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let return_value := M.copy (| γ0_0 |) in + M.match_operator (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&mut") + [ Ty.path "specs::etable::EventTableEntry" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::etable::EventTableEntry" ], + "last_mut", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::DerefMut", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::etable::EventTableEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref_mut", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::etable::ETable", + "entries_mut", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "etable" + |) + ] + |) + ] + |) + ] + |) + ] + |), + "specs::etable::EventTableEntry", + "step_info" + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "ret_val" + |) in + let ret_val := M.alloc (| γ0_0 |) in + let _ := + M.write (| + M.read (| ret_val |), + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "wasmi_core::value::Value", + [ Ty.path "u64" ], + "into", + [] + |), + [ M.read (| return_value |) ] + |) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::ExternalHostCall", + "value" + |) in + let γ0_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::ExternalHostCall", + "sig" + |) in + let value := M.alloc (| γ0_0 |) in + let sig := M.copy (| γ0_1 |) in + let γ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "specs::external_host_call_table::ExternalHostCallSignature", + "is_ret", + [] + |), + [ sig ] + |) + |) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + M.write (| + M.read (| value |), + Value.StructTuple + "core::option::Option::Some" + [ + M.call_closure (| + M.get_trait_method (| + "core::convert::Into", + Ty.path "wasmi_core::value::Value", + [ Ty.path "u64" ], + "into", + [] + |), + [ M.read (| return_value |) ] + |) + ] + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.call_closure (| + M.get_function (| "core::panicking::panic", [] |), + [ + M.read (| + Value.String + "internal error: entered unreachable code" + |) + ] + |) + |) + |))) + ] + |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "wasmi::monitor::Monitor" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ + ("register_module", InstanceField.Method register_module); + ("invoke_exported_function_pre_hook", + InstanceField.Method invoke_exported_function_pre_hook); + ("invoke_instruction_pre_hook", InstanceField.Method invoke_instruction_pre_hook); + ("invoke_instruction_post_hook", InstanceField.Method invoke_instruction_post_hook); + ("invoke_call_host_post_hook", InstanceField.Method invoke_call_host_post_hook) + ]. + End Impl_wasmi_monitor_Monitor_for_delphinus_zkwasm_runtime_monitor_plugins_table_TablePlugin. + End table. + End plugins. + End monitor. +End runtime. diff --git a/CoqOfRust/zkWasm/runtime/monitor/statistic_monitor.v b/CoqOfRust/zkWasm/runtime/monitor/statistic_monitor.v new file mode 100644 index 000000000..425900f77 --- /dev/null +++ b/CoqOfRust/zkWasm/runtime/monitor/statistic_monitor.v @@ -0,0 +1,541 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module runtime. + Module monitor. + Module statistic_monitor. + (* StructRecord + { + name := "StatisticMonitor"; + ty_params := []; + fields := + [ + ("statistic_plugin", + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin") + ]; + } *) + + Module Impl_delphinus_zkwasm_runtime_monitor_statistic_monitor_StatisticMonitor. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::monitor::statistic_monitor::StatisticMonitor". + + (* + pub fn new(phantom_regex: &Vec, env: &HostEnv) -> Self { + let wasm_input = env + .resolve_func( + "wasm_input", + &Signature::new(vec![ValueType::I32], Some(ValueType::I64)), + ) + .expect("Failed to resolve wasm_input function, please make sure it is imported in the wasm image."); + + Self { + statistic_plugin: StatisticPlugin::new(phantom_regex, wasm_input), + } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ phantom_regex; env ] => + ltac:(M.monadic + (let phantom_regex := M.alloc (| phantom_regex |) in + let env := M.alloc (| env |) in + M.read (| + let wasm_input := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "wasmi::func::FuncRef"; Ty.path "wasmi::Error" ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "wasmi::imports::ModuleImportResolver", + Ty.path "delphinus_zkwasm::runtime::host::host_env::HostEnv", + [], + "resolve_func", + [] + |), + [ + M.read (| env |); + M.read (| Value.String "wasm_input" |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::types::Signature", + "new", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "wasmi_core::value::ValueType"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "wasmi_core::value::ValueType" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "wasmi_core::value::ValueType" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.StructTuple + "wasmi_core::value::ValueType::I32" + [] + ] + |) + ] + |) + |)) + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ Value.StructTuple "wasmi_core::value::ValueType::I64" [] ] + ] + |) + |) + ] + |); + M.read (| + Value.String + "Failed to resolve wasm_input function, please make sure it is imported in the wasm image." + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::statistic_monitor::StatisticMonitor" + [ + ("statistic_plugin", + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + "new", + [] + |), + [ M.read (| phantom_regex |); M.read (| wasm_input |) ] + |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + End Impl_delphinus_zkwasm_runtime_monitor_statistic_monitor_StatisticMonitor. + + Module Impl_wasmi_monitor_Monitor_for_delphinus_zkwasm_runtime_monitor_statistic_monitor_StatisticMonitor. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::monitor::statistic_monitor::StatisticMonitor". + + (* + fn register_module( + &mut self, + module: &Module, + module_ref: &ModuleRef, + entry: &str, + ) -> Result<(), wasmi::Error> { + self.statistic_plugin + .register_module(module, module_ref, entry)?; + + Ok(()) + } + *) + Definition register_module (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; module; module_ref; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let module := M.alloc (| module |) in + let module_ref := M.alloc (| module_ref |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "wasmi::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "wasmi::monitor::Monitor", + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + [], + "register_module", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::statistic_monitor::StatisticMonitor", + "statistic_plugin" + |); + M.read (| module |); + M.read (| module_ref |); + M.read (| entry |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "wasmi::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "wasmi::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn invoke_exported_function_pre_hook(&mut self) { + self.statistic_plugin.invoke_exported_function_pre_hook(); + } + *) + Definition invoke_exported_function_pre_hook (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "wasmi::monitor::Monitor", + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + [], + "invoke_exported_function_pre_hook", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::statistic_monitor::StatisticMonitor", + "statistic_plugin" + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + (* + fn invoke_instruction_pre_hook( + &mut self, + value_stack: &ValueStack, + function_context: &FunctionContext, + instruction: &Instruction, + ) { + self.statistic_plugin.invoke_instruction_pre_hook( + value_stack, + function_context, + instruction, + ); + } + *) + Definition invoke_instruction_pre_hook (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; value_stack; function_context; instruction ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let value_stack := M.alloc (| value_stack |) in + let function_context := M.alloc (| function_context |) in + let instruction := M.alloc (| instruction |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "wasmi::monitor::Monitor", + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + [], + "invoke_instruction_pre_hook", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::statistic_monitor::StatisticMonitor", + "statistic_plugin" + |); + M.read (| value_stack |); + M.read (| function_context |); + M.read (| instruction |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + (* + fn invoke_instruction_post_hook( + &mut self, + fid: u32, + iid: u32, + sp: u32, + allocated_memory_pages: u32, + value_stack: &ValueStack, + function_context: &FunctionContext, + instruction: &Instruction, + outcome: &InstructionOutcome, + ) { + self.statistic_plugin.invoke_instruction_post_hook( + fid, + iid, + sp, + allocated_memory_pages, + value_stack, + function_context, + instruction, + outcome, + ); + } + *) + Definition invoke_instruction_post_hook (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], + [ + self; + fid; + iid; + sp; + allocated_memory_pages; + value_stack; + function_context; + instruction; + outcome + ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let fid := M.alloc (| fid |) in + let iid := M.alloc (| iid |) in + let sp := M.alloc (| sp |) in + let allocated_memory_pages := M.alloc (| allocated_memory_pages |) in + let value_stack := M.alloc (| value_stack |) in + let function_context := M.alloc (| function_context |) in + let instruction := M.alloc (| instruction |) in + let outcome := M.alloc (| outcome |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "wasmi::monitor::Monitor", + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + [], + "invoke_instruction_post_hook", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::statistic_monitor::StatisticMonitor", + "statistic_plugin" + |); + M.read (| fid |); + M.read (| iid |); + M.read (| sp |); + M.read (| allocated_memory_pages |); + M.read (| value_stack |); + M.read (| function_context |); + M.read (| instruction |); + M.read (| outcome |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + (* + fn invoke_call_host_post_hook(&mut self, return_value: Option) { + self.statistic_plugin + .invoke_call_host_post_hook(return_value); + } + *) + Definition invoke_call_host_post_hook (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; return_value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let return_value := M.alloc (| return_value |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "wasmi::monitor::Monitor", + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + [], + "invoke_call_host_post_hook", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::statistic_monitor::StatisticMonitor", + "statistic_plugin" + |); + M.read (| return_value |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "wasmi::monitor::Monitor" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ + ("register_module", InstanceField.Method register_module); + ("invoke_exported_function_pre_hook", + InstanceField.Method invoke_exported_function_pre_hook); + ("invoke_instruction_pre_hook", InstanceField.Method invoke_instruction_pre_hook); + ("invoke_instruction_post_hook", InstanceField.Method invoke_instruction_post_hook); + ("invoke_call_host_post_hook", InstanceField.Method invoke_call_host_post_hook) + ]. + End Impl_wasmi_monitor_Monitor_for_delphinus_zkwasm_runtime_monitor_statistic_monitor_StatisticMonitor. + + Module Impl_delphinus_zkwasm_runtime_monitor_WasmiMonitor_for_delphinus_zkwasm_runtime_monitor_statistic_monitor_StatisticMonitor. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::monitor::statistic_monitor::StatisticMonitor". + + (* + fn expose_observer(&self) -> Rc> { + self.statistic_plugin.expose_observer() + } + *) + Definition expose_observer (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + "expose_observer", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::statistic_monitor::StatisticMonitor", + "statistic_plugin" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "delphinus_zkwasm::runtime::monitor::WasmiMonitor" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("expose_observer", InstanceField.Method expose_observer) ]. + End Impl_delphinus_zkwasm_runtime_monitor_WasmiMonitor_for_delphinus_zkwasm_runtime_monitor_statistic_monitor_StatisticMonitor. + End statistic_monitor. + End monitor. +End runtime. diff --git a/CoqOfRust/zkWasm/runtime/monitor/table_monitor.v b/CoqOfRust/zkWasm/runtime/monitor/table_monitor.v new file mode 100644 index 000000000..09c1469c9 --- /dev/null +++ b/CoqOfRust/zkWasm/runtime/monitor/table_monitor.v @@ -0,0 +1,836 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module runtime. + Module monitor. + Module table_monitor. + (* StructRecord + { + name := "TableMonitor"; + ty_params := []; + fields := + [ + ("table_plugin", + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin"); + ("statistic_plugin", + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin") + ]; + } *) + + Module Impl_delphinus_zkwasm_runtime_monitor_table_monitor_TableMonitor. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor". + + (* + pub fn new(k: u32, phantom_regex: &Vec, backend: TraceBackend, env: &HostEnv) -> Self { + let wasm_input = env + .resolve_func( + "wasm_input", + &Signature::new(vec![ValueType::I32], Some(ValueType::I64)), + ) + .expect("Failed to resolve wasm_input function, please make sure it is imported in the wasm image."); + + Self { + table_plugin: TablePlugin::new( + k, + env.function_description_table(), + phantom_regex, + wasm_input.clone(), + backend, + ), + statistic_plugin: StatisticPlugin::new(phantom_regex, wasm_input), + } + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ k; phantom_regex; backend; env ] => + ltac:(M.monadic + (let k := M.alloc (| k |) in + let phantom_regex := M.alloc (| phantom_regex |) in + let backend := M.alloc (| backend |) in + let env := M.alloc (| env |) in + M.read (| + let wasm_input := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "wasmi::func::FuncRef"; Ty.path "wasmi::Error" ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "wasmi::imports::ModuleImportResolver", + Ty.path "delphinus_zkwasm::runtime::host::host_env::HostEnv", + [], + "resolve_func", + [] + |), + [ + M.read (| env |); + M.read (| Value.String "wasm_input" |); + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::types::Signature", + "new", + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "wasmi_core::value::ValueType"; + Ty.path "alloc::alloc::Global" + ] + ] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "wasmi_core::value::ValueType" ], + "into_vec", + [ Ty.path "alloc::alloc::Global" ] + |), + [ + (* Unsize *) + M.pointer_coercion + (M.read (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.apply + (Ty.path "array") + [ Ty.path "wasmi_core::value::ValueType" ]; + Ty.path "alloc::alloc::Global" + ], + "new", + [] + |), + [ + M.alloc (| + Value.Array + [ + Value.StructTuple + "wasmi_core::value::ValueType::I32" + [] + ] + |) + ] + |) + |)) + ] + |); + Value.StructTuple + "core::option::Option::Some" + [ Value.StructTuple "wasmi_core::value::ValueType::I64" [] ] + ] + |) + |) + ] + |); + M.read (| + Value.String + "Failed to resolve wasm_input function, please make sure it is imported in the wasm image." + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor" + [ + ("table_plugin", + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "new", + [] + |), + [ + M.read (| k |); + M.call_closure (| + M.get_associated_function (| + Ty.path "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "function_description_table", + [] + |), + [ M.read (| env |) ] + |); + M.read (| phantom_regex |); + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.path "wasmi::func::FuncRef", + [], + "clone", + [] + |), + [ wasm_input ] + |); + M.read (| backend |) + ] + |)); + ("statistic_plugin", + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + "new", + [] + |), + [ M.read (| phantom_regex |); M.read (| wasm_input |) ] + |)) + ] + |) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + + (* + pub fn into_compilation_table(self) -> CompilationTable { + self.table_plugin.into_compilation_table() + } + *) + Definition into_compilation_table (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "into_compilation_table", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor", + "table_plugin" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_into_compilation_table : + M.IsAssociatedFunction Self "into_compilation_table" into_compilation_table. + + (* + pub fn into_tables(self) -> Tables { + self.table_plugin.into_tables() + } + *) + Definition into_tables (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + "into_tables", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor", + "table_plugin" + |) + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_into_tables : + M.IsAssociatedFunction Self "into_tables" into_tables. + End Impl_delphinus_zkwasm_runtime_monitor_table_monitor_TableMonitor. + + Module Impl_wasmi_monitor_Monitor_for_delphinus_zkwasm_runtime_monitor_table_monitor_TableMonitor. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor". + + (* + fn register_module( + &mut self, + module: &Module, + module_ref: &ModuleRef, + entry: &str, + ) -> Result<(), wasmi::Error> { + self.table_plugin + .register_module(module, module_ref, entry)?; + self.statistic_plugin + .register_module(module, module_ref, entry)?; + + Ok(()) + } + *) + Definition register_module (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; module; module_ref; entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let module := M.alloc (| module |) in + let module_ref := M.alloc (| module_ref |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "wasmi::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "wasmi::monitor::Monitor", + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + [], + "register_module", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor", + "table_plugin" + |); + M.read (| module |); + M.read (| module_ref |); + M.read (| entry |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "wasmi::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "wasmi::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "wasmi::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "wasmi::monitor::Monitor", + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + [], + "register_module", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor", + "statistic_plugin" + |); + M.read (| module |); + M.read (| module_ref |); + M.read (| entry |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "wasmi::Error" ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "wasmi::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |) + |))) + |))) + | _, _ => M.impossible + end. + + (* + fn invoke_exported_function_pre_hook(&mut self) { + self.table_plugin.invoke_exported_function_pre_hook(); + self.statistic_plugin.invoke_exported_function_pre_hook(); + } + *) + Definition invoke_exported_function_pre_hook (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "wasmi::monitor::Monitor", + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + [], + "invoke_exported_function_pre_hook", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor", + "table_plugin" + |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "wasmi::monitor::Monitor", + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + [], + "invoke_exported_function_pre_hook", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor", + "statistic_plugin" + |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + (* + fn invoke_instruction_pre_hook( + &mut self, + value_stack: &ValueStack, + function_context: &FunctionContext, + instruction: &Instruction, + ) { + self.table_plugin + .invoke_instruction_pre_hook(value_stack, function_context, instruction); + self.statistic_plugin.invoke_instruction_pre_hook( + value_stack, + function_context, + instruction, + ); + } + *) + Definition invoke_instruction_pre_hook (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; value_stack; function_context; instruction ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let value_stack := M.alloc (| value_stack |) in + let function_context := M.alloc (| function_context |) in + let instruction := M.alloc (| instruction |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "wasmi::monitor::Monitor", + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + [], + "invoke_instruction_pre_hook", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor", + "table_plugin" + |); + M.read (| value_stack |); + M.read (| function_context |); + M.read (| instruction |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "wasmi::monitor::Monitor", + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + [], + "invoke_instruction_pre_hook", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor", + "statistic_plugin" + |); + M.read (| value_stack |); + M.read (| function_context |); + M.read (| instruction |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + (* + fn invoke_instruction_post_hook( + &mut self, + fid: u32, + iid: u32, + sp: u32, + allocated_memory_pages: u32, + value_stack: &ValueStack, + function_context: &FunctionContext, + instruction: &Instruction, + outcome: &InstructionOutcome, + ) { + self.table_plugin.invoke_instruction_post_hook( + fid, + iid, + sp, + allocated_memory_pages, + value_stack, + function_context, + instruction, + outcome, + ); + self.statistic_plugin.invoke_instruction_post_hook( + fid, + iid, + sp, + allocated_memory_pages, + value_stack, + function_context, + instruction, + outcome, + ); + } + *) + Definition invoke_instruction_post_hook (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], + [ + self; + fid; + iid; + sp; + allocated_memory_pages; + value_stack; + function_context; + instruction; + outcome + ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let fid := M.alloc (| fid |) in + let iid := M.alloc (| iid |) in + let sp := M.alloc (| sp |) in + let allocated_memory_pages := M.alloc (| allocated_memory_pages |) in + let value_stack := M.alloc (| value_stack |) in + let function_context := M.alloc (| function_context |) in + let instruction := M.alloc (| instruction |) in + let outcome := M.alloc (| outcome |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "wasmi::monitor::Monitor", + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + [], + "invoke_instruction_post_hook", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor", + "table_plugin" + |); + M.read (| fid |); + M.read (| iid |); + M.read (| sp |); + M.read (| allocated_memory_pages |); + M.read (| value_stack |); + M.read (| function_context |); + M.read (| instruction |); + M.read (| outcome |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "wasmi::monitor::Monitor", + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + [], + "invoke_instruction_post_hook", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor", + "statistic_plugin" + |); + M.read (| fid |); + M.read (| iid |); + M.read (| sp |); + M.read (| allocated_memory_pages |); + M.read (| value_stack |); + M.read (| function_context |); + M.read (| instruction |); + M.read (| outcome |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + (* + fn invoke_call_host_post_hook(&mut self, return_value: Option) { + self.table_plugin.invoke_call_host_post_hook(return_value); + self.statistic_plugin + .invoke_call_host_post_hook(return_value); + } + *) + Definition invoke_call_host_post_hook (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; return_value ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let return_value := M.alloc (| return_value |) in + M.read (| + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "wasmi::monitor::Monitor", + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::table::TablePlugin", + [], + "invoke_call_host_post_hook", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor", + "table_plugin" + |); + M.read (| return_value |) + ] + |) + |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "wasmi::monitor::Monitor", + Ty.path + "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + [], + "invoke_call_host_post_hook", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor", + "statistic_plugin" + |); + M.read (| return_value |) + ] + |) + |) in + M.alloc (| Value.Tuple [] |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "wasmi::monitor::Monitor" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ + ("register_module", InstanceField.Method register_module); + ("invoke_exported_function_pre_hook", + InstanceField.Method invoke_exported_function_pre_hook); + ("invoke_instruction_pre_hook", InstanceField.Method invoke_instruction_pre_hook); + ("invoke_instruction_post_hook", InstanceField.Method invoke_instruction_post_hook); + ("invoke_call_host_post_hook", InstanceField.Method invoke_call_host_post_hook) + ]. + End Impl_wasmi_monitor_Monitor_for_delphinus_zkwasm_runtime_monitor_table_monitor_TableMonitor. + + Module Impl_delphinus_zkwasm_runtime_monitor_WasmiMonitor_for_delphinus_zkwasm_runtime_monitor_table_monitor_TableMonitor. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor". + + (* + fn expose_observer(&self) -> Rc> { + self.statistic_plugin.expose_observer() + } + *) + Definition expose_observer (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + M.call_closure (| + M.get_associated_function (| + Ty.path "delphinus_zkwasm::runtime::monitor::plugins::statistic::StatisticPlugin", + "expose_observer", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "delphinus_zkwasm::runtime::monitor::table_monitor::TableMonitor", + "statistic_plugin" + |) + ] + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "delphinus_zkwasm::runtime::monitor::WasmiMonitor" + Self + (* Trait polymorphic types *) [] + (* Instance *) [ ("expose_observer", InstanceField.Method expose_observer) ]. + End Impl_delphinus_zkwasm_runtime_monitor_WasmiMonitor_for_delphinus_zkwasm_runtime_monitor_table_monitor_TableMonitor. + End table_monitor. + End monitor. +End runtime. diff --git a/CoqOfRust/zkWasm/runtime/state.v b/CoqOfRust/zkWasm/runtime/state.v new file mode 100644 index 000000000..d92447edd --- /dev/null +++ b/CoqOfRust/zkWasm/runtime/state.v @@ -0,0 +1,1345 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module runtime. + Module state. + (* Trait *) + (* Empty module 'UpdateInitMemoryTable' *) + + (* Trait *) + (* Empty module 'UpdateInitializationState' *) + + Module Impl_delphinus_zkwasm_runtime_state_UpdateInitMemoryTable_for_specs_imtable_InitMemoryTable. + Definition Self : Ty.t := Ty.path "specs::imtable::InitMemoryTable". + + (* + fn update_init_memory_table(&self, execution_table: &EventTable) -> InitMemoryTable { + // First insert origin imtable entries which may be overwritten. + let mut map = self.0.clone(); + + let mut it = execution_table.entries().iter(); + while let Some(etable_entry) = it.next() { + let memory_writing_entires = memory_event_of_step(etable_entry) + .into_iter() + .filter(|entry| entry.atype == AccessType::Write); + + for mentry in memory_writing_entires { + map.insert( + (mentry.ltype, mentry.offset), + InitMemoryTableEntry { + ltype: mentry.ltype, + is_mutable: mentry.is_mutable, + offset: mentry.offset, + vtype: mentry.vtype, + value: mentry.value, + eid: etable_entry.eid, + }, + ); + } + } + + InitMemoryTable(map) + } + *) + Definition update_init_memory_table (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; execution_table ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let execution_table := M.alloc (| execution_table |) in + M.read (| + let map := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::clone::Clone", + Ty.apply + (Ty.path "alloc::collections::btree::map::BTreeMap") + [ + Ty.tuple [ Ty.path "specs::mtable::LocationType"; Ty.path "u32" ]; + Ty.path "specs::imtable::InitMemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "clone", + [] + |), + [ + M.SubPointer.get_struct_tuple_field (| + M.read (| self |), + "specs::imtable::InitMemoryTable", + 0 + |) + ] + |) + |) in + let it := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply (Ty.path "slice") [ Ty.path "specs::etable::EventTableEntry" ], + "iter", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::etable::EventTableEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::etable::EventTable", + "entries", + [] + |), + [ M.read (| execution_table |) ] + |) + ] + |) + ] + |) + |) in + let _ := + M.loop (| + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "specs::etable::EventTableEntry" ], + [], + "next", + [] + |), + [ it ] + |) + |) in + let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let etable_entry := M.copy (| γ0_0 |) in + let memory_writing_entires := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "filter", + [ + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "specs::mtable::MemoryTableEntry" ] + ] + ] + (Ty.path "bool") + ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_function (| + "delphinus_zkwasm::runtime::memory_event_of_step", + [] + |), + [ M.read (| etable_entry |) ] + |) + ] + |); + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [ α0 ] => + M.match_operator (| + M.alloc (| α0 |), + [ + fun γ => + ltac:(M.monadic + (let entry := M.copy (| γ |) in + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path "specs::mtable::AccessType", + [ Ty.path "specs::mtable::AccessType" ], + "eq", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "specs::mtable::MemoryTableEntry", + "atype" + |); + M.alloc (| + Value.StructTuple + "specs::mtable::AccessType::Write" + [] + |) + ] + |))) + ] + |) + | _ => M.impossible (||) + end)) + ] + |) + |) in + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path "alloc::vec::into_iter::IntoIter") + [ + Ty.path "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ Ty.path "specs::mtable::MemoryTableEntry" ] + ] + ] + (Ty.path "bool") + ], + [], + "into_iter", + [] + |), + [ M.read (| memory_writing_entires |) ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path + "core::iter::adapters::filter::Filter") + [ + Ty.apply + (Ty.path + "alloc::vec::into_iter::IntoIter") + [ + Ty.path + "specs::mtable::MemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ]; + Ty.function + [ + Ty.tuple + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "specs::mtable::MemoryTableEntry" + ] + ] + ] + (Ty.path "bool") + ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let mentry := M.copy (| γ0_0 |) in + let _ := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path + "alloc::collections::btree::map::BTreeMap") + [ + Ty.tuple + [ + Ty.path + "specs::mtable::LocationType"; + Ty.path "u32" + ]; + Ty.path + "specs::imtable::InitMemoryTableEntry"; + Ty.path "alloc::alloc::Global" + ], + "insert", + [] + |), + [ + map; + Value.Tuple + [ + M.read (| + M.SubPointer.get_struct_record_field (| + mentry, + "specs::mtable::MemoryTableEntry", + "ltype" + |) + |); + M.read (| + M.SubPointer.get_struct_record_field (| + mentry, + "specs::mtable::MemoryTableEntry", + "offset" + |) + |) + ]; + Value.StructRecord + "specs::imtable::InitMemoryTableEntry" + [ + ("ltype", + M.read (| + M.SubPointer.get_struct_record_field (| + mentry, + "specs::mtable::MemoryTableEntry", + "ltype" + |) + |)); + ("is_mutable", + M.read (| + M.SubPointer.get_struct_record_field (| + mentry, + "specs::mtable::MemoryTableEntry", + "is_mutable" + |) + |)); + ("offset", + M.read (| + M.SubPointer.get_struct_record_field (| + mentry, + "specs::mtable::MemoryTableEntry", + "offset" + |) + |)); + ("vtype", + M.read (| + M.SubPointer.get_struct_record_field (| + mentry, + "specs::mtable::MemoryTableEntry", + "vtype" + |) + |)); + ("value", + M.read (| + M.SubPointer.get_struct_record_field (| + mentry, + "specs::mtable::MemoryTableEntry", + "value" + |) + |)); + ("eid", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| etable_entry |), + "specs::etable::EventTableEntry", + "eid" + |) + |)) + ] + ] + |) + |) in + M.alloc (| Value.Tuple [] |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)))); + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| + M.read (| + let _ := + M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |) in + M.alloc (| Value.Tuple [] |) + |) + |) + |))) + ] + |))) + |) in + M.alloc (| Value.StructTuple "specs::imtable::InitMemoryTable" [ M.read (| map |) ] |) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "delphinus_zkwasm::runtime::state::UpdateInitMemoryTable" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("update_init_memory_table", InstanceField.Method update_init_memory_table) ]. + End Impl_delphinus_zkwasm_runtime_state_UpdateInitMemoryTable_for_specs_imtable_InitMemoryTable. + + Module Impl_delphinus_zkwasm_runtime_state_UpdateInitializationState_for_specs_state_InitializationState_u32_num_bigint_biguint_BigUint. + Definition Self : Ty.t := + Ty.apply + (Ty.path "specs::state::InitializationState") + [ Ty.path "u32"; Ty.path "num_bigint::biguint::BigUint" ]. + + (* + fn update_initialization_state( + &self, + execution_table: &EventTable, + configure_table: &ConfigureTable, + // None indicates last slice + next_event_entry: Option<&EventTableEntry>, + ) -> InitializationState { + let mut host_public_inputs = self.host_public_inputs; + let mut context_in_index = self.context_in_index; + let mut context_out_index = self.context_out_index; + let mut external_host_call_call_index = self.external_host_call_call_index; + + #[cfg(feature = "continuation")] + let mut jops = self.jops.clone(); + + for entry in execution_table.entries() { + match &entry.step_info { + // TODO: fix hard code + StepInfo::CallHost { + plugin, + function_name, + args, + .. + } => { + if *plugin == HostPlugin::HostInput { + if (function_name == "wasm_input" && args[0] != 0) + || function_name == "wasm_output" + { + host_public_inputs += 1; + } + } else if *plugin == HostPlugin::Context { + if function_name == "wasm_read_context" { + context_in_index += 1; + } else if function_name == "wasm_write_context" { + context_out_index += 1; + } + } + } + StepInfo::ExternalHostCall { .. } => external_host_call_call_index += 1, + StepInfo::Call { .. } | StepInfo::CallIndirect { .. } => { + #[cfg(feature = "continuation")] + { + jops += crate::circuits::jtable::encode_jops(0, 1); + } + } + StepInfo::Return { .. } => { + #[cfg(feature = "continuation")] + { + jops += crate::circuits::jtable::encode_jops(1, 0); + } + } + _ => (), + } + } + + let post_initialization_state = if next_event_entry.is_none() { + let last_entry = execution_table.entries().last().unwrap(); + + InitializationState { + eid: last_entry.eid + 1, + fid: 0, + iid: 0, + frame_id: 0, + // TODO: why not constant 4095? + sp: last_entry.sp + + if let StepInfo::Return { drop, .. } = last_entry.step_info { + drop + } else { + 0 + }, + + host_public_inputs, + context_in_index, + context_out_index, + external_host_call_call_index, + + initial_memory_pages: last_entry.allocated_memory_pages, + maximal_memory_pages: configure_table.maximal_memory_pages, + + #[cfg(feature = "continuation")] + jops, + + #[cfg(not(feature = "continuation"))] + _phantom: std::marker::PhantomData, + } + } else { + let next_entry = next_event_entry.unwrap(); + + InitializationState { + eid: next_entry.eid, + fid: next_entry.fid, + iid: next_entry.iid, + frame_id: next_entry.last_jump_eid, + sp: next_entry.sp, + + host_public_inputs, + context_in_index, + context_out_index, + external_host_call_call_index, + + initial_memory_pages: next_entry.allocated_memory_pages, + maximal_memory_pages: configure_table.maximal_memory_pages, + + #[cfg(feature = "continuation")] + jops, + + #[cfg(not(feature = "continuation"))] + _phantom: std::marker::PhantomData, + } + }; + + post_initialization_state + } + *) + Definition update_initialization_state (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; execution_table; configure_table; next_event_entry ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let execution_table := M.alloc (| execution_table |) in + let configure_table := M.alloc (| configure_table |) in + let next_event_entry := M.alloc (| next_event_entry |) in + M.read (| + let host_public_inputs := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::state::InitializationState", + "host_public_inputs" + |) + |) in + let context_in_index := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::state::InitializationState", + "context_in_index" + |) + |) in + let context_out_index := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::state::InitializationState", + "context_out_index" + |) + |) in + let external_host_call_call_index := + M.copy (| + M.SubPointer.get_struct_record_field (| + M.read (| self |), + "specs::state::InitializationState", + "external_host_call_call_index" + |) + |) in + let _ := + M.use + (M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::collect::IntoIterator", + Ty.apply + (Ty.path "&") + [ + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::etable::EventTableEntry"; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "into_iter", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::etable::EventTable", + "entries", + [] + |), + [ M.read (| execution_table |) ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let iter := M.copy (| γ |) in + M.loop (| + ltac:(M.monadic + (let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::iter::traits::iterator::Iterator", + Ty.apply + (Ty.path "core::slice::iter::Iter") + [ Ty.path "specs::etable::EventTableEntry" ], + [], + "next", + [] + |), + [ iter ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (M.alloc (| + M.never_to_any (| M.read (| M.break (||) |) |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::option::Option::Some", + 0 + |) in + let entry := M.copy (| γ0_0 |) in + M.match_operator (| + M.alloc (| + M.SubPointer.get_struct_record_field (| + M.read (| entry |), + "specs::etable::EventTableEntry", + "step_info" + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let γ1_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "plugin" + |) in + let γ1_1 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "function_name" + |) in + let γ1_2 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::CallHost", + "args" + |) in + let plugin := M.alloc (| γ1_0 |) in + let function_name := M.alloc (| γ1_1 |) in + let args := M.alloc (| γ1_2 |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "specs::host_function::HostPlugin", + [ + Ty.path + "specs::host_function::HostPlugin" + ], + "eq", + [] + |), + [ + M.read (| plugin |); + M.alloc (| + Value.StructTuple + "specs::host_function::HostPlugin::HostInput" + [] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + LogicalOp.or (| + LogicalOp.and (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "&") + [ + Ty.path + "alloc::string::String" + ], + [ + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ], + "eq", + [] + |), + [ + function_name; + Value.String + "wasm_input" + ] + |), + ltac:(M.monadic + (BinOp.Pure.ne + (M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::index::Index", + Ty.apply + (Ty.path + "alloc::vec::Vec") + [ + Ty.path + "u64"; + Ty.path + "alloc::alloc::Global" + ], + [ + Ty.path + "usize" + ], + "index", + [] + |), + [ + M.read (| + args + |); + Value.Integer 0 + ] + |) + |)) + (Value.Integer 0))) + |), + ltac:(M.monadic + (M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "&") + [ + Ty.path + "alloc::string::String" + ], + [ + Ty.apply + (Ty.path "&") + [ Ty.path "str" ] + ], + "eq", + [] + |), + [ + function_name; + Value.String + "wasm_output" + ] + |))) + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + let β := host_public_inputs in + M.write (| + β, + BinOp.Panic.add (| + Integer.U32, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| Value.Tuple [] |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.path + "specs::host_function::HostPlugin", + [ + Ty.path + "specs::host_function::HostPlugin" + ], + "eq", + [] + |), + [ + M.read (| plugin |); + M.alloc (| + Value.StructTuple + "specs::host_function::HostPlugin::Context" + [] + |) + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path "&") + [ + Ty.path + "alloc::string::String" + ], + [ + Ty.apply + (Ty.path "&") + [ + Ty.path + "str" + ] + ], + "eq", + [] + |), + [ + function_name; + Value.String + "wasm_read_context" + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + let β := + context_in_index in + M.write (| + β, + BinOp.Panic.add (| + Integer.U32, + M.read (| β |), + Value.Integer 1 + |) + |) in + M.alloc (| + Value.Tuple [] + |))); + fun γ => + ltac:(M.monadic + (M.match_operator (| + M.alloc (| + Value.Tuple [] + |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::cmp::PartialEq", + Ty.apply + (Ty.path + "&") + [ + Ty.path + "alloc::string::String" + ], + [ + Ty.apply + (Ty.path + "&") + [ + Ty.path + "str" + ] + ], + "eq", + [] + |), + [ + function_name; + Value.String + "wasm_write_context" + ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| + M.read (| γ |), + Value.Bool true + |) in + let _ := + let β := + context_out_index in + M.write (| + β, + BinOp.Panic.add (| + Integer.U32, + M.read (| + β + |), + Value.Integer + 1 + |) + |) in + M.alloc (| + Value.Tuple [] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| + Value.Tuple [] + |))) + ] + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + let β := external_host_call_call_index in + M.write (| + β, + BinOp.Panic.add (| + Integer.U32, + M.read (| β |), + Value.Integer 1 + |) + |))); + fun γ => + ltac:(M.monadic + (M.find_or_pattern (| + γ, + [ + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + Value.Tuple [])); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + Value.Tuple [])) + ], + M.closure + (fun γ => + ltac:(M.monadic + match γ with + | [] => M.alloc (| Value.Tuple [] |) + | _ => M.impossible (||) + end)) + |))); + fun γ => + ltac:(M.monadic + (let γ := M.read (| γ |) in + M.alloc (| Value.Tuple [] |))); + fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |))) + ] + |))) + ] + |) in + M.alloc (| Value.Tuple [] |))) + |))) + ] + |)) in + let post_initialization_state := + M.copy (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.use + (M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ Ty.path "specs::etable::EventTableEntry" ] + ], + "is_none", + [] + |), + [ next_event_entry ] + |) + |)) in + let _ := + M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in + let last_entry := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ Ty.path "specs::etable::EventTableEntry" ] + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "slice") + [ Ty.path "specs::etable::EventTableEntry" ], + "last", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::vec::Vec") + [ + Ty.path "specs::etable::EventTableEntry"; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "specs::etable::EventTable", + "entries", + [] + |), + [ M.read (| execution_table |) ] + |) + ] + |) + ] + |) + ] + |) + |) in + M.alloc (| + Value.StructRecord + "specs::state::InitializationState" + [ + ("eid", + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| last_entry |), + "specs::etable::EventTableEntry", + "eid" + |) + |), + Value.Integer 1 + |)); + ("fid", Value.Integer 0); + ("iid", Value.Integer 0); + ("frame_id", Value.Integer 0); + ("sp", + BinOp.Panic.add (| + Integer.U32, + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| last_entry |), + "specs::etable::EventTableEntry", + "sp" + |) + |), + M.read (| + M.match_operator (| + M.alloc (| Value.Tuple [] |), + [ + fun γ => + ltac:(M.monadic + (let γ := + M.SubPointer.get_struct_record_field (| + M.read (| last_entry |), + "specs::etable::EventTableEntry", + "step_info" + |) in + let γ0_0 := + M.SubPointer.get_struct_record_field (| + γ, + "specs::step::StepInfo::Return", + "drop" + |) in + let drop := M.copy (| γ0_0 |) in + drop)); + fun γ => ltac:(M.monadic (M.alloc (| Value.Integer 0 |))) + ] + |) + |) + |)); + ("host_public_inputs", M.read (| host_public_inputs |)); + ("context_in_index", M.read (| context_in_index |)); + ("context_out_index", M.read (| context_out_index |)); + ("external_host_call_call_index", + M.read (| external_host_call_call_index |)); + ("initial_memory_pages", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| last_entry |), + "specs::etable::EventTableEntry", + "allocated_memory_pages" + |) + |)); + ("maximal_memory_pages", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| configure_table |), + "specs::configure_table::ConfigureTable", + "maximal_memory_pages" + |) + |)); + ("_phantom", Value.StructTuple "core::marker::PhantomData" []) + ] + |))); + fun γ => + ltac:(M.monadic + (let next_entry := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::option::Option") + [ + Ty.apply + (Ty.path "&") + [ Ty.path "specs::etable::EventTableEntry" ] + ], + "unwrap", + [] + |), + [ M.read (| next_event_entry |) ] + |) + |) in + M.alloc (| + Value.StructRecord + "specs::state::InitializationState" + [ + ("eid", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| next_entry |), + "specs::etable::EventTableEntry", + "eid" + |) + |)); + ("fid", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| next_entry |), + "specs::etable::EventTableEntry", + "fid" + |) + |)); + ("iid", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| next_entry |), + "specs::etable::EventTableEntry", + "iid" + |) + |)); + ("frame_id", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| next_entry |), + "specs::etable::EventTableEntry", + "last_jump_eid" + |) + |)); + ("sp", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| next_entry |), + "specs::etable::EventTableEntry", + "sp" + |) + |)); + ("host_public_inputs", M.read (| host_public_inputs |)); + ("context_in_index", M.read (| context_in_index |)); + ("context_out_index", M.read (| context_out_index |)); + ("external_host_call_call_index", + M.read (| external_host_call_call_index |)); + ("initial_memory_pages", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| next_entry |), + "specs::etable::EventTableEntry", + "allocated_memory_pages" + |) + |)); + ("maximal_memory_pages", + M.read (| + M.SubPointer.get_struct_record_field (| + M.read (| configure_table |), + "specs::configure_table::ConfigureTable", + "maximal_memory_pages" + |) + |)); + ("_phantom", Value.StructTuple "core::marker::PhantomData" []) + ] + |))) + ] + |) + |) in + post_initialization_state + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "delphinus_zkwasm::runtime::state::UpdateInitializationState" + Self + (* Trait polymorphic types *) [] + (* Instance *) + [ ("update_initialization_state", InstanceField.Method update_initialization_state) ]. + End Impl_delphinus_zkwasm_runtime_state_UpdateInitializationState_for_specs_state_InitializationState_u32_num_bigint_biguint_BigUint. + End state. +End runtime. diff --git a/CoqOfRust/zkWasm/runtime/wasmi_interpreter.v b/CoqOfRust/zkWasm/runtime/wasmi_interpreter.v new file mode 100644 index 000000000..3349bda69 --- /dev/null +++ b/CoqOfRust/zkWasm/runtime/wasmi_interpreter.v @@ -0,0 +1,940 @@ +(* Generated by coq-of-rust *) +Require Import CoqOfRust.CoqOfRust. + +Module runtime. + Module wasmi_interpreter. + (* Trait *) + (* Empty module 'Execution' *) + + Module Impl_delphinus_zkwasm_runtime_wasmi_interpreter_Execution_wasmi_core_value_Value_for_delphinus_zkwasm_runtime_CompiledImage_wasmi_module_NotStartedModuleRef. + Definition Self : Ty.t := + Ty.apply + (Ty.path "delphinus_zkwasm::runtime::CompiledImage") + [ Ty.path "wasmi::module::NotStartedModuleRef" ]. + + (* + fn run( + self, + monitor: &mut dyn WasmiMonitor, + externals: HostEnv, + ) -> Result> { + let mut exec_env = ExecEnv { + host_env: externals, + observer: monitor.expose_observer(), + }; + let instance = self + .instance + .run_start_tracer(&mut exec_env, monitor) + .unwrap(); + + let result = instance.invoke_export_trace(&self.entry, &[], &mut exec_env, monitor)?; + + let host_statics = exec_env.host_env.external_env.get_statics(); + let public_inputs_and_outputs = exec_env + .host_env + .internal_env + .get_context_of_plugin(HostPlugin::HostInput) + .borrow() + .expose_public_inputs_and_outputs(); + let outputs = exec_env + .host_env + .internal_env + .get_context_of_plugin(HostPlugin::HostInput) + .borrow() + .expose_outputs(); + let context_outputs = ContextOutput( + exec_env + .host_env + .internal_env + .get_context_of_plugin(HostPlugin::Context) + .borrow() + .expose_context_outputs(), + ); + + Ok(ExecutionResult { + result, + host_statics, + guest_statics: monitor.expose_observer().borrow().counter, + public_inputs_and_outputs, + outputs, + context_outputs, + }) + } + *) + Definition run (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [ self; monitor; externals ] => + ltac:(M.monadic + (let self := M.alloc (| self |) in + let monitor := M.alloc (| monitor |) in + let externals := M.alloc (| externals |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let exec_env := + M.alloc (| + Value.StructRecord + "delphinus_zkwasm::runtime::host::host_env::ExecEnv" + [ + ("host_env", M.read (| externals |)); + ("observer", + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::runtime::monitor::WasmiMonitor", + Ty.dyn + [ ("delphinus_zkwasm::runtime::monitor::WasmiMonitor::Trait", []) + ], + [], + "expose_observer", + [] + |), + [ M.read (| monitor |) ] + |)) + ] + |) in + let instance := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "wasmi::module::ModuleRef"; Ty.path "wasmi_core::trap::Trap" + ], + "unwrap", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::module::NotStartedModuleRef", + "run_start_tracer", + [ Ty.path "delphinus_zkwasm::runtime::host::host_env::ExecEnv" ] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::runtime::CompiledImage", + "instance" + |) + |); + exec_env; + (* Unsize *) M.pointer_coercion (M.read (| monitor |)) + ] + |) + ] + |) + |) in + let result := + M.copy (| + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "core::option::Option") + [ Ty.path "wasmi_core::value::Value" ]; + Ty.path "wasmi::Error" + ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::module::ModuleInstance", + "invoke_export_trace", + [ Ty.path "delphinus_zkwasm::runtime::host::host_env::ExecEnv" ] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "wasmi::module::ModuleRef", + [], + "deref", + [] + |), + [ instance ] + |); + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.path "alloc::string::String", + [], + "deref", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + self, + "delphinus_zkwasm::runtime::CompiledImage", + "entry" + |) + ] + |); + (* Unsize *) M.pointer_coercion (M.alloc (| Value.Array [] |)); + exec_env; + (* Unsize *) M.pointer_coercion (M.read (| monitor |)) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path + "delphinus_zkwasm::runtime::ExecutionResult") + [ Ty.path "wasmi_core::value::Value" ]; + Ty.path "anyhow::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "wasmi::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) + |) in + let host_statics := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::host::external_circuit_plugin::ExternalCircuitEnv", + "get_statics", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + exec_env, + "delphinus_zkwasm::runtime::host::host_env::ExecEnv", + "host_env" + |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "external_env" + |) + ] + |) + |) in + let public_inputs_and_outputs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::runtime::host::ForeignContext", + Ty.dyn [ ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", []) ], + [], + "expose_public_inputs_and_outputs", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "core::cell::Ref") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "borrow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv", + "get_context_of_plugin", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + exec_env, + "delphinus_zkwasm::runtime::host::host_env::ExecEnv", + "host_env" + |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "internal_env" + |); + Value.StructTuple + "specs::host_function::HostPlugin::HostInput" + [] + ] + |) + |) + ] + |) + ] + |) + |) + ] + |) + |) + ] + |) + |) in + let outputs := + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::runtime::host::ForeignContext", + Ty.dyn [ ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", []) ], + [], + "expose_outputs", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "core::cell::Ref") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "borrow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv", + "get_context_of_plugin", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + exec_env, + "delphinus_zkwasm::runtime::host::host_env::ExecEnv", + "host_env" + |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "internal_env" + |); + Value.StructTuple + "specs::host_function::HostPlugin::HostInput" + [] + ] + |) + |) + ] + |) + ] + |) + |) + ] + |) + |) + ] + |) + |) in + let context_outputs := + M.alloc (| + Value.StructTuple + "delphinus_zkwasm::foreign::context::ContextOutput" + [ + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::runtime::host::ForeignContext", + Ty.dyn + [ ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", []) ], + [], + "expose_context_outputs", + [] + |), + [ + M.read (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "core::cell::Ref") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ], + "borrow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.apply + (Ty.path "alloc::boxed::Box") + [ + Ty.dyn + [ + ("delphinus_zkwasm::runtime::host::ForeignContext::Trait", + []) + ]; + Ty.path "alloc::alloc::Global" + ] + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.path + "delphinus_zkwasm::runtime::host::internal_circuit_plugin::InternalCircuitEnv", + "get_context_of_plugin", + [] + |), + [ + M.SubPointer.get_struct_record_field (| + M.SubPointer.get_struct_record_field (| + exec_env, + "delphinus_zkwasm::runtime::host::host_env::ExecEnv", + "host_env" + |), + "delphinus_zkwasm::runtime::host::host_env::HostEnv", + "internal_env" + |); + Value.StructTuple + "specs::host_function::HostPlugin::Context" + [] + ] + |) + |) + ] + |) + ] + |) + |) + ] + |) + |) + ] + |) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::ExecutionResult" + [ + ("result", M.read (| result |)); + ("host_statics", M.read (| host_statics |)); + ("guest_statics", + M.read (| + M.SubPointer.get_struct_record_field (| + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "core::cell::Ref") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ], + "borrow", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "core::ops::deref::Deref", + Ty.apply + (Ty.path "alloc::rc::Rc") + [ + Ty.apply + (Ty.path "core::cell::RefCell") + [ + Ty.path + "delphinus_zkwasm::runtime::monitor::observer::Observer" + ]; + Ty.path "alloc::alloc::Global" + ], + [], + "deref", + [] + |), + [ + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "delphinus_zkwasm::runtime::monitor::WasmiMonitor", + Ty.dyn + [ + ("delphinus_zkwasm::runtime::monitor::WasmiMonitor::Trait", + []) + ], + [], + "expose_observer", + [] + |), + [ M.read (| monitor |) ] + |) + |) + ] + |) + ] + |) + |) + ] + |), + "delphinus_zkwasm::runtime::monitor::observer::Observer", + "counter" + |) + |)); + ("public_inputs_and_outputs", M.read (| public_inputs_and_outputs |)); + ("outputs", M.read (| outputs |)); + ("context_outputs", M.read (| context_outputs |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom Implements : + M.IsTraitInstance + "delphinus_zkwasm::runtime::wasmi_interpreter::Execution" + Self + (* Trait polymorphic types *) [ (* R *) Ty.path "wasmi_core::value::Value" ] + (* Instance *) [ ("run", InstanceField.Method run) ]. + End Impl_delphinus_zkwasm_runtime_wasmi_interpreter_Execution_wasmi_core_value_Value_for_delphinus_zkwasm_runtime_CompiledImage_wasmi_module_NotStartedModuleRef. + + (* StructTuple + { + name := "WasmiRuntime"; + ty_params := []; + fields := []; + } *) + + Module Impl_delphinus_zkwasm_runtime_wasmi_interpreter_WasmiRuntime. + Definition Self : Ty.t := + Ty.path "delphinus_zkwasm::runtime::wasmi_interpreter::WasmiRuntime". + + (* + pub fn new() -> Self { + WasmiRuntime + } + *) + Definition new (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [], [] => + ltac:(M.monadic + (Value.StructTuple "delphinus_zkwasm::runtime::wasmi_interpreter::WasmiRuntime" [])) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new. + + (* + pub fn compile<'a, I: ImportResolver>( + monitor: &mut dyn Monitor, + module: &'a wasmi::Module, + imports: &I, + entry: &str, + ) -> Result>> { + let instance = + ModuleInstance::new(&module, imports).expect("failed to instantiate wasm module"); + monitor.register_module(instance.loaded_module.module(), &instance.instance, entry)?; + + Ok(CompiledImage { + entry: entry.to_owned(), + instance, + }) + } + *) + Definition compile (τ : list Ty.t) (α : list Value.t) : M := + match τ, α with + | [ _ as I ], [ monitor; module; imports; entry ] => + ltac:(M.monadic + (let monitor := M.alloc (| monitor |) in + let module := M.alloc (| module |) in + let imports := M.alloc (| imports |) in + let entry := M.alloc (| entry |) in + M.catch_return (| + ltac:(M.monadic + (M.read (| + let instance := + M.alloc (| + M.call_closure (| + M.get_associated_function (| + Ty.apply + (Ty.path "core::result::Result") + [ Ty.path "wasmi::module::NotStartedModuleRef"; Ty.path "wasmi::Error" + ], + "expect", + [] + |), + [ + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::module::ModuleInstance", + "new", + [ I ] + |), + [ M.read (| module |); M.read (| imports |) ] + |); + M.read (| Value.String "failed to instantiate wasm module" |) + ] + |) + |) in + let _ := + M.match_operator (| + M.alloc (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::Try", + Ty.apply + (Ty.path "core::result::Result") + [ Ty.tuple []; Ty.path "wasmi::Error" ], + [], + "branch", + [] + |), + [ + M.call_closure (| + M.get_trait_method (| + "wasmi::monitor::Monitor", + Ty.dyn [ ("wasmi::monitor::Monitor::Trait", []) ], + [], + "register_module", + [] + |), + [ + M.read (| monitor |); + M.call_closure (| + M.get_associated_function (| + Ty.path "wasmi::Module", + "module", + [] + |), + [ + M.read (| + M.SubPointer.get_struct_record_field (| + instance, + "wasmi::module::NotStartedModuleRef", + "loaded_module" + |) + |) + ] + |); + M.SubPointer.get_struct_record_field (| + instance, + "wasmi::module::NotStartedModuleRef", + "instance" + |); + M.read (| entry |) + ] + |) + ] + |) + |), + [ + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Break", + 0 + |) in + let residual := M.copy (| γ0_0 |) in + M.alloc (| + M.never_to_any (| + M.read (| + M.return_ (| + M.call_closure (| + M.get_trait_method (| + "core::ops::try_trait::FromResidual", + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.apply + (Ty.path "delphinus_zkwasm::runtime::CompiledImage") + [ Ty.path "wasmi::module::NotStartedModuleRef" ]; + Ty.path "anyhow::Error" + ], + [ + Ty.apply + (Ty.path "core::result::Result") + [ + Ty.path "core::convert::Infallible"; + Ty.path "wasmi::Error" + ] + ], + "from_residual", + [] + |), + [ M.read (| residual |) ] + |) + |) + |) + |) + |))); + fun γ => + ltac:(M.monadic + (let γ0_0 := + M.SubPointer.get_struct_tuple_field (| + γ, + "core::ops::control_flow::ControlFlow::Continue", + 0 + |) in + let val := M.copy (| γ0_0 |) in + val)) + ] + |) in + M.alloc (| + Value.StructTuple + "core::result::Result::Ok" + [ + Value.StructRecord + "delphinus_zkwasm::runtime::CompiledImage" + [ + ("entry", + M.call_closure (| + M.get_trait_method (| + "alloc::borrow::ToOwned", + Ty.path "str", + [], + "to_owned", + [] + |), + [ M.read (| entry |) ] + |)); + ("instance", M.read (| instance |)) + ] + ] + |) + |))) + |))) + | _, _ => M.impossible + end. + + Axiom AssociatedFunction_compile : M.IsAssociatedFunction Self "compile" compile. + End Impl_delphinus_zkwasm_runtime_wasmi_interpreter_WasmiRuntime. + End wasmi_interpreter. +End runtime. diff --git a/CoqOfRust/zkWasm/simulations/deps.v b/CoqOfRust/zkWasm/simulations/deps.v new file mode 100644 index 000000000..4e850067f --- /dev/null +++ b/CoqOfRust/zkWasm/simulations/deps.v @@ -0,0 +1,40 @@ +(** * Various definitions coming from the dependencies of the project. *) +Require Import CoqOfRust.CoqOfRust. +Require Import simulations.M. + +Import simulations.M.Notations. + +(* pub trait FieldExt: ff::PrimeField + BaseExt + Group + From { + /// Inverse of $2$ in the field. + const TWO_INV: Self; + + /// Inverse of `ROOT_OF_UNITY` + const ROOT_OF_UNITY_INV: Self; + + /// Generator of the $t-order$ multiplicative subgroup + const DELTA: Self; + + /// Element of multiplicative order $3$. + const ZETA: Self; + + /// Obtains a field element congruent to the integer `v`. + fn from_u128(v: u128) -> Self; + + // /// Converts this field element to its normalized, little endian byte + // /// representation. + // fn to_bytes(&self) -> [u8; 32]; + + // /// Attempts to obtain a field element from its normalized, little endian + // /// byte representation. + // fn from_bytes(bytes: &[u8; 32]) -> CtOption; + + /// Gets the lower 128 bits of this field element when expressed + /// canonically. + fn get_lower_128(&self) -> u128; +} *) +Module FieldExt. + Local Unset Primitive Projections. + Class Trait (Self : Set) : Set := { + }. + Global Set Primitive Projections. +End FieldExt. diff --git a/CoqOfRust/zkWasm/simulations/state.v b/CoqOfRust/zkWasm/simulations/state.v new file mode 100644 index 000000000..6fdf7d3c9 --- /dev/null +++ b/CoqOfRust/zkWasm/simulations/state.v @@ -0,0 +1,33 @@ +Require Import CoqOfRust.CoqOfRust. +Require Import simulations.M. + +Require Import zkWasm.circuits.etable.simulations.allocator_type. +Require Import zkWasm.circuits.etable.simulations.constraint_builder. + +Import simulations.M.Notations. + +Module State. + (* + allocator: &mut EventTableCellAllocator, + constraint_builder: &mut ConstraintBuilder, + *) + Record t {F : Set} {H : deps.FieldExt.Trait F} : Set := { + allocator : EventTableCellAllocator.t F; + constraint_builder : ConstraintBuilder.t F; + }. + Arguments t _ {_}. + + Module Lens. + Definition allocator {F : Set} {_ : deps.FieldExt.Trait F} : + Lens.t (t F) (EventTableCellAllocator.t F) := {| + Lens.read st := st.(allocator); + Lens.write st v := st <| allocator := v |>; + |}. + + Definition constraint_builder {F : Set} {_ : deps.FieldExt.Trait F} : + Lens.t (t F) (ConstraintBuilder.t F) := {| + Lens.read st := st.(constraint_builder); + Lens.write st v := st <| constraint_builder := v |>; + |}. + End Lens. +End State. diff --git a/lib/src/path.rs b/lib/src/path.rs index 473477df6..24c858acd 100644 --- a/lib/src/path.rs +++ b/lib/src/path.rs @@ -139,7 +139,7 @@ pub(crate) fn to_valid_coq_name(is_value: IsValue, str: &str) -> String { let str = str.replace("::", "_"); let str = str.replace('+', "_plus_"); let characters_to_replace = [ - ' ', '$', '(', ')', '&', '?', ',', '<', '>', '=', '[', ']', '*', + ' ', '$', '(', ')', '&', '?', ',', ';', '<', '>', '=', '[', ']', '*', ]; let str = characters_to_replace .iter()